private static String normalizeIntegerValue(String integer,String minValue,String maxValue){
  integer=collapseWhiteSpace(integer);
  int intLength=integer.length();
  if (intLength == 0) {
    throwIAE("Not a legal integer: " + integer);
  }
  int idx=0;
  boolean isNegative=false;
  if (integer.charAt(idx) == '-') {
    isNegative=true;
    idx++;
  }
 else   if (integer.charAt(idx) == '+') {
    idx++;
  }
  if (idx == intLength) {
    throwIAE("Not a legal integer: " + integer);
  }
  if (integer.charAt(idx) == '0' && idx < intLength - 1) {
    idx++;
    while (idx < intLength - 1 && integer.charAt(idx) == '0') {
      idx++;
    }
  }
  String norm=integer.substring(idx);
  for (int i=0; i < norm.length(); i++) {
    if (!isDigit(norm.charAt(i))) {
      throwIAE("Not a legal integer: " + integer);
    }
  }
  if (isNegative && norm.charAt(0) != '0') {
    norm="-" + norm;
  }
  if (minValue != null) {
    if (compareCanonicalIntegers(norm,minValue) < 0) {
      throwIAE("Value smaller than minimum value");
    }
  }
  if (maxValue != null) {
    if (compareCanonicalIntegers(norm,maxValue) > 0) {
      throwIAE("Value larger than maximum value");
    }
  }
  return norm;
}

private static String normalizeIntegerValue ( String integer , String minValue , String maxValue ) { integer = collapseWhiteSpace ( integer ) ; int intLength = integer . length ( ) ; if ( intLength == 0 ) { throwIAE ( "Not a legal integer: " + integer ) ; } int idx = 0 ; boolean isNegative = false ; if ( integer . charAt ( idx ) == '-' ) { isNegative = true ; idx ++ ; } else if ( integer . charAt ( idx ) == '+' ) { idx ++ ; } if ( idx == intLength ) { throwIAE ( "Not a legal integer: " + integer ) ; } if ( integer . charAt ( idx ) == '0' && idx < intLength - 1 ) { idx ++ ; while ( idx < intLength - 1 && integer . charAt ( idx ) == '0' ) { idx ++ ; } } String norm = integer . substring ( idx ) ; for ( int i = 0 ; i < norm . length ( ) ; i ++ ) { if ( ! isDigit ( norm . charAt ( i ) ) ) { throwIAE ( "Not a legal integer: " + integer ) ; } } if ( isNegative && norm . charAt ( 0 ) != '0' ) { norm = "-" + norm ; } if ( minValue != null ) { if ( compareCanonicalIntegers ( norm , minValue ) < 0 ) { throwIAE ( "Value smaller than minimum value" ) ; } } if ( maxValue != null ) { if ( compareCanonicalIntegers ( norm , maxValue ) > 0 ) { throwIAE ( "Value larger than maximum value" ) ; } } return norm ; }
normalizes an integer to its canonical representation and checks that the value is in the range [ minvalue , maxvalue ] .
