Example usage for java.lang Character MIN_VALUE

List of usage examples for java.lang Character MIN_VALUE

Introduction

In this page you can find the example usage for java.lang Character MIN_VALUE.

Prototype

char MIN_VALUE

To view the source code for java.lang Character MIN_VALUE.

Click Source Link

Document

The constant value of this field is the smallest value of type char , '\u005Cu0000' .

Usage

From source file:net.jofm.metadata.PrimitiveFieldMetaData.java

private static Format createFormatter(Field fieldAnnotation, Class<?> fieldType, String fieldName,
        FormatConfig formatConfig) {/*from  ww  w  . j av a 2 s .c o m*/
    String defaultFormat = "";
    Class<? extends Format> formatterClazz = null;
    if (Date.class.isAssignableFrom(fieldType) || Calendar.class.isAssignableFrom(fieldType)) {
        defaultFormat = formatConfig.getDateFormat();
        formatterClazz = DateFormat.class;
    } else if (String.class.isAssignableFrom(fieldType)) {
        formatterClazz = StringFormat.class;
    } else if (fieldType.equals(BigDecimal.class)) {
        defaultFormat = formatConfig.getBigDecimalFormat();
        formatterClazz = NumberFormat.class;
    } else if (fieldType.equals(Short.class) || fieldType.equals(short.class)) {
        defaultFormat = formatConfig.getShortFormat();
        formatterClazz = NumberFormat.class;
    } else if (fieldType.equals(Integer.class) || fieldType.equals(int.class)) {
        defaultFormat = formatConfig.getIntFormat();
        formatterClazz = NumberFormat.class;
    } else if (fieldType.equals(Long.class) || fieldType.equals(long.class)) {
        defaultFormat = formatConfig.getLongFormat();
        formatterClazz = NumberFormat.class;
    } else if (fieldType.equals(Float.class) || fieldType.equals(float.class)) {
        defaultFormat = formatConfig.getFloatFormat();
        formatterClazz = NumberFormat.class;
    } else if (fieldType.equals(Double.class) || fieldType.equals(double.class)) {
        defaultFormat = formatConfig.getDoubleFormat();
        formatterClazz = NumberFormat.class;
    } else if (fieldType.equals(Boolean.class) || fieldType.equals(boolean.class)) {
        defaultFormat = formatConfig.getBooleanFormat();
        formatterClazz = BooleanFormat.class;
    } else if (fieldType.isEnum()) {
        formatterClazz = EnumFormat.class;
    }

    if (fieldAnnotation.formatter() != null && !fieldAnnotation.formatter().equals(DefaultFormat.class)) {
        formatterClazz = fieldAnnotation.formatter();
    }

    if (formatterClazz == null) {
        throw new FixedMappingException(
                "Unable to find formatter for field '" + fieldName + "' of type " + fieldType);
    }

    try {
        Constructor<?> c = formatterClazz
                .getConstructor(new Class[] { Pad.class, char.class, int.class, String.class });

        Pad pad = fieldAnnotation.pad() == Pad.DEFAULT ? formatConfig.getPad() : fieldAnnotation.pad();
        char padWith = fieldAnnotation.padWith() == Character.MIN_VALUE ? formatConfig.getPadWith()
                : fieldAnnotation.padWith();
        int length = fieldAnnotation.length();
        String format = StringUtils.isEmpty(fieldAnnotation.format()) ? defaultFormat
                : fieldAnnotation.format();

        return (Format) c.newInstance(new Object[] { pad, padWith, length, format });
    } catch (Exception e) {
        throw new FixedMappingException(
                "Unable to instantiate the formatter " + formatterClazz + " for field '" + fieldName + "'", e);
    }
}

From source file:de.knightsoftnet.validators.shared.util.RegExUtil.java

/**
 * get all allowed characters which can be part of a String which matches a given regular
 * expression. TODO: this is a first feature incomplete implementation, has to be improved.
 *
 * @param pregEx string contains a regular expression pattern
 * @return string with all characters that can be part of a string that matches the regex
 *//*from   w  ww  .  ja va 2 s .c o  m*/
public static String getAllowedCharactersForRegEx(final String pregEx) {
    if (StringUtils.isEmpty(pregEx)) {
        return null;
    }
    final StringBuilder regExCheck = new StringBuilder();
    final StringBuilder regExCheckOut = new StringBuilder();
    boolean inSequence = false;
    boolean isNegativeSequence = false;
    boolean inSize = false;
    boolean isMasked = false;

    regExCheck.append("([");
    for (final char character : pregEx.toCharArray()) {
        switch (character) {
        case '\\':
            if (isMasked || inSequence) {
                regExCheck.append(character);
            }
            if (!inSequence) {
                isMasked = !isMasked;
            }
            break;
        case '^':
            if (inSequence) {
                if (isMasked) {
                    regExCheck.append(character);
                } else {
                    isNegativeSequence = true;
                }
            }
            isMasked = false;
            break;
        case '$':
        case '*':
        case '+':
        case '?':
        case '|':
            if (isMasked || inSequence) {
                regExCheck.append(character);
            }
            isMasked = false;
            break;
        case '[':
            if (isMasked || inSequence) {
                regExCheck.append(character);
            } else {
                inSequence = true;
                isNegativeSequence = false;
            }
            isMasked = false;
            break;
        case ']':
            if (isMasked) {
                regExCheck.append(character);
            } else {
                inSequence = false;
                isNegativeSequence = false;
            }
            isMasked = false;
            break;
        case '{':
            if (isMasked || inSequence) {
                regExCheck.append(character);
            } else {
                inSize = true;
            }
            isMasked = false;
            break;
        case '}':
            if (isMasked || inSequence) {
                regExCheck.append(character);
            } else {
                inSize = false;
            }
            isMasked = false;
            break;
        case '(':
            if (isMasked || inSequence) {
                regExCheck.append(character);
            }
            isMasked = false;
            break;
        case ')':
            if (isMasked || inSequence) {
                regExCheck.append(character);
            }
            isMasked = false;
            break;
        default:
            if (inSize) {
                if (character != ',' && (character < '0' || character > '9')) {
                    regExCheck.append(character);
                }
            } else if (!isNegativeSequence) {
                if (isMasked) {
                    if (regExCheckOut.length() > 1) {
                        regExCheckOut.append('|');
                    }
                    regExCheckOut.append('\\');
                    regExCheckOut.append(character);
                } else {
                    regExCheck.append(character);
                }
            }
            isMasked = false;
            break;
        }
    }
    if (regExCheck.length() < 3) {
        regExCheck.delete(1, regExCheck.length());
    } else {
        regExCheck.append(']');
        if (regExCheckOut.length() > 0) {
            regExCheck.append('|');
        }
    }
    regExCheck.append(regExCheckOut);
    regExCheck.append(')');
    final RegExp regEx = RegExp.compile(regExCheck.toString());
    final StringBuilder result = new StringBuilder();
    for (int count = Character.MIN_VALUE; count < Character.MAX_VALUE; count++) {
        if (regEx.exec(String.valueOf((char) count)) != null) {
            result.append((char) count);
        }
    }
    return result.toString();
}

From source file:jp.terasoluna.fw.file.dao.standard.VariableFileLineIterator.java

/**
 * //from w w  w.j  av  a2  s.c om
 * @param fileName ??
 * @param clazz 
 * @param columnParserMap 
 */
public VariableFileLineIterator(String fileName, Class<T> clazz, Map<String, ColumnParser> columnParserMap) {

    super(fileName, clazz, columnParserMap);

    FileFormat fileFormat = clazz.getAnnotation(FileFormat.class);

    // ?Character.MIN_VALUE????
    if (fileFormat.delimiter() == Character.MIN_VALUE) {
        throw new FileException("Delimiter can not use '\\u0000'.", new IllegalStateException(), fileName);
    }

    // ?????????
    if (fileFormat.lineFeedChar().indexOf(fileFormat.delimiter()) >= 0) {
        throw new FileException("delimiter is the same as lineFeedChar and is no use.",
                new IllegalStateException(), fileName);
    }

    // ??
    this.encloseChar = fileFormat.encloseChar();

    // ?
    this.delimiter = fileFormat.delimiter();

    // ???
    super.init();
}

