|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ls.util.validation.Validator
This class is for testing of regular expressions. It uses the "gnu.regexp" library.
Constructor Summary | |
Validator()
Creates a new Validator object. |
Method Summary | |
void |
addRule(String ruleCode,
ValidatorRuleSet ruleSet)
The following function group adds a rule to the know rule sets. |
protected void |
criteriaFromVector(Vector criteria)
Turns a vector of hashtables into criteria / regex pairs stored in the private member criteria. |
boolean |
isValid(String value,
String ruleCode)
Function to check a value (from the user input side) against the rule set for a rule code. |
boolean |
isValid(String value,
String subject,
String fieldName)
Function to check a value (from the user input side) against the rule set for a combination of subject and field name. |
boolean |
isValid(String value,
String subject,
String action,
String fieldName)
Function to check a value (from the user input side) against the rule set for a combination of subject, action and field name. |
String |
makeRuleCode(String subject,
String action,
String fieldName)
Generates a rule code for a certain subject, action and field. |
protected boolean |
mandatoryFulfilled(String value)
Returns if a value contains at least something, i.e. a mandatory field would be checked for presence. |
boolean |
matchesCriteria(String value,
String typecode)
Checks if a string matches a typecode's regular expression. |
void |
setCriteria(Vector criteria)
Sets the validation criteria from the instantiating class. |
void |
setRules(String subject,
String action,
Hashtable defaults,
Vector fields)
Sets the rules to apply to fields posted with a certain subject and action. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Validator()
Method Detail |
public void setCriteria(Vector criteria) throws gnu.regexp.REException
criteria
- Criteria vector of hashtables.gnu.regexp.REException
- If something went wrong.protected void criteriaFromVector(Vector criteria) throws gnu.regexp.REException
criteria
- Vector of hashtables, each containing a "typecode" and a "regex" String element.gnu.regexp.REException
- If something went wrong.public boolean matchesCriteria(String value, String typecode) throws IllegalArgumentException
value
- Value to check against the regular expression of the criteriatypecode
- String with the name of the criteriaIllegalArgumentException
- If argumant is not correct.public boolean isValid(String value, String ruleCode)
value
- The user input to check.ruleCode
- The rule code that identifies the rule to use for the check.public boolean isValid(String value, String subject, String action, String fieldName)
value
- The user input to check.subject
- The message's subject.action
- The message's action, or empty string.fieldName
- The input field to check.public boolean isValid(String value, String subject, String fieldName)
value
- The user input to check.subject
- The message's subject.fieldName
- The input field to check.public String makeRuleCode(String subject, String action, String fieldName)
subject
- Subject of the incoming message.action
- Action of the incoming message.fieldName
- Input field to check.protected boolean mandatoryFulfilled(String value)
value
- The value to check.public void addRule(String ruleCode, ValidatorRuleSet ruleSet)
ruleCode
- Rule code generated by makeRuleCode(),
i.e. parse_template.insert_item.emailruleSet
- The set of rulespublic void setRules(String subject, String action, Hashtable defaults, Vector fields)
subject
- Subject of posted message.action
- Action of posted message, if any.defaults
- Hashtable with default rules to use.fields
- Vector with the field rules, one per field.
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |