public class ConstraintValidator extends Object implements ParameterValidator
ParameterValidator
that is based on Constraint
s.
Each instance of a ConstraintValidator
may contain a set of
constraints that are all fulfilled, if checkValue(Object)
returns
true
.Constructor and Description |
---|
ConstraintValidator()
Creates a new
ConstraintValidator having an empty list of
Constraint s, i.e. |
ConstraintValidator(StringBuffer representation)
The standard constructor for the interface
Storable . |
Modifier and Type | Method and Description |
---|---|
void |
addConstraint(Constraint c)
Adds an additional
Constraint to the list of Constraint s. |
boolean |
checkValue(Object value)
Returns
true if the value is valid and false
otherwise. |
ConstraintValidator |
clone()
This method returns a deep copy of the current instance.
|
void |
fromXML(StringBuffer representation)
Parses a
ConstraintValidator from the XML representation as
returned by toXML() . |
String |
getErrorMessage()
Returns the error message if
ParameterValidator.checkValue(Object) returned false. |
StringBuffer |
toXML()
This method returns an XML representation as
StringBuffer of an
instance of the implementing class. |
public ConstraintValidator()
ConstraintValidator
having an empty list of
Constraint
s, i.e. the constraints of this
ConstraintValidator
are always fulfilled before additional
Constraint
s are added using addConstraint(Constraint)
.public ConstraintValidator(StringBuffer representation) throws NonParsableException
Storable
.
Creates a new ConstraintValidator
from its XML representation.representation
- the XML representation as StringBuffer
NonParsableException
- if representation
could not be parsedpublic ConstraintValidator clone() throws CloneNotSupportedException
ParameterValidator
clone
in interface ParameterValidator
clone
in class Object
CloneNotSupportedException
- if the ParameterValidator
could not be clonedCloneable
public void addConstraint(Constraint c)
Constraint
to the list of Constraint
s.c
- the Constraint
to be addedpublic boolean checkValue(Object value)
ParameterValidator
true
if the value is valid and false
otherwise.checkValue
in interface ParameterValidator
value
- the Object
to be checkedvalue
is validpublic String getErrorMessage()
ParameterValidator
ParameterValidator.checkValue(Object)
returned false.getErrorMessage
in interface ParameterValidator
public StringBuffer toXML()
Storable
StringBuffer
of an
instance of the implementing class.public void fromXML(StringBuffer representation) throws NonParsableException
ConstraintValidator
from the XML representation as
returned by toXML()
.representation
- the XML representationNonParsableException
- if the XML code could not be parsed