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 StorableValidator

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

All Implemented Interfaces:
  ParameterValidator, Storable, Cloneable

    public class StorableValidator

extends Object
implements ParameterValidator

Class for a validator that validates instances and XML representations for the correct class types (e.g. `AbstractModel`).

Author:
  Jan Grau

Constructor Summary
`StorableValidator(Class<? extends Storable> clazz)` Creates a new `StorableValidator` for a subclass of `Storable`.
`StorableValidator(Class<? extends Storable> clazz, boolean trained)` Creates a new `StorableValidator` for a subclass of `AbstractModel` or `AbstractClassifier`.
`StorableValidator(StringBuffer buf)` The standard constructor for the interface `Storable`.

Method Summary
`boolean` | `checkValue(Object value)` Checks the value of `value`.
`StorableValidator` | `clone()` This method returns a deep copy of the current instance.
`void` | `fromXML(StringBuffer representation)` Parses a `StorableValidator` 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

### StorableValidator

    public StorableValidator(Class<? extends Storable> clazz,
                             boolean trained)
                      throws Exception

  Creates a new `StorableValidator` for a subclass of `AbstractModel` or `AbstractClassifier`. This constructor may not be used on other subclasses of `Storable`.

  Parameters:
    `clazz` - the class
    `trained` - `true` if the model or classifier must be trained
  Throws:
    `Exception` - if `clazz` is not of the expected type

### StorableValidator

    public StorableValidator(Class<? extends Storable> clazz)
                      throws Exception

  Creates a new `StorableValidator` for a subclass of `Storable`.

  Parameters:
    `clazz` - the class
  Throws:
    `Exception` - if `clazz` is not of the expected type

### StorableValidator

    public StorableValidator(StringBuffer buf)
                      throws NonParsableException

  The standard constructor for the interface `Storable`. Constructs an `StorableValidator` from its XML representation.

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

Method Detail

### clone

    public StorableValidator 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`

### checkValue

    public boolean checkValue(Object value)

  Checks the value of `value`. Allowed types of `value` are `AbstractModel`, `AbstractClassifier`, `FileParameter.FileRepresentation`, `String`, and `StringBuffer`. In all cases where an XML representation is given as `value`, it must be surrounded by <object>-tags and these tags must contain a <className>-element that contains the name of the class of the represented instance.

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

### 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 `StorableValidator` 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