public class SimpleStaticConstraint extends Object implements Constraint
Constraint that checks values against static values using
the comparison operators defined in the interface Constraint. As long
as just an upper and lower bound shall be checked, NumberValidator
has the same functionality and is easier to use. Thus it is recommended to
use this class for more complex constraints, e.g. multiple allowed ranges or
combinations of static and reference-based constraints.NumberValidator| Constructor and Description |
|---|
SimpleStaticConstraint(Number reference,
int comparisonOperator)
Creates a new
SimpleStaticConstraint from a Number
-reference and a comparison operator as defined in Constraint. |
SimpleStaticConstraint(StringBuffer representation)
The standard constructor for the interface
Storable. |
SimpleStaticConstraint(String reference,
int comparisonOperator)
Creates a new
SimpleStaticConstraint from a String
-reference and a comparison operator as defined in Constraint. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
check(Object value)
Checks
value for the constraint defined in the
Constraint. |
SimpleStaticConstraint |
clone()
This method returns a deep copy of the current instance.
|
void |
fromXML(StringBuffer representation)
Parses a
SimpleStaticConstraint from the XML representation as
returned by toXML(). |
String |
getErrorMessage()
Returns the message of the last error (missed constraint) or
null if the constraint was fulfilled by the last checked
value. |
StringBuffer |
toXML()
This method returns an XML representation as
StringBuffer of an
instance of the implementing class. |
public SimpleStaticConstraint(Number reference, int comparisonOperator)
SimpleStaticConstraint from a Number
-reference and a comparison operator as defined in Constraint.reference - the Number-referencecomparisonOperator - the comparison operatorpublic SimpleStaticConstraint(String reference, int comparisonOperator)
SimpleStaticConstraint from a String
-reference and a comparison operator as defined in Constraint.reference - the String-referencecomparisonOperator - the comparison operatorpublic SimpleStaticConstraint(StringBuffer representation) throws NonParsableException
Storable.
Creates a new SimpleStaticConstraint from its XML representation.representation - the XML representation as StringBufferNonParsableException - if representation could not be parsedpublic SimpleStaticConstraint clone() throws CloneNotSupportedException
Constraintclone in interface Constraintclone in class ObjectCloneNotSupportedException - if the Constraint could not be clonedCloneablepublic boolean check(Object value)
Constraintvalue for the constraint defined in the
Constraint. If the constraint is fulfilled, true is
returned.check in interface Constraintvalue - the Object to be checkedtrue if the constraint is fulfilled,
false otherwisepublic StringBuffer toXML()
StorableStringBuffer of an
instance of the implementing class.public void fromXML(StringBuffer representation) throws NonParsableException
SimpleStaticConstraint from the XML representation as
returned by toXML().representation - the XML representationNonParsableException - the XML code could not be parsedpublic String getErrorMessage()
Constraintnull if the constraint was fulfilled by the last checked
value.getErrorMessage in interface Constraintnull