core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerStringAbstract.java
public static OType getType(final String iValue) {
    if (iValue.length() == 0)
      return null;

    final char firstChar = iValue.charAt(0);

    if (firstChar == ORID.PREFIX)
      // RID
      return OType.LINK;
    else if (firstChar == '\'' || firstChar == '"')
      return OType.STRING;
    else if (firstChar == OStringSerializerHelper.BINARY_BEGINEND)
      return OType.BINARY;
    else if (firstChar == OStringSerializerHelper.EMBEDDED_BEGIN)
      return OType.EMBEDDED;
    else if (firstChar == OStringSerializerHelper.LIST_BEGIN)
      return OType.EMBEDDEDLIST;
    else if (firstChar == OStringSerializerHelper.SET_BEGIN)
      return OType.EMBEDDEDSET;
    else if (firstChar == OStringSerializerHelper.MAP_BEGIN)
      return OType.EMBEDDEDMAP;
    else if (firstChar == OStringSerializerHelper.CUSTOM_TYPE)
      return OType.CUSTOM;

    // BOOLEAN?
    if (iValue.equalsIgnoreCase("true") || iValue.equalsIgnoreCase("false"))
      return OType.BOOLEAN;

    // NUMBER OR STRING?
    boolean integer = true;
    for (int index = 0; index < iValue.length(); ++index) {
      final char c = iValue.charAt(index);
      if (c < '0' || c > '9')
        if ((index == 0 && (c == '+' || c == '-')))
          continue;
        else if (c == DECIMAL_SEPARATOR)
          integer = false;
        else {
          if (index > 0)
            if (!integer && c == 'E') {
              // CHECK FOR SCIENTIFIC NOTATION
              if (index < iValue.length()) {
                if (iValue.charAt(index + 1) == '-')
                  // JUMP THE DASH IF ANY (NOT MANDATORY)
                  index++;
                continue;
              }
            } else if (c == 'f')
              return index != (iValue.length() - 1) ? OType.STRING : OType.FLOAT;
            else if (c == 'c')
              return index != (iValue.length() - 1) ? OType.STRING : OType.DECIMAL;
            else if (c == 'l')
              return index != (iValue.length() - 1) ? OType.STRING : OType.LONG;
            else if (c == 'd')
              return index != (iValue.length() - 1) ? OType.STRING : OType.DOUBLE;
            else if (c == 'b')
              return index != (iValue.length() - 1) ? OType.STRING : OType.BYTE;
            else if (c == 'a')
              return index != (iValue.length() - 1) ? OType.STRING : OType.DATE;
            else if (c == 't')
              return index != (iValue.length() - 1) ? OType.STRING : OType.DATETIME;
            else if (c == 's')
              return index != (iValue.length() - 1) ? OType.STRING : OType.SHORT;
            else if (c == 'e') { //eg. 1e-06
              try{
                Double.parseDouble(iValue);
                return  OType.DOUBLE;
              } catch (Exception ignore) {
                return OType.STRING;
              }
            }

          return OType.STRING;
        }
    }

    if (integer) {
      // AUTO CONVERT TO LONG IF THE INTEGER IS TOO BIG
      final int numberLength = iValue.length();
      if (numberLength > MAX_INTEGER_DIGITS || (numberLength == MAX_INTEGER_DIGITS && iValue.compareTo(MAX_INTEGER_AS_STRING) > 0))
        return OType.LONG;

      return OType.INTEGER;
    }

    // CHECK IF THE DECIMAL NUMBER IS A FLOAT OR DOUBLE
    final double dou = Double.parseDouble(iValue);
    if (dou <= Float.MAX_VALUE && dou >= Float.MIN_VALUE && Double.toString(dou).equals(Float.toString((float) dou))
        && new Double(new Double(dou).floatValue()).doubleValue() == dou) {
      return OType.FLOAT;
    } else if (!new Double(dou).toString().equals(iValue)) {
      return OType.DECIMAL;
    }

    return OType.DOUBLE;
  }
