本文整理汇总了Java中org.apache.commons.validator.GenericValidator.isLong方法的典型用法代码示例。如果您正苦于以下问题:Java GenericValidator.isLong方法的具体用法?Java GenericValidator.isLong怎么用?Java GenericValidator.isLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.validator.GenericValidator
的用法示例。
在下文中一共展示了GenericValidator.isLong方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
* Parses the specified string into a long integer.
*
* @param context
* FacesContext for the request we are processing
* @param component
* UIComponent we are checking for correctness
* @param value
* the value to parse
* @throws ValidatorException
* if the specified string could not be parsed into a valid long
* integer.
*/
public static long parse(FacesContext context, UIComponent uiComponent,
String value) throws ValidatorException {
if (!GenericValidator.isLong(value)) {
Object[] args = null;
String label = JSFUtils.getLabel(uiComponent);
if (label != null) {
args = new Object[] { label };
}
ValidationException e = new ValidationException(
ValidationException.ReasonEnum.LONG, label, null);
String message = JSFUtils.getText(e.getMessageKey(), args, context);
throw getException(message);
}
return Long.parseLong(value);
}
示例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.isLong(parameter.getValue())) {
throw new ValidationException(ValidationException.ReasonEnum.LONG,
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: parse
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
private static long parse(PlatformConfigurationKey key, String value,
Long minValue, Long maxValue) {
if (!GenericValidator.isLong(value)) {
minValue = (minValue != null ? minValue : Long
.valueOf(Long.MIN_VALUE));
maxValue = (maxValue != null ? maxValue : Long
.valueOf(Long.MAX_VALUE));
throw new RuntimeException(
"The value for"
+ key
+ " is illegal.Please enter a valid integer value within the range of "
+ minValue + " and " + maxValue + ".");
}
return Long.parseLong(value);
}
示例5: parse
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
private static long parse(ConfigurationKey key, String value,
Long minValue, Long maxValue) {
if (!GenericValidator.isLong(value)) {
minValue = (minValue != null ? minValue : Long
.valueOf(Long.MIN_VALUE));
maxValue = (maxValue != null ? maxValue : Long
.valueOf(Long.MAX_VALUE));
throw new RuntimeException(
"The value for "
+ key.getKeyName()
+ " is illegal.Please enter a valid integer value within the range of "
+ minValue + " and " + maxValue + ".");
}
return Long.parseLong(value);
}
示例6: longIsValid
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
private static boolean longIsValid(VOParameterDefinition parDefinition,
String parValue) {
if (GenericValidator.isLong(parValue.toString())) {
return LongValidator.isInRange(Long.parseLong(parValue),
parDefinition.getMinValue(), parDefinition.getMaxValue());
} else {
return false;
}
}
示例7: validateUserId
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
public static boolean validateUserId(Object bean, Field field) {
String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return GenericValidator.isLong(value) && value.length() == Cirkulacija.getApp().getEnvironment().getUseridLength();
}
示例8: isLong
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
* Validates that the given input string is a valid long 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 long.
*/
public static void isLong(String member, String inputValue)
throws ValidationException {
if (!GenericValidator.isLong(inputValue)) {
ValidationException vf = new ValidationException(ReasonEnum.LONG,
member, new Object[] { inputValue });
logValidationFailure(vf);
throw vf;
}
}
示例9: longInRange
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
* 最小値、最大値チェック(long)
*
* @param value 入力チェック対象の値
* @param min 最小値
* @param max 最大値
* @param code 入力チェックエラー時のメッセージコード
* @param params 入力チェックエラー時のメッセージパラメータ
*/
public static void longInRange(String value, long min, long max, String code, Object... params) {
if (GenericValidator.isLong(value) == false) {
throw new AutoApplicationException(code, params);
}
if (GenericValidator.isInRange(Long.parseLong(value), min, max) == false) {
throw new AutoApplicationException(code, params);
}
}