Java Code Examples for org.apache.commons.validator.GenericValidator#isFloat()

The following examples show how to use org.apache.commons.validator.GenericValidator#isFloat() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataSetsSDKServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
private void checkParameterValues(String[] values, DataSetParameterItem dataSetParameterItem) throws InvalidParameterValue {
	logger.debug("IN");
	try {
		String parameterType = dataSetParameterItem.getType();
		if (parameterType.equalsIgnoreCase("Number")) {
			for (int i = 0; i < values.length; i++) {
				String value = values[i];
				if (GenericValidator.isBlankOrNull(value)
						|| (!(GenericValidator.isInt(value) || GenericValidator.isFloat(value) || GenericValidator.isDouble(value)
								|| GenericValidator.isShort(value) || GenericValidator.isLong(value)))) {
					InvalidParameterValue error = new InvalidParameterValue();
					error.setParameterName(dataSetParameterItem.getName());
					error.setParameterType(parameterType);
					error.setWrongParameterValue(value);
					error.setParameterFormat("");
					throw error;
				}
			}
		}
	} finally {
		logger.debug("OUT");
	}
}
 
Example 2
Source File: QueryDetail.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
private void validateNumber(String value) {
	if (!(GenericValidator.isInt(value) || GenericValidator.isFloat(value) || GenericValidator.isDouble(value) || GenericValidator.isShort(value)
			|| GenericValidator.isLong(value))) {
		throw new SecurityException("Input value " + value + " is not a valid number");
	}
}