public static OType getType(final String iValue) {
    if (iValue.length() == 0)
      return null;

    final char firstChar = iValue.charAt(0);

    if (firstChar == ORID.PREFIX)
      // RID
      return OType.LINK;
    else if (firstChar == '\'' || firstChar == '"')
      return OType.STRING;
    else if (firstChar == OStringSerializerHelper.BINARY_BEGINEND)
      return OType.BINARY;
    else if (firstChar == OStringSerializerHelper.EMBEDDED_BEGIN)
      return OType.EMBEDDED;
    else if (firstChar == OStringSerializerHelper.LIST_BEGIN)
      return OType.EMBEDDEDLIST;
    else if (firstChar == OStringSerializerHelper.SET_BEGIN)
      return OType.EMBEDDEDSET;
    else if (firstChar == OStringSerializerHelper.MAP_BEGIN)
      return OType.EMBEDDEDMAP;
    else if (firstChar == OStringSerializerHelper.CUSTOM_TYPE)
      return OType.CUSTOM;

    // BOOLEAN?
    if (iValue.equalsIgnoreCase("true") || iValue.equalsIgnoreCase("false"))
      return OType.BOOLEAN;

    // NUMBER OR STRING?
    boolean integer = true;
    for (int index = 0; index < iValue.length(); ++index) {
      final char c = iValue.charAt(index);
      if (c < '0' || c > '9')
        if ((index == 0 && (c == '+' || c == '-')))
          continue;
        else if (c == DECIMAL_SEPARATOR)
          integer = false;
        else {
          if (index > 0)
            if (!integer && c == 'E') {
              // CHECK FOR SCIENTIFIC NOTATION
              if (index < iValue.length()) {
                if (iValue.charAt(index + 1) == '-')
                  // JUMP THE DASH IF ANY (NOT MANDATORY)
                  index++;
                continue;
              }
            } else if (c == 'f')
              return index != (iValue.length() - 1) ? OType.STRING : OType.FLOAT;
            else if (c == 'c')
              return index != (iValue.length() - 1) ? OType.STRING : OType.DECIMAL;
            else if (c == 'l')
              return index != (iValue.length() - 1) ? OType.STRING : OType.LONG;
            else if (c == 'd')
              return index != (iValue.length() - 1) ? OType.STRING : OType.DOUBLE;
            else if (c == 'b')
              return index != (iValue.length() - 1) ? OType.STRING : OType.BYTE;
            else if (c == 'a')
              return index != (iValue.length() - 1) ? OType.STRING : OType.DATE;
            else if (c == 't')
              return index != (iValue.length() - 1) ? OType.STRING : OType.DATETIME;
            else if (c == 's')
              return index != (iValue.length() - 1) ? OType.STRING : OType.SHORT;
            else if (c == 'e') { //eg. 1e-06
              try{
                Double.parseDouble(iValue);
                return  OType.DOUBLE;
              } catch (Exception ignore) {
                return OType.STRING;
              }
            }

          return OType.STRING;
        }
    }

    if (integer) {
      // AUTO CONVERT TO LONG IF THE INTEGER IS TOO BIG
      final int numberLength = iValue.length();
      if (numberLength > MAX_INTEGER_DIGITS || (numberLength == MAX_INTEGER_DIGITS && iValue.compareTo(MAX_INTEGER_AS_STRING) > 0))
        return OType.LONG;

      return OType.INTEGER;
    }

    // CHECK IF THE DECIMAL NUMBER IS A FLOAT OR DOUBLE
    final double dou = Double.parseDouble(iValue);
    if (dou <= Float.MAX_VALUE && dou >= Float.MIN_VALUE && Double.toString(dou).equals(Float.toString((float) dou))
        && new Double(new Double(dou).floatValue()).doubleValue() == dou) {
      return OType.FLOAT;
    } else if (!new Double(dou).toString().equals(iValue)) {
      return OType.DECIMAL;
    }

    return OType.DOUBLE;
  }
