public class StringConstraint extends RequiredIfConstraint
The Constraint
class represents a single data constraint,
including the data type, allowed values, and required ranges.
Modifier and Type | Field and Description |
---|---|
protected static org.apache.log4j.Logger |
LOG |
protected java.lang.Double |
maxLength
Max length of the String
|
protected java.lang.Double |
minLength
Min length of the string
|
protected java.lang.String |
regEx
String must match this regular expression
|
Constructor and Description |
---|
StringConstraint(java.lang.String identifierIn)
This will create a new
Constraints with the specified
identifier as the "name". |
Modifier and Type | Method and Description |
---|---|
ValidatorError |
checkConstraint(java.lang.Object value)
Check the field against this Constraint to see
if it is in a valid state.
|
java.lang.Double |
getMaxLength() |
java.lang.Double |
getMinLength() |
java.lang.String |
getRegEx()
Returns the regular expression
|
boolean |
hasMaxLength()
This will return
true if a maximum length constraint
exists. |
boolean |
hasMinLength()
This will return
true if a minimum length constraint
exists. |
boolean |
hasRegEx() |
void |
setMaxLength(java.lang.Double maxLengthIn)
Set the max length of the Constraint
|
void |
setMinLength(java.lang.Double minLengthIn)
Set the minimum length of the Constraint
|
void |
setRegEx(java.lang.String regExIn)
Sets the regular expression for the Constraint.
|
addField, isRequired
getASCII, getDataType, getIdentifier, getOptional, getPosix, getUserName, isPosix, isValidUserName, setASCII, setDataType, setOptional, setPosix, setUserName, toString
protected static final org.apache.log4j.Logger LOG
protected java.lang.Double minLength
protected java.lang.Double maxLength
protected java.lang.String regEx
public StringConstraint(java.lang.String identifierIn)
This will create a new Constraints
with the specified
identifier as the "name".
identifierIn
- String
identifier for Constraint
.public ValidatorError checkConstraint(java.lang.Object value)
checkConstraint
in interface Constraint
checkConstraint
in class ParsedConstraint
value
- the value to checkpublic void setMaxLength(java.lang.Double maxLengthIn)
maxLengthIn
- The maxLength to set.public java.lang.Double getMaxLength()
public boolean hasMaxLength()
This will return true
if a maximum length constraint
exists.
boolean
- whether there is a constraint for the
maximum legnth (inclusive)public void setMinLength(java.lang.Double minLengthIn)
minLengthIn
- The minLength to set.public java.lang.Double getMinLength()
public boolean hasMinLength()
This will return true
if a minimum length constraint
exists.
boolean
- whether there is a constraint for the
minimum legnth (inclusive)public void setRegEx(java.lang.String regExIn)
regExIn
- Java Reg Ex to validate the field againstpublic java.lang.String getRegEx()
public boolean hasRegEx()