|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.parameters.ParameterSet
de.jstacs.parameters.InstanceParameterSet
public abstract class InstanceParameterSet
Abstract class for a ParameterSet
containing all parameters necessary to construct an
Object
that implements InstantiableFromParameterSet
. This parameter set handles the
alphabet container and if necessary the length, so it is well suited as parameter set for AbstractModel and
AbstractClassifier.
InstantiableFromParameterSet
,
ParameterSet
,
AbstractModel
,
AbstractClassifier
Nested Class Summary |
---|
Nested classes/interfaces inherited from class de.jstacs.parameters.ParameterSet |
---|
ParameterSet.ParameterList |
Field Summary | |
---|---|
protected Parameter |
alphabet
The alphabet the model works on |
protected Parameter |
length
The length of sequences the model can work on or 0 for arbitrary length |
Fields inherited from class de.jstacs.parameters.ParameterSet |
---|
alternativeInstanceClass, errorMessage, parameters, parent, ranged |
Constructor Summary | |
---|---|
InstanceParameterSet(Class instanceClass,
AlphabetContainer alphabet)
Constructs a InstanceParameterSet for an object that can handle sequences of variable length and with the alphabet. |
|
InstanceParameterSet(Class instanceClass,
AlphabetContainer alphabet,
int length,
boolean variableLength)
Constructs a InstanceParameterSet from the alphabet and the length. |
|
InstanceParameterSet(Class instanceClass,
boolean discrete,
boolean simple)
Constructs a InstanceParameterSet having empty parameter values. |
|
InstanceParameterSet(Class instanceClass,
boolean discrete,
boolean simple,
boolean variableLength)
Constructs a InstanceParameterSet having empty parameter values. |
|
InstanceParameterSet(StringBuffer representation)
Constructs a InstanceParameterSet from its XML-representation. |
Method Summary | |
---|---|
InstanceParameterSet |
clone()
Creates a full clone (deep copy) of this ParameterSet . |
boolean |
equals(Object o)
|
protected void |
fromXML(StringBuffer representation)
Parses the instance fields of a ParameterSet from the XML-representation
as returned by ParameterSet.toXML() . |
AlphabetContainer |
getAlphabet()
Returns the alphabet |
static int |
getIndex(String[] names,
Object[] values,
Comparable current,
boolean hasAlternative)
This method tries to find the correct name (String) for your choice. |
int |
getLength()
Returns the length of sequences the model can work on |
int |
getNumberOfParameters()
Returns the number of parameters in set |
Parameter |
getParameterAt(int i)
Returns the parameter at position i |
boolean |
hasDefaultOrIsSet()
Returns true if all parameters in this ParameterSet are
either set by the user or have default values. |
protected void |
replaceParametersWithRangedInstance()
Replaces all Parameter s in this ParameterSet
by their equivalents implementing the Rangeable interface. |
void |
reset()
Resets all parameters in this ParameterSet to their
default values or null if not default value was provided. |
StringBuffer |
toXML()
This method returns an XML-representation of an instance of the implementing class. |
Methods inherited from class de.jstacs.parameters.ParameterSet |
---|
getErrorMessage, getId, getInstance, getInstanceClass, getInstanceComment, getInstanceName, getNumberOfValues, getParent, initParameterList, initParameterList, isAtomic, isRanged, loadParameters, makeRanged, next, parametersLoaded, propagateId, recieveId, resetToFirst, setAlternativeInstanceClass, setParent, simplify, valuesToString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Parameter alphabet
protected Parameter length
0
for arbitrary length
Constructor Detail |
---|
public InstanceParameterSet(Class instanceClass, boolean discrete, boolean simple)
InstanceParameterSet
having empty parameter values. This constructor
should only be used if the object can handle sequences of fixed length.
instanceClass
- the class of the instancediscrete
- whether the alphabet should be discretesimple
- whether the alphabet should be simplepublic InstanceParameterSet(Class instanceClass, boolean discrete, boolean simple, boolean variableLength)
InstanceParameterSet
having empty parameter values. The user can specify a-priorily
if the object can handle sequences of variable lengths. If it can handle sequences of variable length the object is not queried from
the user as it is 0
anyway.
instanceClass
- the (sub-)classdiscrete
- whether the alphabet should be discretesimple
- whether the alphabet should be simplevariableLength
- true
if the object can handle sequences of arbitrary lengthpublic InstanceParameterSet(StringBuffer representation) throws NonParsableException
InstanceParameterSet
from its XML-representation. Automatically calls the current
implementation of fromXML(StringBuffer)
of Storable
.
representation
- the XML-representation
NonParsableException
- a NonParsableException
is thrown if representation
could not be parsedpublic InstanceParameterSet(Class instanceClass, AlphabetContainer alphabet, int length, boolean variableLength) throws Exception
InstanceParameterSet
from the alphabet and the length. This constructor can be used
to implement a InstanceParameterSet
that is already instantiated with known parameter values.
instanceClass
- the class of the instancealphabet
- the alphabetlength
- the lengthvariableLength
- whether the object can handle sequences of variable length
Exception
- an Exception
is thrown if the alphabet or the length are not in the expected range of
valuespublic InstanceParameterSet(Class instanceClass, AlphabetContainer alphabet) throws Exception
InstanceParameterSet
for an object that can handle sequences of variable length and with the alphabet.
This constructor can be used to implement a InstanceParameterSet
that is already instantiated with known parameter
values.
0
.
instanceClass
- the (sub-)classalphabet
- the alphabet
Exception
- an Exception
is thrown if the alphabet or the length are not in the expected range of
valuesMethod Detail |
---|
public static int getIndex(String[] names, Object[] values, Comparable current, boolean hasAlternative) throws IllegalArgumentException
names
- the namesvalues
- the values, that can be setcurrent
- the value to be sethasAlternative
- indicates whether the last entry of names is an alternative parameter
IllegalArgumentException
- if no match could be foundCollectionParameter
public boolean hasDefaultOrIsSet()
ParameterSet
ParameterSet
are
either set by the user or have default values. If any additional
constraints are required on your parameters you should either specifiy
some ParameterValidator
on these parameters or implement
these contraints by overriding this method in your implementation of
ParameterSet
. It is recommended to specify a useful
remark which constraint failed in the member-variable
errorMessage
, which will be displayed to the user. In the
overriding method super.hasDefaultOrIsSet() should be called prior to
checking specific constraints.
hasDefaultOrIsSet
in class ParameterSet
public void reset()
ParameterSet
ParameterSet
to their
default values or null
if not default value was provided.
reset
in class ParameterSet
Parameter.reset()
public AlphabetContainer getAlphabet()
public int getLength() throws IllegalArgumentException
IllegalArgumentException
- if the length is not correct, i.e. the length is not suitable for the chosen requirementsprotected void fromXML(StringBuffer representation) throws NonParsableException
ParameterSet
ParameterSet
from the XML-representation
as returned by ParameterSet.toXML()
.
fromXML
in class ParameterSet
representation
- the XML-representation
NonParsableException
- is thrown if the XML-code could not be parsedpublic int getNumberOfParameters()
ParameterSet
getNumberOfParameters
in class ParameterSet
protected void replaceParametersWithRangedInstance() throws Exception
ParameterSet
Parameter
s in this ParameterSet
by their equivalents implementing the Rangeable
interface.
replaceParametersWithRangedInstance
in class ParameterSet
Exception
- is thrown if these instances could not be createdpublic Parameter getParameterAt(int i)
ParameterSet
i
getParameterAt
in class ParameterSet
i
- the position
public StringBuffer toXML()
Storable
toXML
in interface Storable
toXML
in class ParameterSet
public boolean equals(Object o)
equals
in class Object
public InstanceParameterSet clone() throws CloneNotSupportedException
ParameterSet
ParameterSet
. As
a convenience-method the user can use
fillWithStandardFieldsForClone(ParameterSet)
on a newly
created instance of a subclass of ParameterSet
to obtain a
clone/copy of all standard member variables (those already defined in
ParameterSet
) in the passed ParameterSet
.
Using this method, the cloning-process becomes merely three-step:ParameterSet
,
most likely with an empty constructor or the one taking just the
instance-class
this.fillWithStandardFieldsForClone
on this
instance
Object
's method clone()
clone
in class ParameterSet
ParameterSet
CloneNotSupportedException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |