Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.jstacs.parameters.validation
Class ConstraintValidator

    java.lang.Object
      de.jstacs.parameters.validation.ConstraintValidator

All Implemented Interfaces:
  ParameterValidator, Storable, Cloneable

    public class ConstraintValidator

extends Object
implements ParameterValidator

Class for a `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`.

Author:
  Jan Grau

Constructor Summary
`ConstraintValidator()` Creates a new `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)`.
`ConstraintValidator(StringBuffer representation)` The standard constructor for the interface `Storable`.

Method Summary
`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.

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ConstraintValidator

    public ConstraintValidator()

  Creates a new `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)`.

### ConstraintValidator

    public ConstraintValidator(StringBuffer representation)
                        throws NonParsableException

  The standard constructor for the interface `Storable`. Creates a new `ConstraintValidator` from its XML representation.

  Parameters:
    `representation` - the XML representation as `StringBuffer`
  Throws:
    `NonParsableException` - if `representation` could not be parsed

Method Detail

### clone

    public ConstraintValidator clone()
                              throws CloneNotSupportedException

  Description copied from interface: `ParameterValidator`
  This method returns a deep copy of the current instance.

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

### addConstraint

    public void addConstraint(Constraint c)

  Adds an additional `Constraint` to the list of `Constraint`s.

  Parameters:
    `c` - the `Constraint` to be added

### checkValue

    public boolean checkValue(Object value)

  Description copied from interface: `ParameterValidator`
  Returns `true` if the value is valid and `false` otherwise.

  Specified by:
    `checkValue` in interface `ParameterValidator`
  Parameters:
    `value` - the `Object` to be checked
  Returns:
    if `value` is valid

### getErrorMessage

    public String getErrorMessage()

  Description copied from interface: `ParameterValidator`
  Returns the error message if `ParameterValidator.checkValue(Object)` returned false.

  Specified by:
    `getErrorMessage` in interface `ParameterValidator`
  Returns:
    the error message

### 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 `ConstraintValidator` from the XML representation as returned by `toXML()`.

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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD