private int parseIntValue(String input) throws NumberFormatException {
  int value=0;
  if (input.startsWith("+")) {
    String temp=input.substring(1);
    return Integer.parseInt(temp);
  }
 else   if (input.startsWith("0x")) {
    String temp=input.substring(2);
    char[] chars=temp.toCharArray();
    if (chars.length > 8) {
      throw new NumberFormatException();
    }
 else {
      for (int i=0; i < chars.length; i++) {
        int index=chars.length - i - 1;
switch (chars[i]) {
case '0':
          value+=0;
        break;
case '1':
      value+=1 * getBase(index);
    break;
case '2':
  value+=2 * getBase(index);
break;
case '3':
value+=3 * getBase(index);
break;
case '4':
value+=4 * getBase(index);
break;
case '5':
value+=5 * getBase(index);
break;
case '6':
value+=6 * getBase(index);
break;
case '7':
value+=7 * getBase(index);
break;
case '8':
value+=8 * getBase(index);
break;
case '9':
value+=9 * getBase(index);
break;
case 'a':
case 'A':
value+=10 * getBase(index);
break;
case 'b':
case 'B':
value+=11 * getBase(index);
break;
case 'c':
case 'C':
value+=12 * getBase(index);
break;
case 'd':
case 'D':
value+=13 * getBase(index);
break;
case 'e':
case 'E':
value+=14 * getBase(index);
break;
case 'f':
case 'F':
value+=15 * getBase(index);
break;
default :
throw new NumberFormatException("Invalid numerical format");
}
}
}
if (value < 0) {
throw new NumberFormatException("Data overflow.");
}
}
 else {
value=Integer.parseInt(input);
}
return value;
}

private int parseIntValue ( String input ) throws NumberFormatException { int value = 0 ; if ( input . startsWith ( "+" ) ) { String temp = input . substring ( 1 ) ; return Integer . parseInt ( temp ) ; } else if ( input . startsWith ( "0x" ) ) { String temp = input . substring ( 2 ) ; char [ ] chars = temp . toCharArray ( ) ; if ( chars . length > 8 ) { throw new NumberFormatException ( ) ; } else { for ( int i = 0 ; i < chars . length ; i ++ ) { int index = chars . length - i - 1 ; switch ( chars [ i ] ) { case '0' : value += 0 ; break ; case '1' : value += 1 * getBase ( index ) ; break ; case '2' : value += 2 * getBase ( index ) ; break ; case '3' : value += 3 * getBase ( index ) ; break ; case '4' : value += 4 * getBase ( index ) ; break ; case '5' : value += 5 * getBase ( index ) ; break ; case '6' : value += 6 * getBase ( index ) ; break ; case '7' : value += 7 * getBase ( index ) ; break ; case '8' : value += 8 * getBase ( index ) ; break ; case '9' : value += 9 * getBase ( index ) ; break ; case 'a' : case 'A' : value += 10 * getBase ( index ) ; break ; case 'b' : case 'B' : value += 11 * getBase ( index ) ; break ; case 'c' : case 'C' : value += 12 * getBase ( index ) ; break ; case 'd' : case 'D' : value += 13 * getBase ( index ) ; break ; case 'e' : case 'E' : value += 14 * getBase ( index ) ; break ; case 'f' : case 'F' : value += 15 * getBase ( index ) ; break ; default : throw new NumberFormatException ( "Invalid numerical format" ) ; } } } if ( value < 0 ) { throw new NumberFormatException ( "Data overflow." ) ; } } else { value = Integer . parseInt ( input ) ; } return value ; }
parses a string to an integer . the convertible strings include the string representations of positive integers , negative integers , and hex decimal integers . valid inputs are , e . g . , - 1234 , + 1234 , 0x40000 .
