|
||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.tws.objects.validator.Validator
This class is the root of all validator classes, and provides common utility methods that can be invoked by subclasses to check the validity of allowed lengths, ranges and other rules on object fields.
Field Summary | |
---|---|
static java.lang.String |
COPYRIGHT
Copyright. |
Constructor Summary | |
---|---|
protected |
Validator(java.util.Locale locale)
Creates a new Validator, using the specified locale for error messages. |
Method Summary | |
---|---|
protected void |
checkAlphabetic(java.lang.String field,
java.lang.String value,
java.lang.String allowed)
Checks that the string specified for the given field includes only alphabetic characters. |
protected void |
checkAlphaNumeric(java.lang.String field,
java.lang.String value,
java.lang.String allowed)
Checks that the string specified for the given field includes only alphanumeric characters. |
protected void |
checkComparison(java.lang.String field1,
java.util.Date value1,
java.lang.String field2,
java.util.Date value2)
Checks that the date values specified for the given fields meet a comparison constraint. |
protected void |
checkComparison(java.lang.String field1,
int value1,
java.lang.String field2,
int value2)
Checks that the integer values specified for the given fields meet a comparison constraint. |
protected void |
checkComparison(java.lang.String field1,
long value1,
java.lang.String field2,
long value2)
Checks that the long integer values specified for the given fields meet a comparison constraint. |
protected void |
checkConstraint(java.util.List masterFields,
java.util.List masterValues,
java.util.List masterChecks,
java.util.List masterEquals,
java.lang.String slaveField,
java.lang.Object slaveValue,
java.lang.Object slaveCheck,
boolean slaveEquals)
Checks that the value of a "slave" field is compliant with the constraint defined by the value of one or more "master" fields. |
protected void |
checkConstraint(java.lang.String masterField,
java.lang.Object masterValue,
java.lang.Object masterCheck,
boolean masterEquals,
java.lang.String slaveField,
java.lang.Object slaveValue,
java.lang.Object slaveCheck,
boolean slaveEquals)
Checks that the value of a "slave" field is compliant with the constraint defined by the value of a "master" field. |
protected void |
checkFilter(QueryFilter filter,
java.lang.String name,
java.lang.Class type,
boolean isNullable)
Checks that the value specified for a query filter element is an instance of the expected class. |
protected void |
checkInstanceOf(java.lang.String field,
java.lang.Object value,
java.lang.Class type)
Checks that the object specified for the given field is an instance of the expected class. |
protected void |
checkInternetAddress(java.lang.String field,
java.lang.String value)
Checks that the string specified for the given field includes a valid internet address. |
protected void |
checkLength(java.lang.String field,
java.lang.String value,
int maxLength)
Checks that the string specified for the given field does not exceed the specified length. |
protected void |
checkListFilter(QueryFilter filter,
java.lang.String name,
java.lang.Class type,
boolean isNullable)
Checks that the values specified for a query filter element of type List are correct. |
protected void |
checkNotAllowedChars(java.lang.String field,
java.lang.String value,
java.lang.String notAllowed)
Checks that the string specified for the given field does not include not allowed characters. |
protected void |
checkNotAllowedStart(java.lang.String field,
java.lang.String value,
java.lang.String notAllowed)
Checks that the string specified for the given field does not start with a not allowed character. |
protected void |
checkNotNull(java.util.List fields,
java.util.List values)
Checks that at least one of the values specified for the given fields is not null. |
protected void |
checkNotNull(java.lang.String field,
int value)
Checks that the integer specified for the given field is not null. |
protected void |
checkNotNull(java.lang.String field,
long value)
Checks that the long integer specified for the given field is not null. |
protected void |
checkNotNull(java.lang.String field,
java.lang.Object value)
Checks that the value specified for the given field is not null. |
protected void |
checkNotNull(java.lang.String field,
java.lang.String value)
Checks that the text value specified for the given field is not null. |
protected void |
checkNumeric(java.lang.String field,
java.lang.String value,
java.lang.String allowed)
Checks that the string specified for the given field includes only numeric characters. |
protected void |
checkRange(java.lang.String field,
java.util.Date value,
java.util.Date start,
java.util.Date end)
Checks that the date specified for the given field is within the specified range. |
protected void |
checkRange(java.lang.String field,
int value,
int start,
int end)
Checks that the integer specified for the given field is within the specified range. |
protected void |
checkRange(java.lang.String field,
long value,
long start,
long end)
Checks that the long integer specified for the given field is within the specified range. |
protected void |
checkStartWithAlphabetic(java.lang.String field,
java.lang.String value,
java.lang.String allowed)
Checks that the string specified for the given field starts with an alphabetic character. |
protected void |
checkStartWithAlphaNumeric(java.lang.String field,
java.lang.String value,
java.lang.String allowed)
Checks that the string specified for the given field starts with an alphanumeric character. |
protected void |
checkStartWithNumeric(java.lang.String field,
java.lang.String value,
java.lang.String allowed)
Checks that the string specified for the given field starts with a numeric character. |
protected void |
checkValue(java.lang.String field,
int value,
int invalid)
Checks that the integer specified for the given field is not equal to the specified invalid value. |
protected void |
checkValue(java.lang.String field,
long value,
long invalid)
Checks that the long integer specified for the given field is not equal to the specified invalid value. |
protected void |
checkValue(java.lang.String field,
java.lang.Object value,
java.lang.Object invalid)
Checks that the object specified for the given field is not equal to the specified invalid value. |
protected int |
getLength(java.lang.String value)
Returns the length of the specified string. |
protected java.util.Locale |
getLocale()
Returns the locale used by this validator to generate error messages. |
protected java.lang.String |
getLocalizedField(java.lang.String field)
Returns the localized text to be shown for the specified field name. |
protected java.lang.String |
getLocalizedValue(java.lang.Object value)
Returns the localized text to be shown for the specified field value. |
java.lang.String |
getObjectName()
Returns the name of the object for which this validator is working. |
void |
setObjectName(java.lang.String value)
Sets the name of the object for which this validator is working. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String COPYRIGHT
Constructor Detail |
protected Validator(java.util.Locale locale)
locale
- The locale requested for error messages.Method Detail |
public java.lang.String getObjectName()
public void setObjectName(java.lang.String value)
value
- The name of the object for which this validator is working.protected void checkNotNull(java.lang.String field, java.lang.Object value) throws NullValidatorException
field
- The name of the field that is being checked.value
- The value specified for the given field.
NullValidatorException
- The specified value is null.protected void checkNotNull(java.lang.String field, java.lang.String value) throws NullValidatorException
field
- The name of the field that is being checked.value
- The value specified for the given field.
NullValidatorException
- The specified text value is null.protected void checkNotNull(java.lang.String field, int value) throws NullValidatorException
field
- The name of the field that is being checked.value
- The value specified for the given field.
NullValidatorException
- The specified integer is null.protected void checkNotNull(java.lang.String field, long value) throws NullValidatorException
field
- The name of the field that is being checked.value
- The value specified for the given field.
NullValidatorException
- The specified long integer is null.protected void checkNotNull(java.util.List fields, java.util.List values) throws NullValidatorException
fields
- A list of the names of the fields that cannot be null at the same time.values
- A list of the values of the fields that cannot be null at the same time.
NullValidatorException
- All the specified values are null.protected void checkInstanceOf(java.lang.String field, java.lang.Object value, java.lang.Class type) throws InstanceValidatorException
field
- The name of the field that is being checked.value
- The value specified for the given field.type
- The expected class for the given field.
InstanceValidatorException
- The specified object is not an instance of the expected class.protected void checkFilter(QueryFilter filter, java.lang.String name, java.lang.Class type, boolean isNullable) throws FilterValidatorException
filter
- The query filter including all filter elements.name
- The name of the filter element to be checked.type
- The expected class for the given filter element.isNullable
- True if null values are allowed in addition to objects of the given type.
FilterValidatorException
- The current value of the filter element is not allowed.protected void checkListFilter(QueryFilter filter, java.lang.String name, java.lang.Class type, boolean isNullable) throws FilterValidatorException
filter
- The query filter including all filter elements.name
- The name of the filter element of type List to be checked.type
- The expected class for every object in the list.isNullable
- True if null values are allowed in addition to objects of the given type.
FilterValidatorException
- The current value of the filter element is not allowed.protected int getLength(java.lang.String value)
value
- The string whose length must be calculated.
protected void checkLength(java.lang.String field, java.lang.String value, int maxLength) throws LengthValidatorException
field
- The name of the field that is being checked.value
- The value specified for the given field.maxLength
- The allowed maximum length for the given field.
LengthValidatorException
- The specified string exceeds the allowed maximum length.protected void checkAlphabetic(java.lang.String field, java.lang.String value, java.lang.String allowed) throws CharValidatorException
field
- The name of the field that is being checked.value
- The value specified for the given field.allowed
- A string including the characters allowed in addition to alphabetic ones, if any.
CharValidatorException
- An invalid character was found in the specified string.protected void checkNumeric(java.lang.String field, java.lang.String value, java.lang.String allowed) throws CharValidatorException
field
- The name of the field that is being checked.value
- The value specified for the given field.allowed
- A string including the characters allowed in addition to numeric ones, if any.
CharValidatorException
- An invalid character was found in the specified string.protected void checkAlphaNumeric(java.lang.String field, java.lang.String value, java.lang.String allowed) throws CharValidatorException
field
- The name of the field that is being checked.value
- The value specified for the given field.allowed
- A string including the characters allowed in addition to alphanumeric ones, if any.
CharValidatorException
- An invalid character was found in the specified string.protected void checkInternetAddress(java.lang.String field, java.lang.String value) throws AddressValidatorException
field
- The name of the field that is being checked.value
- The value specified for the given field.
AddressValidatorException
- An invalid internet address was found in the specified string.protected void checkNotAllowedChars(java.lang.String field, java.lang.String value, java.lang.String notAllowed) throws CharValidatorException
field
- The name of the field that is being checked.value
- The value specified for the given field.notAllowed
- A string including the characters that are not allowed for the given field.
CharValidatorException
- An invalid character was found in the specified string.protected void checkStartWithAlphabetic(java.lang.String field, java.lang.String value, java.lang.String allowed) throws StartValidatorException
field
- The name of the field that is being checked.value
- The value specified for the given field.allowed
- A string including the characters allowed in addition to alphabetic ones, if any.
StartValidatorException
- The specified string does not start as expected.protected void checkStartWithNumeric(java.lang.String field, java.lang.String value, java.lang.String allowed) throws StartValidatorException
field
- The name of the field that is being checked.value
- The value specified for the given field.allowed
- A string including the characters allowed in addition to numeric ones, if any.
StartValidatorException
- The specified string does not start as expected.protected void checkStartWithAlphaNumeric(java.lang.String field, java.lang.String value, java.lang.String allowed) throws StartValidatorException
field
- The name of the field that is being checked.value
- The value specified for the given field.allowed
- A string including the characters allowed in addition to alphanumeric ones, if any.
StartValidatorException
- The specified string does not start as expected.protected void checkNotAllowedStart(java.lang.String field, java.lang.String value, java.lang.String notAllowed) throws StartValidatorException
field
- The name of the field that is being checked.value
- The value specified for the given field.notAllowed
- A string including the characters thar are not allowed as a start of the given field.
StartValidatorException
- The specified string does not start as expected.protected void checkRange(java.lang.String field, int value, int start, int end) throws RangeValidatorException
field
- The name of the field that is being checked.value
- The value specified for the given field.start
- The lower bound of the range allowed for the given field.end
- The upper bound of the range allowed for the given field.
RangeValidatorException
- The specified integer is out of the allowed range.protected void checkRange(java.lang.String field, long value, long start, long end) throws RangeValidatorException
field
- The name of the field that is being checked.value
- The value specified for the given field.start
- The lower bound of the range allowed for the given field.end
- The upper bound of the range allowed for the given field.
RangeValidatorException
- The specified long integer is out of the allowed range.protected void checkRange(java.lang.String field, java.util.Date value, java.util.Date start, java.util.Date end) throws RangeValidatorException
field
- The name of the field that is being checked.value
- The value specified for the given field.start
- The lower bound of the range allowed for the given field.end
- The upper bound of the range allowed for the given field.
RangeValidatorException
- The specified date is out of the allowed range.protected void checkValue(java.lang.String field, int value, int invalid) throws ValueValidatorException
field
- The name of the field that is being checked.value
- The value specified for the given field.invalid
- An invalid value for the given field.
ValueValidatorException
- The specified integer is equal to the invalid value.protected void checkValue(java.lang.String field, long value, long invalid) throws ValueValidatorException
field
- The name of the field that is being checked.value
- The value specified for the given field.invalid
- An invalid value for the given field.
ValueValidatorException
- The specified long integer is equal to the invalid value.protected void checkValue(java.lang.String field, java.lang.Object value, java.lang.Object invalid) throws ValueValidatorException
field
- The name of the field that is being checked.value
- The value specified for the given field.invalid
- An invalid value for the given field.
ValueValidatorException
- The specified object is equal to the invalid value.protected void checkComparison(java.lang.String field1, int value1, java.lang.String field2, int value2) throws ComparisonValidatorException
field1
- The name of the first field (the one that must be greater).value1
- The value of the first field.field2
- The name of the second field (the one that must be lower).value2
- The value of the second field.
ComparisonValidatorException
- The value of the first field is lower than the value of the second field.protected void checkComparison(java.lang.String field1, long value1, java.lang.String field2, long value2) throws ComparisonValidatorException
field1
- The name of the first field (the one that must be greater).value1
- The value of the first field.field2
- The name of the second field (the one that must be lower).value2
- The value of the second field.
ComparisonValidatorException
- The value of the first field is lower than the value of the second field.protected void checkComparison(java.lang.String field1, java.util.Date value1, java.lang.String field2, java.util.Date value2) throws ComparisonValidatorException
field1
- The name of the first field (the one that must be greater).value1
- The value of the first field.field2
- The name of the second field (the one that must be lower).value2
- The value of the second field.
ComparisonValidatorException
- The value of the first field is lower than the value of the second field.protected void checkConstraint(java.lang.String masterField, java.lang.Object masterValue, java.lang.Object masterCheck, boolean masterEquals, java.lang.String slaveField, java.lang.Object slaveValue, java.lang.Object slaveCheck, boolean slaveEquals) throws ConstraintValidatorException
masterField
- The name of the field that defines the constraint.masterValue
- The current value of the field that defines the constraint.masterCheck
- The value of the master field that constrains the value of the slave field.masterEquals
- True (false) if the constraint is triggered when masterValue is equal to (different than) masterCheck.slaveField
- The name of the field that must comply with the constraint.slaveValue
- The current value of the field that must comply with the constraint.slaveCheck
- A value of the slave field to be compared with the current one.slaveEquals
- True (false) if slaveValue must be equal to (different than) slaveCheck if the constraint is triggered.
ConstraintValidatorException
- The constraint is violated by the current value of the slave field.protected void checkConstraint(java.util.List masterFields, java.util.List masterValues, java.util.List masterChecks, java.util.List masterEquals, java.lang.String slaveField, java.lang.Object slaveValue, java.lang.Object slaveCheck, boolean slaveEquals) throws ConstraintValidatorException
masterFields
- A list of the names of all the fields that define the constraint.masterValues
- A list of the current values of all the fields that define the constraint.masterChecks
- A list of the values of the master fields that constrain the value of the slave field.masterEquals
- True (false) if the constraint is triggered when masterValue is equal to (different than) masterCheck.slaveField
- The name of the field that must comply with the constraint.slaveValue
- The current value of the field that must comply with the constraint.slaveCheck
- A value of the slave field to be compared with the current one.slaveEquals
- True (false) if slaveValue must be equal to (different than) slaveCheck if the constraint is triggered.
ConstraintValidatorException
- The constraint is violated by the current value of the slave field.protected java.util.Locale getLocale()
protected java.lang.String getLocalizedField(java.lang.String field)
field
- The non-localized field name.
protected java.lang.String getLocalizedValue(java.lang.Object value)
value
- The non-localized field value.
|
||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |