public NSNumber(String text){
  if (text == null)   throw new IllegalArgumentException("The given string is null and cannot be parsed as number.");
  try {
    long l;
    if (text.startsWith("0x")) {
      l=Long.parseLong(text.substring(2),16);
    }
 else {
      l=Long.parseLong(text);
    }
    doubleValue=longValue=l;
    type=INTEGER;
  }
 catch (  Exception ex) {
    try {
      doubleValue=Double.parseDouble(text);
      longValue=Math.round(doubleValue);
      type=REAL;
    }
 catch (    Exception ex2) {
      try {
        boolValue=text.equalsIgnoreCase("true") || text.equalsIgnoreCase("yes");
        if (!boolValue && !(text.equalsIgnoreCase("false") || text.equalsIgnoreCase("no"))) {
          throw new Exception("not a boolean");
        }
        type=BOOLEAN;
        doubleValue=longValue=boolValue ? 1 : 0;
      }
 catch (      Exception ex3) {
        throw new IllegalArgumentException("The given string neither represents a double, an int nor a boolean value.");
      }
    }
  }
}

public NSNumber ( String text ) { if ( text == null ) throw new IllegalArgumentException ( "The given string is null and cannot be parsed as number." ) ; try { long l ; if ( text . startsWith ( "0x" ) ) { l = Long . parseLong ( text . substring ( 2 ) , 16 ) ; } else { l = Long . parseLong ( text ) ; } doubleValue = longValue = l ; type = INTEGER ; } catch ( Exception ex ) { try { doubleValue = Double . parseDouble ( text ) ; longValue = Math . round ( doubleValue ) ; type = REAL ; } catch ( Exception ex2 ) { try { boolValue = text . equalsIgnoreCase ( "true" ) || text . equalsIgnoreCase ( "yes" ) ; if ( ! boolValue && ! ( text . equalsIgnoreCase ( "false" ) || text . equalsIgnoreCase ( "no" ) ) ) { throw new Exception ( "not a boolean" ) ; } type = BOOLEAN ; doubleValue = longValue = boolValue ? 1 : 0 ; } catch ( Exception ex3 ) { throw new IllegalArgumentException ( "The given string neither represents a double, an int nor a boolean value." ) ; } } } }
creates a number from its textual representation .
