de.jstacs.parameters.validation
Class ReferenceConstraint

java.lang.Object
  extended by de.jstacs.parameters.validation.ReferenceConstraint
All Implemented Interfaces:
Constraint, Storable, Cloneable
Direct Known Subclasses:
SimpleReferenceConstraint

public abstract class ReferenceConstraint
extends Object
implements Constraint

Class for a Constraint that defines a condition on one Parameter (the one containing the ConstraintValidator) with respect to another Parameter.

Author:
Jan Grau

Field Summary
protected  Parameter constraintParameter
          The reference to the Parameter that is part of the condition.
protected  String errorMessage
          The message of the last error or null.
 
Fields inherited from interface de.jstacs.parameters.validation.Constraint
EQUALS, GEQ, GT, LEQ, LT
 
Constructor Summary
ReferenceConstraint(Parameter constraintParameter)
          Creates a new ReferenceConstraint with respect to the Parameter constraintParameter.
ReferenceConstraint(StringBuffer representation)
          The standard constructor for the interface Storable.
 
Method Summary
abstract  boolean check(Object value)
          Checks value for the constraint defined in the Constraint.
abstract  ReferenceConstraint clone()
          This method returns a deep copy of the current instance.
protected  void fillWithStandardFieldForClone(ReferenceConstraint clone)
          Sets the standard fields of clone to the values (or clones of them) of this instance.
 void fromXML(StringBuffer representation)
          Parses a ReferenceConstraint 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.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

constraintParameter

protected Parameter constraintParameter
The reference to the Parameter that is part of the condition.


errorMessage

protected String errorMessage
The message of the last error or null.

Constructor Detail

ReferenceConstraint

public ReferenceConstraint(Parameter constraintParameter)
Creates a new ReferenceConstraint with respect to the Parameter constraintParameter.

Parameters:
constraintParameter - the parameter

ReferenceConstraint

public ReferenceConstraint(StringBuffer representation)
                    throws NonParsableException
The standard constructor for the interface Storable. Creates a new ReferenceConstraint from its XML representation.

Parameters:
representation - the XML representation
Throws:
NonParsableException - if representation could not be parsed
Method Detail

clone

public abstract ReferenceConstraint clone()
                                   throws CloneNotSupportedException
Description copied from interface: Constraint
This method returns a deep copy of the current instance.

Specified by:
clone in interface Constraint
Overrides:
clone in class Object
Returns:
a deep copy of the current instance
Throws:
CloneNotSupportedException - if the Constraint could not be cloned
See Also:
Cloneable

fillWithStandardFieldForClone

protected void fillWithStandardFieldForClone(ReferenceConstraint clone)
                                      throws CloneNotSupportedException
Sets the standard fields of clone to the values (or clones of them) of this instance.

Parameters:
clone - the clone
Throws:
CloneNotSupportedException - if the contained Parameter could not be cloned

check

public abstract boolean check(Object value)
Description copied from interface: Constraint
Checks value for the constraint defined in the Constraint. If the constraint is fulfilled, true is returned.

Specified by:
check in interface Constraint
Parameters:
value - the Object to be checked
Returns:
true if the constraint is fulfilled, false otherwise

getErrorMessage

public String getErrorMessage()
Description copied from interface: Constraint
Returns the message of the last error (missed constraint) or null if the constraint was fulfilled by the last checked value.

Specified by:
getErrorMessage in interface Constraint
Returns:
the message of the last error or null

toXML

public StringBuffer toXML()
Description copied from interface: Storable
This method returns an XML representation as StringBuffer of an instance of the implementing class.

Specified by:
toXML in interface Storable
Returns:
the XML representation

fromXML

public void fromXML(StringBuffer representation)
             throws NonParsableException
Parses a ReferenceConstraint from the XML representation as returned by toXML().

Parameters:
representation - the XML representation
Throws:
NonParsableException - if the XML code could not be parsed