本文整理汇总了Java中org.apache.commons.validator.GenericValidator.isInt方法的典型用法代码示例。如果您正苦于以下问题:Java GenericValidator.isInt方法的具体用法?Java GenericValidator.isInt怎么用?Java GenericValidator.isInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.validator.GenericValidator
的用法示例。
在下文中一共展示了GenericValidator.isInt方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateInteger
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
* Validate integer value.
*
* @param context
* JSF context.
* @param uiComponent
* UI component.
* @param value
* Value for validation.
*/
private void validateInteger(FacesContext context, UIComponent uiComponent,
String value) {
if (!GenericValidator.isInt(value.toString())) {
Object[] args = null;
String label = JSFUtils.getLabel(uiComponent);
if (label != null) {
args = new Object[] { label };
}
ValidationException e = new ValidationException(
ValidationException.ReasonEnum.INTEGER, label, null);
String text = JSFUtils.getText(e.getMessageKey(), args, context);
throw new ValidatorException(new FacesMessage(
FacesMessage.SEVERITY_ERROR, text, null));
}
}
示例2: validate
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
@Override
public void validate(Object obj) throws ValidationException {
super.validate(obj);
VOParameter parameter = (VOParameter) obj;
VOParameterDefinition parameterDefinition = parameter
.getParameterDefinition();
if(isOptionalAndNullOrEmpty(parameter)) {
return;
}
if (!GenericValidator.isInt(parameter.getValue())) {
throw new ValidationException(
ValidationException.ReasonEnum.INTEGER, null,
new Object[] { parameter.getParameterDefinition()
.getParameterId() });
}
if (!isValid(parameter, parameterDefinition)) {
throw new ValidationException(
ValidationException.ReasonEnum.VALUE_NOT_IN_RANGE, null,
new Object[] { parameter.getParameterDefinition()
.getParameterId() });
}
}
示例3: addSimpleField
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
public static void addSimpleField(XContentBuilder builder, String fieldName,
byte[] data) throws IOException {
String dataString = new String(data, charset);
if(!fieldName.toLowerCase().contains("timestamp") && NumberUtils.isNumber(dataString)){
if (GenericValidator.isInt(dataString)) {
builder.field(fieldName, Integer.valueOf(dataString));
} else if (GenericValidator.isLong(dataString)) {
builder.field(fieldName, Long.valueOf(dataString));
} else if (GenericValidator.isDouble(dataString)) {
builder.field(fieldName, Double.valueOf(dataString));
} else if (GenericValidator.isFloat(dataString)) {
builder.field(fieldName, Float.valueOf(dataString));
} else {
builder.field(fieldName, dataString);
}
} else {
builder.field(fieldName, dataString);
}
}
示例4: integerIsValid
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
private static boolean integerIsValid(VOParameterDefinition parDefinition,
String parValue) {
if (GenericValidator.isInt(parValue.toString())) {
return LongValidator.isInRange(Integer.parseInt(parValue),
parDefinition.getMinValue(), parDefinition.getMaxValue());
} else {
return false;
}
}
示例5: validateIntOrBlank
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
public static boolean validateIntOrBlank(Object bean, Field field) {
String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return GenericValidator.isBlankOrNull(value) || GenericValidator.isInt(value);
}
示例6: validateIntOrNotEnabled
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
public static boolean validateIntOrNotEnabled(Object bean, Field field) {
String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return !validateEnabled(bean, field) || GenericValidator.isInt(value);
}
示例7: isInteger
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
* Validates that the given input string is a valid integer number.
*
* @param member
* The indicator of the field to be validated.
* @param inputValue
* The value to be validated.
* @throws ValidationException
* Thrown in case the value is not a valid integer.
*/
public static void isInteger(String member, String inputValue)
throws ValidationException {
if (!GenericValidator.isInt(inputValue)) {
ValidationException vf = new ValidationException(
ReasonEnum.INTEGER, member, new Object[] { inputValue });
logValidationFailure(vf);
throw vf;
}
}
示例8: isInteger
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
public boolean isInteger(String inputValue){
boolean validation = true;
if(!GenericValidator.isInt(inputValue)){
validation=false;
}
return validation;
}
示例9: intInRange
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
* 最小値、最大値チェック(int)
*
* @param value 入力チェック対象の値
* @param min 最小値
* @param max 最大値
* @param code 入力チェックエラー時のメッセージコード
* @param params 入力チェックエラー時のメッセージパラメータ
*/
public static void intInRange(String value, int min, int max, String code, Object[] params) {
if (GenericValidator.isInt(value) == false) {
throw new AutoApplicationException(code, params);
}
if (GenericValidator.isInRange(Integer.valueOf(value), min, max) == false) {
throw new AutoApplicationException(code, params);
}
}
示例10: isInteger
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
public boolean isInteger(String inputValue){
boolean validation = true;
org.apache.commons.validator.GenericValidator gValidator = new org.apache.commons.validator.GenericValidator();
if(!GenericValidator.isInt(inputValue)){
validation=false;
}
return validation;
}
示例11: validateInt
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
* Checks if the field can be successfully converted to a <code>int</code>.
*
* @param value The value validation is being performed on.
* @return boolean If the field can be successfully converted
* to a <code>int</code> <code>true</code> is returned.
* Otherwise <code>false</code>.
*/
public static boolean validateInt(Object bean, Field field) {
String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return GenericValidator.isInt(value);
}