public class StorableValidator extends Object implements ParameterValidator
AbstractTrainableStatisticalModel
).Constructor and Description |
---|
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
AbstractTrainableStatisticalModel or AbstractClassifier . |
StorableValidator(StringBuffer buf)
The standard constructor for the interface
Storable . |
Modifier and Type | Method and Description |
---|---|
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. |
public StorableValidator(Class<? extends Storable> clazz, boolean trained) throws Exception
StorableValidator
for a subclass of
AbstractTrainableStatisticalModel
or AbstractClassifier
. This constructor may
not be used on other subclasses of Storable
.clazz
- the classtrained
- true
if the model or classifier must be trainedException
- if clazz
is not of the expected typepublic StorableValidator(Class<? extends Storable> clazz) throws Exception
StorableValidator
for a subclass of
Storable
.clazz
- the classException
- if clazz
is not of the expected typepublic StorableValidator(StringBuffer buf) throws NonParsableException
Storable
.
Constructs an StorableValidator
from its XML representation.buf
- the XML representation as StringBuffer
NonParsableException
- if buf
could not be parsedpublic StorableValidator clone() throws CloneNotSupportedException
ParameterValidator
clone
in interface ParameterValidator
clone
in class Object
CloneNotSupportedException
- if the ParameterValidator
could not be clonedCloneable
public boolean checkValue(Object value)
value
. Allowed types of
value
are AbstractTrainableStatisticalModel
, 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.checkValue
in interface ParameterValidator
value
- the Object
to be checkedtrue
if value
is valid and
false
otherwisepublic 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
StorableValidator
from the XML representation as
returned by toXML()
.representation
- the XML representationNonParsableException
- if the XML code could not be parsed