code: static int getHexDigit(String s, int position) {
          int value = Character.digit(s.charAt(position), 16);
          if (value <= -1 || value >= 16) {
              throw new AssertionError("Unexpected failure of digit conversion of " +
                                       s.charAt(position));
          }
          return value;
      }
docs: Extracts a hexadecimal digit from position <code>position</code>
  of string <code>s</code>.