public static OType getType ( final String iValue ) { if ( iValue . length ( ) == 0 ) return null ; final char firstChar = iValue . charAt ( 0 ) ; if ( firstChar == ORID . PREFIX ) // RID
 return OType . LINK ; else if ( firstChar == ' ' || firstChar == ' ' ) return OType . STRING ; else if ( firstChar == OStringSerializerHelper . BINARY_BEGINEND ) return OType . BINARY ; else if ( firstChar == OStringSerializerHelper . EMBEDDED_BEGIN ) return OType . EMBEDDED ; else if ( firstChar == OStringSerializerHelper . LIST_BEGIN ) return OType . EMBEDDEDLIST ; else if ( firstChar == OStringSerializerHelper . SET_BEGIN ) return OType . EMBEDDEDSET ; else if ( firstChar == OStringSerializerHelper . MAP_BEGIN ) return OType . EMBEDDEDMAP ; else if ( firstChar == OStringSerializerHelper . CUSTOM_TYPE ) return OType . CUSTOM ; // BOOLEAN?
 if ( iValue . equalsIgnoreCase ( "true" ) || iValue . equalsIgnoreCase ( "false" ) ) return OType . BOOLEAN ; // NUMBER OR STRING?
 boolean integer = true ; for ( int index = 0 ; index < iValue . length ( ) ; ++ index ) { final char c = iValue . charAt ( index ) ; if ( c < ' ' || c > ' ' ) if ( ( index == 0 && ( c == ' ' || c == ' ' ) ) ) continue ; else if ( c == DECIMAL_SEPARATOR ) integer = false ; else { if ( index > 0 ) if ( ! integer && c == ' ' ) { // CHECK FOR SCIENTIFIC NOTATION
 if ( index < iValue . length ( ) ) { if ( iValue . charAt ( index + 1 ) == ' ' ) // JUMP THE DASH IF ANY (NOT MANDATORY)
 index ++ ; continue ; } } else if ( c == ' ' ) return index != ( iValue . length ( ) - 1 ) ? OType . STRING : OType . FLOAT ; else if ( c == ' ' ) return index != ( iValue . length ( ) - 1 ) ? OType . STRING : OType . DECIMAL ; else if ( c == ' ' ) return index != ( iValue . length ( ) - 1 ) ? OType . STRING : OType . LONG ; else if ( c == ' ' ) return index != ( iValue . length ( ) - 1 ) ? OType . STRING : OType . DOUBLE ; else if ( c == ' ' ) return index != ( iValue . length ( ) - 1 ) ? OType . STRING : OType . BYTE ; else if ( c == ' ' ) return index != ( iValue . length ( ) - 1 ) ? OType . STRING : OType . DATE ; else if ( c == ' ' ) return index != ( iValue . length ( ) - 1 ) ? OType . STRING : OType . DATETIME ; else if ( c == ' ' ) return index != ( iValue . length ( ) - 1 ) ? OType . STRING : OType . SHORT ; else if ( c == ' ' ) { //eg. 1e-06
 try { Double . parseDouble ( iValue ) ; return OType . DOUBLE ; } catch ( Exception ignore ) { return OType . STRING ; } } return OType . STRING ; } } if ( integer ) { // AUTO CONVERT TO LONG IF THE INTEGER IS TOO BIG
 final int numberLength = iValue . length ( ) ; if ( numberLength > MAX_INTEGER_DIGITS || ( numberLength == MAX_INTEGER_DIGITS && iValue . compareTo ( MAX_INTEGER_AS_STRING ) > 0 ) ) return OType . LONG ; return OType . INTEGER ; } // CHECK IF THE DECIMAL NUMBER IS A FLOAT OR DOUBLE
 final double dou = Double . parseDouble ( iValue ) ; if ( dou <= Float . MAX_VALUE && dou >= Float . MIN_VALUE && Double . toString ( dou ) . equals ( Float . toString ( ( float ) dou ) ) && new Double ( new Double ( dou ) . floatValue ( ) ) . doubleValue ( ) == dou ) { return OType . FLOAT ; } else if ( ! new Double ( dou ) . toString ( ) . equals ( iValue ) ) { return OType . DECIMAL ; } return OType . DOUBLE ; }
Parses a string returning the closer type. Numbers by default are INTEGER if haven't decimal separator, otherwise FLOAT. To
treat all the number types numbers are postponed with a character that tells the type: b=byte, s=short, l=long, f=float,
d=double, t=date.

@param iValue
Value to parse
@return The closest type recognized
Parses a string returning the closer type . Numbers by default are INTEGER if haven t decimal separator otherwise FLOAT . To treat all the number types numbers are postponed with a character that tells the type : b = byte s = short l = long f = float d = double t = date .