Example usage for org.apache.commons.validator.routines IntegerValidator isValid

List of usage examples for org.apache.commons.validator.routines IntegerValidator isValid

Introduction

In this page you can find the example usage for org.apache.commons.validator.routines IntegerValidator isValid.

Prototype

public boolean isValid(String value) 

Source Link

Document

Validate using the default Locale.

Usage

From source file:com.btobits.automator.ant.sql.task.SQLCompareTask.java

private int getColumnType(final SQLCompareTask.VerifyCell inRowPos) throws Exception {
    final IntegerValidator validator = new IntegerValidator();
    if (validator.isValid(inRowPos.getField())) {
        Integer id = validator.validate(inRowPos.getField());
        return resultSet.getMetaData().getColumnType(id);
    } else {//from   ww w. j ava2s  .  c  om
        for (int i = 0; i < resultSet.getMetaData().getColumnCount(); i++) {
            final String nameColumn = resultSet.getMetaData().getColumnName(i + 1);
            if (StringUtils.equalsIgnoreCase(nameColumn, inRowPos.getField())) {
                return resultSet.getMetaData().getColumnType(i + 1);
            }
        }
    }
    throw new Exception("Unknown field name [" + inRowPos.getField() + "].");
}