From source file:jp.terasoluna.fw.file.dao.standard.VariableFileLineIterator.java

/**
 * ????? ???? ????<br>/*from w  w  w  . j  av  a  2s .com*/
 * <code>fileLineString</code>?<code>null</code>???? ?????????<code>String</code>????
 * @param fileLineString ??1?
 * @return ?
 */
@Override
protected String[] separateColumns(String fileLineString) {

    if (fileLineString == null || "".equals(fileLineString)) {
        return new String[0];
    }

    // 1???
    StringBuilder columnBuilder = new StringBuilder();

    // ????
    char previousChar = Character.MIN_VALUE;

    // ??????
    List<String> columnList = new ArrayList<String>();

    boolean isEnclosed = true;
    boolean isEscaped = false;

    int fieldCount = 0;
    char[] columnEncloseChar = getColumnEncloseChar();

    if (!isEnclosed()) {
        return StringUtils.splitByWholeSeparatorPreserveAllTokens(fileLineString,
                Character.toString(delimiter));
    } else {
        for (char currentChar : fileLineString.toCharArray()) {
            if (previousChar == Character.MIN_VALUE) {
                previousChar = currentChar;
            }
            if (previousChar == getEncloseCharcter(columnEncloseChar, fieldCount)) {
                if (isEnclosed) {
                    if (currentChar == getEncloseCharcter(columnEncloseChar, fieldCount)) {
                        isEnclosed = false;
                    }
                } else {
                    if (currentChar == getEncloseCharcter(columnEncloseChar, fieldCount)) {
                        if (isEscaped) {
                            columnBuilder.append(currentChar);
                            isEscaped = false;
                        } else {
                            isEscaped = true;
                        }
                    } else if (currentChar == getDelimiter()) {
                        if (isEscaped) {
                            columnList.add(columnBuilder.toString());
                            previousChar = Character.MIN_VALUE;
                            columnBuilder.delete(0, columnBuilder.length());
                            isEnclosed = true;
                            isEscaped = false;
                            fieldCount++;
                        } else {
                            columnBuilder.append(currentChar);
                            isEscaped = false;
                        }
                    } else {
                        columnBuilder.append(currentChar);
                    }
                }
            } else {
                if (currentChar != getDelimiter()) {
                    columnBuilder.append(currentChar);
                } else {
                    columnList.add(columnBuilder.toString());
                    previousChar = Character.MIN_VALUE;
                    columnBuilder.delete(0, columnBuilder.length());
                    fieldCount++;
                }
            }
        }
        columnList.add(columnBuilder.toString());
        return columnList.toArray(new String[columnList.size()]);
    }
}

From source file:com.tesora.dve.sql.parser.InvokeParser.java

public static ParseResult parse(byte[] line, SchemaContext pc, Charset cs) throws ParserException {
    preparse(pc);/*from   www .jav a 2 s .  c  om*/
    ParserOptions options = ParserOptions.NONE.setDebugLog(true).setResolve().setFailEarly();

    String lineStr = PECharsetUtils.getString(line, cs, true);
    if (lineStr != null) {
        lineStr = StringUtils.strip(lineStr, new String(Character.toString(Character.MIN_VALUE)));
        return parse(buildInputState(lineStr, pc), options, pc);
    }
    return parameterizeAndParse(pc, options, line, cs);
}

From source file:com.tesora.dve.sql.parser.InvokeParser.java

private static ParseResult parameterizeAndParse(SchemaContext pc, ParserOptions options, byte[] line,
        Charset cs) throws ParserException {
    String singleByteEncoded = PECharsetUtils.getString(line, PECharsetUtils.latin1, false);

    logParse(pc, singleByteEncoded, null);

    ListOfPairs<Statement, List<Object>> parameterized = buildParameterizedCommands(singleByteEncoded, cs, pc);
    ArrayList<Statement> out = new ArrayList<Statement>();
    for (Pair<Statement, List<Object>> p : parameterized) {
        DMLStatement dmls = (DMLStatement) p.getFirst();
        String msql = dmls.getSQL(pc, false, true);
        List<Object> params = p.getSecond();
        byte[] modstmt = msql.getBytes(PECharsetUtils.latin1);
        String orig = PECharsetUtils.getString(modstmt, cs, true);
        if (orig == null)
            throw new ParserException(Pass.FIRST,
                    "Unable to parameterize SQL statement to handle characters invalid for character set "
                            + cs.name());
        orig = StringUtils.strip(orig, new String(Character.toString(Character.MIN_VALUE)));
        out.addAll(parse(buildInputState(orig, pc), DEFAULT_PARSER_RULE, options, pc, params,
                TranslatorInitCallback.INSTANCE).getStatements());
    }/* w  w  w  .  java 2s  . c om*/
    return new ParseResult(out, null);
}

From source file:com.oneops.antenna.service.NotificationMessageDao.java

private List<String> getNsIds(String nsPath, NotificationType type) {
    String key = getOrgFromNsPath(nsPath);

    List<String> ids = new ArrayList<String>();
    SliceQuery<String, String, String> sliceQuery = HFactory.createSliceQuery(keyspace, stringSerializer,
            stringSerializer, stringSerializer);
    sliceQuery.setColumnFamily(NS_MAP_CF);
    sliceQuery.setRange(nsPath + Character.MIN_VALUE, nsPath + Character.MAX_VALUE, false, 1000000);
    sliceQuery.setKey(key);/*w  w w.  j a v  a2s.c  o m*/

    QueryResult<ColumnSlice<String, String>> result = sliceQuery.execute();
    ColumnSlice<String, String> resultCols = result.get();
    for (HColumn<String, String> col : resultCols.getColumns()) {
        String id = col.getValue();
        if (type == null) {
            ids.add(id);
        } else {
            if (type.equals(getTypeFromKey(id))) {
                ids.add(id);
            }
        }
    }
    return ids;
}

From source file:jp.terasoluna.fw.file.dao.standard.AbstractFileLineWriter.java

/**
 * ??????//  ww w  . j a v  a2  s .co  m
 */
private void buildFields() {
    List<Field[]> fieldList = new ArrayList<Field[]>();

    // ?
    Class<?> tempClass = clazz;
    Field[] declaredFieldArray = null;
    int allFieldCount = 0;
    while (tempClass != null) {
        declaredFieldArray = tempClass.getDeclaredFields();
        fieldList.add(declaredFieldArray);
        allFieldCount += declaredFieldArray.length;
        tempClass = tempClass.getSuperclass();
    }

    // ?????
    Field[] dataColumnFields = new Field[allFieldCount];

    OutputFileColumn outputFileColumn = null;
    int maxColumnIndex = -1;
    int columnIndex = -1;
    int columnCount = 0;

    for (Field[] fields : fieldList) {
        for (Field field : fields) {
            outputFileColumn = field.getAnnotation(OutputFileColumn.class);
            if (outputFileColumn != null) {
                // ????????
                if (columnFormatterMap.get(field.getType().getName()) == null) {
                    throw new FileException(
                            "There is a type which isn't supported in a "
                                    + "mapping target field in FileLineObject.",
                            new IllegalStateException(), fileName);
                }

                columnIndex = outputFileColumn.columnIndex();
                // Index??????
                if (columnIndex < 0) {
                    throw new FileException("Column Index in FileLineObject is the minus " + "number.",
                            new IllegalStateException(), fileName);
                }
                // Index?????????
                if (dataColumnFields.length <= columnIndex) {
                    throw new FileException(
                            "Column Index in FileLineObject is bigger than " + "the total number of the field.",
                            new IllegalStateException(), fileName);
                }
                // Index??????????
                if (dataColumnFields[columnIndex] == null) {
                    dataColumnFields[columnIndex] = field;
                    if (maxColumnIndex < columnIndex) {
                        maxColumnIndex = columnIndex;
                    }
                    columnCount++;
                } else {
                    throw new FileException("Column Index is duplicate : " + columnIndex, fileName);
                }
            }
        }
    }
    // columnIndex????????
    if (columnCount != (maxColumnIndex + 1)) {
        throw new FileException("columnIndex in FileLineObject is not sequential order.",
                new IllegalStateException(), fileName);
    }

    // (null?)
    if (dataColumnFields.length == columnCount) {
        this.fields = dataColumnFields;
    } else {
        this.fields = new Field[columnCount];
        System.arraycopy(dataColumnFields, 0, this.fields, 0, columnCount);
    }

    // OutputFileColumnList??
    outputFileColumns = new OutputFileColumn[fields.length];
    columnIndexs = new int[fields.length];
    columnFormats = new String[fields.length];
    columnBytes = new int[fields.length];
    paddingTypes = new PaddingType[fields.length];
    paddingChars = new char[fields.length];
    trimTypes = new TrimType[fields.length];
    trimChars = new char[fields.length];

    // ???FileFormat???
    columnEncloseChar = new char[fields.length];
    if (getEncloseChar() != Character.MIN_VALUE) {
        enclosed = true;
        for (int index = 0; index < fields.length; index++) {
            columnEncloseChar[index] = getEncloseChar();
        }
    }

    for (int i = 0; i < fields.length; i++) {
        outputFileColumns[i] = fields[i].getAnnotation(OutputFileColumn.class);
        columnIndexs[i] = outputFileColumns[i].columnIndex();
        columnFormats[i] = outputFileColumns[i].columnFormat();
        columnBytes[i] = outputFileColumns[i].bytes();
        paddingTypes[i] = outputFileColumns[i].paddingType();
        paddingChars[i] = outputFileColumns[i].paddingChar();
        trimTypes[i] = outputFileColumns[i].trimType();
        trimChars[i] = outputFileColumns[i].trimChar();
        // ?inputFileColumns?????
        if (outputFileColumns[i].columnEncloseChar() != Character.MIN_VALUE) {
            columnEncloseChar[i] = outputFileColumns[i].columnEncloseChar();
            enclosed = true;
        }
    }
}

From source file:com.mijecu25.sqlplus.SQLPlus.java

/**
 * Create an SQLPlusConnection by taking the credentials from the user.
 *
 * @throws IOException if there is an I/O error while reading input from the user.
 * @throws SQLException if there is an error while establishing a connection.
 *///from  ww w . j a va 2s. c o  m
private static void createSQLPlusConnection() throws IOException, SQLException {
    if (false) {
        System.out.println("You will now enter the credentials to connect to your database");

        // Add credentials
        System.out.print(SQLPlus.PROMPT + "Host(default " + SQLPlusConnection.getDefaultHost() + "): ");
        String host = SQLPlus.console.readLine().trim();
        SQLPlus.logger.info("User entered host:" + host);
        // TODO validate host        

        //        if(!host.isEmpty()) {
        //            // The Console object for the JVM could not be found. Alert the user and throw a
        //            // NullPointerException that the caller will handle
        //            SQLPlus.logger.fatal(Messages.FATAL + "The user wants to use a host that is not supported");
        //            System.out.println(Messages.ERROR + SQLPlus.PROGRAM_NAME + " does not support the host that you entered");
        //            
        //            SQLPlus.logger.info("Throwing a " + IllegalArgumentException.class.getSimpleName() + " to the "
        //                    + "calling class");
        //            throw new IllegalArgumentException();  
        //        }

        System.out.print(SQLPlus.PROMPT + "Database(default " + SQLPlusConnection.getDefaultDatabase() + "): ");
        String database = SQLPlus.console.readLine().trim();
        SQLPlus.logger.info("User entered database:" + database);

        if (database.isEmpty()) {
            database = SQLPlusConnection.getDefaultDatabase();
            SQLPlus.logger.info("Using default database:" + database);
        }

        String port = "";

        // While the port is not numeric
        while (!StringUtils.isNumeric(port)) {
            System.out.print(SQLPlus.PROMPT + "Port (default " + SQLPlusConnection.getDefaultPort() + "): ");
            port = SQLPlus.console.readLine().trim();
            SQLPlus.logger.info("Port entered: " + port);
            SQLPlus.logger.info("Port string length: " + port.length());

            // If the port is empty
            if (port.isEmpty()) {
                // Assume that the user wants to use the default port. Continue to the next step
                break;
            }

            // If the port has more than 5 numbers or is not numberic 
            if (port.length() > 5 || !StringUtils.isNumeric(port)) {
                SQLPlus.logger.warn("The user provided an invalid port number: " + port);
                System.out.println(
                        Messages.WARNING + "You need to provided a valid port number " + "from 0 to 65535");

                // Set the port to the empty string to ask the user again
                port = "";
            }
        }
        SQLPlus.logger.info("User entered port:" + port);

        String username = "";

        // While the username is empty
        while (username.isEmpty()) {
            System.out.print(SQLPlus.PROMPT + "Username: ");
            username = SQLPlus.console.readLine().trim();

            // If the username is empty
            if (username.isEmpty()) {
                SQLPlus.logger.warn("The user did not provide a username");
                System.out.println(Messages.WARNING + "You cannot have an empty username");
            }
        }
        SQLPlus.logger.info("User entered username:" + username);

        // Reset the jline console since we are going to use the regular console to securely get the password
        SQLPlus.resetConsole();

        // Get the console for safe password entry
        Console javaConsole = System.console();

        // If the console is null
        if (javaConsole == null) {
            // The Console object for the JVM could not be found. Alert the user and throw a
            // NullPointerException that the caller will handle
            SQLPlus.logger.fatal("A JVM Console object to enter a password was not found");
            System.out.println(
                    Messages.ERROR + SQLPlus.PROGRAM_NAME + " was not able to find your JVM's Console object. "
                            + "Try running " + SQLPlus.PROGRAM_NAME + " from the command line.");

            SQLPlus.logger.info(
                    "Throwing a " + NullPointerException.class.getSimpleName() + " to the " + "calling class");
            throw new NullPointerException();
        }

        // Read the password without echoing the result
        char[] password = javaConsole.readPassword("%s", SQLPlus.PROMPT + "Password:");

        // If the password is null
        if (password == null) {
            // The Console object for the JVM could not be found. Alert the user and throw a
            // NullPointerException that the caller will handle
            SQLPlus.logger.fatal("The password captured by the JVM Console object returned null");
            System.out.println(
                    Messages.ERROR + SQLPlus.PROGRAM_NAME + " was not able to get the password you entered from"
                            + "your JVM's Console object. Try running " + SQLPlus.PROGRAM_NAME
                            + " from the command line or a different" + "terminal program");

            SQLPlus.logger.info(
                    "Throwing a " + NullPointerException.class.getSimpleName() + " to the " + "calling class");
            throw new NullPointerException();
        }
        SQLPlus.logger.info("User entered some password");
        System.out.println();

        // Create a connection based on the database system
        switch (database) {
        case SQLPlusMySQLConnection.MYSQL:
            // If the default port and host are used
            if (port.isEmpty() && host.isEmpty()) {
                SQLPlus.logger.info("Connection with username, password");
                sqlPlusConnection = SQLPlusMySQLConnection.getConnection(username, password);
            }
            // If the default port is used
            else if (port.isEmpty()) {
                SQLPlus.logger.info("Connection with username, password, and host");
                sqlPlusConnection = SQLPlusMySQLConnection.getConnection(username, password, host);
            }
            // All the values were provided by the user
            else {
                SQLPlus.logger.info("Connection with all credentials");
                sqlPlusConnection = SQLPlusMySQLConnection.getConnection(username, password, host, port);
            }
            break;
        default:
            // Database entered is not supported
            SQLPlus.logger.fatal(Messages.FATAL + "The database system " + database + " is not supported");
            System.out.println(
                    Messages.ERROR + SQLPlus.PROGRAM_NAME + " does not support the database that you entered");

            SQLPlus.logger.info("Throwing a " + IllegalArgumentException.class.getSimpleName() + " to the "
                    + "calling class");
            throw new IllegalArgumentException();
        }

        // Delete any traces of password in memory by filling the password array with with random characters
        // to minimize the lifetime of sensitive data in memory. Then call the garbage collections
        java.util.Arrays.fill(password, Character.MIN_VALUE);
        System.gc();

        // Recreate the jline console
        SQLPlus.console = new ConsoleReader();
        SQLPlus.console.setHandleUserInterrupt(true);
    }

    // TODO remove this which is for testing
    SQLPlus.logger.info("Connection with username, password, and host");
    SQLPlusConnection sqlPlusConnection = SQLPlusMySQLConnection.getConnection("sqlplus", new char[0],
            SQLPlusConnection.getDefaultHost());

    // TODO this does have to be in the final code
    SQLPlus.logger.info("Created and returning a SQLPlusConnection " + sqlPlusConnection);
    SQLPlus.sqlPlusConnection = sqlPlusConnection;
}

From source file:com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.java

protected boolean isInRange(Number value, String stringValue, Class toType) {
    Number bigValue = null;//from ww  w  .  jav  a  2s  . co m
    Number lowerBound = null;
    Number upperBound = null;

    try {
        if (double.class == toType || Double.class == toType) {
            bigValue = new BigDecimal(stringValue);
            // Double.MIN_VALUE is the smallest positive non-zero number
            lowerBound = BigDecimal.valueOf(Double.MAX_VALUE).negate();
            upperBound = BigDecimal.valueOf(Double.MAX_VALUE);
        } else if (float.class == toType || Float.class == toType) {
            bigValue = new BigDecimal(stringValue);
            // Float.MIN_VALUE is the smallest positive non-zero number
            lowerBound = BigDecimal.valueOf(Float.MAX_VALUE).negate();
            upperBound = BigDecimal.valueOf(Float.MAX_VALUE);
        } else if (byte.class == toType || Byte.class == toType) {
            bigValue = new BigInteger(stringValue);
            lowerBound = BigInteger.valueOf(Byte.MIN_VALUE);
            upperBound = BigInteger.valueOf(Byte.MAX_VALUE);
        } else if (char.class == toType || Character.class == toType) {
            bigValue = new BigInteger(stringValue);
            lowerBound = BigInteger.valueOf(Character.MIN_VALUE);
            upperBound = BigInteger.valueOf(Character.MAX_VALUE);
        } else if (short.class == toType || Short.class == toType) {
            bigValue = new BigInteger(stringValue);
            lowerBound = BigInteger.valueOf(Short.MIN_VALUE);
            upperBound = BigInteger.valueOf(Short.MAX_VALUE);
        } else if (int.class == toType || Integer.class == toType) {
            bigValue = new BigInteger(stringValue);
            lowerBound = BigInteger.valueOf(Integer.MIN_VALUE);
            upperBound = BigInteger.valueOf(Integer.MAX_VALUE);
        } else if (long.class == toType || Long.class == toType) {
            bigValue = new BigInteger(stringValue);
            lowerBound = BigInteger.valueOf(Long.MIN_VALUE);
            upperBound = BigInteger.valueOf(Long.MAX_VALUE);
        }
    } catch (NumberFormatException e) {
        //shoult it fail here? BigInteger doesnt seem to be so nice parsing numbers as NumberFormat
        return true;
    }

    return ((Comparable) bigValue).compareTo(lowerBound) >= 0
            && ((Comparable) bigValue).compareTo(upperBound) <= 0;
}