private static Object convertStringToPrimitiveOrPrimitiveWrapper(String value, final Class<?> expectedClz)
    throws VoltTypeException
    {
        value = value.trim();
        // detect CSV null
        if (value.equals(Constants.CSV_NULL)) return nullValueForType(expectedClz);

        // Remove commas.  Doing this seems kind of dubious since it lets strings like
        //    ,,,3.1,4,,e,+,,16
        // be parsed as a valid double value (for example).
        String commaFreeValue = thousandSeparator.matcher(value).replaceAll("");

        try {
            // autoboxing converts to boxed types since this method returns a java Object
            if (isLongClass(expectedClz)) {
                return Long.parseLong(commaFreeValue);
            }
            if (isIntClass(expectedClz)) {
                return Integer.parseInt(commaFreeValue);
            }
            if (isShortClass(expectedClz)) {
                return Short.parseShort(commaFreeValue);
            }
            if (isByteClass(expectedClz)) {
                return Byte.parseByte(commaFreeValue);
            }
            if (isDoubleClass(expectedClz)) {
                return Double.parseDouble(commaFreeValue);
            }
        }
        // ignore the exception and fail through below
        catch (NumberFormatException nfe) {

            // If we failed to parse the string in decimal form it could still
            // be a numeric value specified as X'....'
            //
            // Do this only after trying to parse a decimal literal, which is the
            // most common case.
            if (expectedClz != double.class) {
                String hexDigits = SQLParser.getDigitsFromHexLiteral(value);
                if (hexDigits != null) {
                    try {
                        return SQLParser.hexDigitsToLong(hexDigits);
                    }
                    catch (SQLParser.Exception spe) {
                    }
                }
            }
        }

        throw new VoltTypeException(
                "Unable to convert string "
                + value + " to "  + expectedClz.getName()
                + " value for target parameter.");
    }
private static Object convertStringToPrimitiveOrPrimitiveWrapper ( String value , final Class < ? > expectedClz ) throws VoltTypeException { value = value . trim ( ) ; if ( value . equals ( Constants . CSV_NULL ) ) return nullValueForType ( expectedClz ) ; String commaFreeValue = thousandSeparator . matcher ( value ) . replaceAll ( "" ) ; try { if ( isLongClass ( expectedClz ) ) { return Long . parseLong ( commaFreeValue ) ; } if ( isIntClass ( expectedClz ) ) { return Integer . parseInt ( commaFreeValue ) ; } if ( isShortClass ( expectedClz ) ) { return Short . parseShort ( commaFreeValue ) ; } if ( isByteClass ( expectedClz ) ) { return Byte . parseByte ( commaFreeValue ) ; } if ( isDoubleClass ( expectedClz ) ) { return Double . parseDouble ( commaFreeValue ) ; } } catch ( NumberFormatException nfe ) { if ( expectedClz != double . class ) { String hexDigits = SQLParser . getDigitsFromHexLiteral ( value ) ; if ( hexDigits != null ) { try { return SQLParser . hexDigitsToLong ( hexDigits ) ; } catch ( SQLParser . Exception spe ) { } } } } throw new VoltTypeException ( "Unable to convert string " + value + " to " + expectedClz . getName ( ) + " value for target parameter." ) ; }
Given a string, covert it to a primitive type or boxed type of the primitive type or return null.

If the string value is a VARBINARY constant of the form X'00ABCD', and the
expected class is one of byte, short, int or long, then we interpret the
string as specifying bits of a 64-bit signed integer (padded with zeroes if
there are fewer than 16 digits).
Corresponding code for handling hex literals appears in HSQL's ExpressionValue class
and in voltdb.expressions.ConstantValueExpression.