|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.locomotive.util.StringConstraint
This is a general, powerful way to constrain String values and generate errors on specific criteria. Here's an example of usage:
String username = (String) hd.form_hash.get("USERNAME"); StringConstraint sc = new StringConstraint("USERNAME", "DEFINED TIDY NO_WHITESPACE ISALPHANUM " + "LENGTH_GREATERTHAN=1 MAXSIZE=" + MAX_USERNAME_LENGTH + " WARNTRUNC"); StringBuffer errors = new StringBuffer(); // this will append some error messages to errors, and also return a // new String which is a cleaned-up verison of the username. username = sc.check(username, errors);The constraints are performed or evaluated in order. Here are all the valid constraints, all specified as words within the String that is the second argument in the constructor:
Constraints which result in errors:
(YY-MM-DD) (YY-MM-DD HH:MM:SS) (YYYY-MM-DD) (YYYY-MM-DD HH:MM:SS)
Constraints which modify the input string:
Constructor Summary | |
StringConstraint(java.lang.String name,
java.lang.String cons_list_string)
Deprecated. See the documentation at the top of this class for an example. |
Method Summary | |
void |
add(java.lang.String newconstraint)
Deprecated. add a new constraint. |
java.lang.String |
check(java.lang.String stocheck,
java.lang.StringBuffer error_sb)
Deprecated. Check a string with the present set of constraints. |
static java.lang.String |
checkHashWithConstraints(java.util.Hashtable check_hash,
java.util.Hashtable constraints_hash)
Deprecated. check all the values of a hash table against a hashtable containing a list of constraints. |
java.lang.String |
getProperName()
Deprecated. |
void |
overrideMessage(java.lang.String constraint,
java.lang.String msg)
Deprecated. Use the specified message instead of the default. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public StringConstraint(java.lang.String name, java.lang.String cons_list_string)
name
- the name of this field, to be used in an error message.cons_list_string
- a string containing all the constraints.Method Detail |
public void overrideMessage(java.lang.String constraint, java.lang.String msg)
public void add(java.lang.String newconstraint)
public static java.lang.String checkHashWithConstraints(java.util.Hashtable check_hash, java.util.Hashtable constraints_hash)
check_hash
- the hastable to checkconstraints_hash
- a hastable containing StringConstraints,
whose keys are the names of the keys in check_hash.public java.lang.String check(java.lang.String stocheck, java.lang.StringBuffer error_sb)
public java.lang.String getProperName()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |