code: public static Number parseNumber( String numberAsString )  throws InvalidSelectorException
      {
          if (numberAsString == null) return null;
          try
          {
              if (numberAsString.indexOf('.') != -1 || 
                  numberAsString.indexOf('e') != -1 ||
                  numberAsString.indexOf('E') != -1)
              {
                  return new Double(numberAsString);
              }
              else
                  return Long.valueOf(numberAsString);
          }
          catch (NumberFormatException e)
          {
              throw new InvalidSelectorException("Invalid numeric value : "+numberAsString);
          }
      }
docs: Parse a number as string