当前位置: 首页>>代码示例>>Java>>正文


Java GenericValidator.isInt方法代码示例

本文整理汇总了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));
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:26,代码来源:ParameterValueValidator.java

示例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() });
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:26,代码来源:IntegerParameterValidator.java

示例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);
    }

}
 
开发者ID:nicolasbaer,项目名称:flume-ng-elasticsearch-serializer-num,代码行数:23,代码来源:ContentBuilderUtil.java

示例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;
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:10,代码来源:ExternalParameterValidation.java

示例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);
}
 
开发者ID:unsftn,项目名称:bisis-v4,代码行数:5,代码来源:Validator.java

示例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);
}
 
开发者ID:unsftn,项目名称:bisis-v4,代码行数:5,代码来源:Validator.java

示例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;
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:20,代码来源:BLValidator.java

示例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;
    }
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:13,代码来源:EctValidation.java

示例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);
    }
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:18,代码来源:ValidateUtil.java

示例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;
    }
 
开发者ID:oscarservice,项目名称:oscar-old,代码行数:14,代码来源:EctValidation.java

示例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);
}
 
开发者ID:unsftn,项目名称:bisis-v4,代码行数:13,代码来源:Validator.java


注:本文中的org.apache.commons.validator.GenericValidator.isInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。