code: public static int parseInteger(String rule, int[] pos, int limit) {
          int count = 0;
          int value = 0;
          int p = pos[0];
          int radix = 10;
  
          if (rule.regionMatches(true, p, "0x", 0, 2)) {
              p += 2;
              radix = 16;
          } else if (p < limit && rule.charAt(p) == '0') {
              p++;
              count = 1;
              radix = 8;
          }
  
          while (p < limit) {
              int d = UCharacter.digit(rule.charAt(p++), radix);
              if (d < 0) {
                  --p;
                  break;
              }
              ++count;
              int v = (value * radix) + d;
              if (v <= value) {
                  // If there are too many input digits, at some point
                  // the value will go negative, e.g., if we have seen
                  // "0x8000000" already and there is another '0', when
                  // we parse the next 0 the value will go negative.
                  return 0;
              }
              value = v;
          }
          if (count > 0) {
              pos[0] = p;
          }
          return value;
      }
docs: Parse an integer at pos, either of the form \d+ or of the form
  0x[0-9A-Fa-f]+ or 0[0-7]+, that is, in standard decimal, hex,
  or octal format.
  @param pos INPUT-OUTPUT parameter.  On input, the first
  character to parse.  On output, the character after the last
  parsed character.