IntegerGreaterThanConstraintpublic class IntegerGreaterThanConstraint extends ConstraintUtils implements ConstraintIntegerGreaterThanConstraint is a {@link Constraint} to validate numbers
between the given value and Integer.MAX_VALUE.
It implements Constraint interface and extends
{@link ConstraintUtils} class.
match method of this object returns empty
Collection if the value being validated is a number between
the given value and Integer.MAX_VALUE; else it returns a
Collection with a {@link ConstraintFailure} object in it.
ConstraintUtils class provides utility methods for formating
failure messages and a print method to print this object. |
Fields Summary |
---|
private int | valueA value represented by this Constraint . |
Constructors Summary |
---|
public IntegerGreaterThanConstraint()Creates a new instance of IntegerGreaterThanConstraint .
value = -1;
| public IntegerGreaterThanConstraint(String inputValue)Creates a new instance of IntegerGreaterThanConstraint .
try {
this.value = Integer.parseInt(inputValue);
} catch(NumberFormatException e) {
String format =
BundleReader.getValue("Error_failed_to_create"); //NOI18N
Object[] arguments =
new Object[]{"IntegerGreaterThanConstraint"}; //NOI18N
System.out.println(MessageFormat.format(format, arguments));
}
|
Methods Summary |
---|
private void | addFailure(java.util.Collection failed_constrained_list, java.lang.String name, java.lang.String inputValue)
String failureMessage = formatFailureMessage(toString(),
inputValue, name);
String format = BundleReader.getValue(
"MSG_IntegerGreaterThanConstraint_Failure"); //NOI18N
Object[] arguments =
new Object[]{String.valueOf(value)};
String genericFailureMessage = MessageFormat.format(format, arguments);
failed_constrained_list.add(new ConstraintFailure(toString(),
inputValue, name, failureMessage, genericFailureMessage));
| public java.util.Collection | match(java.lang.String inputValue, java.lang.String name)Validates the given value against this Constraint .
ArrayList failed_constrained_list = new ArrayList();
if((inputValue != null) && (inputValue.length() != 0)){
try {
int intValue = Integer.parseInt(inputValue);
if((intValue <= value) || (intValue > Integer.MAX_VALUE)){
addFailure(failed_constrained_list, name, inputValue);
}
} catch(NumberFormatException e) {
addFailure(failed_constrained_list, name, inputValue);
}
}
return failed_constrained_list;
| public void | print()Prints this Constraint .
super.print();
String format = BundleReader.getValue("Name_Value_Pair_Format");//NOI18N
Object[] arguments =
new Object[]{"Value", String.valueOf(value)}; //NOI18N
System.out.println(MessageFormat.format(format, arguments));
| public void | setValue(java.lang.String value)Sets the value represented by this object.
try {
this.value = Integer.parseInt(value);
} catch(NumberFormatException e) {
String format =
BundleReader.getValue("Error_failed_to_set"); //NOI18N
Object[] arguments =
new Object[]{this.toString(), "Value"}; //NOI18N
System.out.println(MessageFormat.format(format, arguments));
}
| public void | setValue(java.lang.Integer value)Sets the value represented by this object.
this.value = value.intValue();
|
|