|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.parameters.ParameterSet
public abstract class ParameterSet
(Container) class for a set of Parameter
s.
This is the base class for other ParameterSet
s that provide more specialized methods, e.g. for
expanding the set of Parameter
s at runtime ( ExpandableParameterSet
) or defining an array
of ParameterSet
s from a common template ( ArrayParameterSet
).
Nested Class Summary | |
---|---|
class |
ParameterSet.ParameterList
Class for a List of Parameter s that basically has the same functionality
as ArrayList , but additionally takes care of the references Parameter.parent . |
Field Summary | |
---|---|
protected Class |
alternativeInstanceClass
The class that can be instantiated using this ParameterSet |
protected String |
errorMessage
The error-message of the last error or null |
protected ParameterSet.ParameterList |
parameters
The set of parameters |
protected ParameterSetContainer |
parent
Is this ParameterSet is contained in a ParameterSetContainer ,
this variable holds a reference to that ParameterSetContainer . |
protected boolean |
ranged
Indicates if the Parameter s of this ParameterSet
that implement Rangeable and return true
shall be replaced by their ranged instances |
Constructor Summary | |
---|---|
|
ParameterSet()
Constructs a new ParameterSet with empty parameter values. |
protected |
ParameterSet(ArrayList<Parameter> parameters)
Constructs a ParameterSet out of an ArrayList
of parameters. |
|
ParameterSet(Class alternativeInstanceClass)
Constructs a ParameterSet from the class that can be instantiated using
this ParameterSet . |
protected |
ParameterSet(Parameter[] parameters)
Constructs a ParameterSet out of an array of parameters. |
|
ParameterSet(StringBuffer representation)
Constructs a ParameterSet out of an XML representation |
Method Summary | |
---|---|
ParameterSet |
clone()
Creates a full clone (deep copy) of this ParameterSet . |
protected void |
fromXML(StringBuffer representation)
Parses the instance fields of a ParameterSet from the XML-representation
as returned by toXML() . |
String |
getErrorMessage()
Returns the message of the last error that occurred. |
long |
getId()
Returns the id of this ParameterSet . |
InstantiableFromParameterSet |
getInstance()
Returns a new instance of the class of getInstanceClass() that was created using this ParameterSet . |
Class |
getInstanceClass()
Returns the class of the instances that can be constructed using this set. |
abstract String |
getInstanceComment()
Returns a comment (a textual description) of the class that can be constructed using this ParameterSet . |
abstract String |
getInstanceName()
Returns the name of an instance of the class that can be constructed using this ParameterSet . |
int |
getNumberOfParameters()
Returns the number of parameters in set |
int |
getNumberOfValues()
Returns the number of values in the collection. |
Parameter |
getParameterAt(int i)
Returns the parameter at position i |
ParameterSetContainer |
getParent()
Returns the enclosing ParameterSetContainer of this ParameterSet
or null if none exists. |
boolean |
hasDefaultOrIsSet()
Returns true if all parameters in this ParameterSet are
either set by the user or have default values. |
protected void |
initParameterList()
Initializes the internal set of Parameter s,
which is a ParameterSet.ParameterList . |
protected void |
initParameterList(int initCapacity)
Initializes the internal set of Parameter s,
which is a ParameterSet.ParameterList , with an initial number of Parameter s
of initCapacity . |
boolean |
isAtomic()
Returns true if this ParameterSet contains only atomic
parameters, i.e. the parameters do not contain ParameterSet s
themselves. |
boolean |
isRanged()
Returns true if this range iterator is ranging over a set of values. |
protected abstract void |
loadParameters()
Loads the parameters for this ParameterSet . |
void |
makeRanged()
Replaces all Parameter s in this ParameterSet
by their equivalents implementing the Rangeable interface. |
boolean |
next()
Switches to the next value in the collection of values in the specified range. |
boolean |
parametersLoaded()
Returns true if the parameters of this
ParameterSet have already been loaded using the
loadParameters() -method |
protected void |
propagateId()
Propagates the id of this ParameterSet to all Parameter s
above and below in the hierarchy. |
protected void |
recieveId()
Searches for all Parameter.neededReferenceId s in the hierarchy below this
ParameterSet and sets the corresponding Parameter.neededReference s. |
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. |
void |
resetToFirst()
Resets the current value in the collection to the first value. |
void |
setAlternativeInstanceClass(Class c)
Sets the class of the instances that can be constructed using this set. |
void |
setParent(ParameterSetContainer parent)
Sets the enclosing ParameterSetContainer of this ParameterSet
to parent . |
void |
simplify()
Simplifies all parameters in this ParameterSet |
StringBuffer |
toXML()
This method returns an XML-representation of an instance of the implementing class. |
String |
valuesToString()
Returns a String -representation of the set of values. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ParameterSet.ParameterList parameters
protected Class alternativeInstanceClass
ParameterSet
protected String errorMessage
null
protected boolean ranged
Parameter
s of this ParameterSet
that implement Rangeable
and return true
shall be replaced by their ranged instances
protected ParameterSetContainer parent
ParameterSet
is contained in a ParameterSetContainer
,
this variable holds a reference to that ParameterSetContainer
.
Constructor Detail |
---|
public ParameterSet(Class alternativeInstanceClass)
ParameterSet
from the class that can be instantiated using
this ParameterSet
. The set of parameters is loaded by the
loadParameters()
-method if this ParameterSet
is expected to be filled with values.
alternativeInstanceClass
- the classpublic ParameterSet() throws UnsupportedOperationException
ParameterSet
with empty parameter values.
The set of parameters is loaded by the loadParameters()
-method.ParameterSet
s, i.e.
to create ParameterSet
s from a set of values and not to fill it from the platform user-interface.
If this constructor is used as the super-contructor for constructors that shall be used in the platform user-interface,
the lazy evaluation of loadParameters()
-methods will be lost and memory may probably be wasted.
UnsupportedOperationException
- if the ParameterSet
could not be constructed
or the parameters could not be loaded an
UnsupportedOperationException
is thrown.protected ParameterSet(Parameter[] parameters)
ParameterSet
out of an array of parameters.
The parameters are not cloned, but passed by reference.
parameters
- the parametersprotected ParameterSet(ArrayList<Parameter> parameters)
ParameterSet
out of an ArrayList
of parameters. The parameters are not cloned, but passed by reference.
parameters
- the parameterspublic ParameterSet(StringBuffer representation) throws NonParsableException
ParameterSet
out of an XML representation
representation
- the XML representation
NonParsableException
- if the ParameterSet
could not be reconstructed
out of the representation, a
NonParsableException
is thrownMethod Detail |
---|
public ParameterSet clone() throws CloneNotSupportedException
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 Object
ParameterSet
CloneNotSupportedException
protected final void initParameterList()
Parameter
s,
which is a ParameterSet.ParameterList
.
protected final void initParameterList(int initCapacity)
Parameter
s,
which is a ParameterSet.ParameterList
, with an initial number of Parameter
s
of initCapacity
.
initCapacity
- the initial number of Parameter
sprotected abstract void loadParameters() throws Exception
ParameterSet
. This is in
most cases done by simply creating a new ArrayList<Parameter>
for the
field parameters/code>
and filling it with instances of subclasses of Parameter
- Throws:
Exception
- an Exception
is thrown if the parameters could not be loaded- See Also:
parameters
,
Parameter
public abstract String getInstanceName()
ParameterSet
.
public abstract String getInstanceComment()
ParameterSet
.
public boolean parametersLoaded()
true
if the parameters of this
ParameterSet
have already been loaded using the
loadParameters()
-method
public void setAlternativeInstanceClass(Class c)
c
- the classpublic Class getInstanceClass()
public boolean isAtomic()
ParameterSet
contains only atomic
parameters, i.e. the parameters do not contain ParameterSet
s
themselves.
public boolean hasDefaultOrIsSet()
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.
public String getErrorMessage()
null
.
public int getNumberOfParameters()
public Parameter getParameterAt(int i)
i
i
- the position
public void makeRanged() throws Exception
Parameter
s in this ParameterSet
by their equivalents implementing the Rangeable
interface.
Exception
- is thrown if these instances could not be createdpublic boolean next() throws ParameterException
RangeIterator
next
in interface RangeIterator
ParameterException
- if the next value could not be setpublic void resetToFirst()
RangeIterator
resetToFirst
in interface RangeIterator
public int getNumberOfValues()
RangeIterator
getNumberOfValues
in interface RangeIterator
public boolean isRanged()
RangeIterator
isRanged
in interface RangeIterator
public String valuesToString()
RangeIterator
String
-representation of the set of values.
valuesToString
in interface RangeIterator
protected void replaceParametersWithRangedInstance() throws Exception
Parameter
s in this ParameterSet
by their equivalents implementing the Rangeable
interface.
Exception
- is thrown if these instances could not be createdpublic InstantiableFromParameterSet getInstance() throws ParameterSetParser.NotInstantiableException
getInstanceClass()
that was created using this ParameterSet
.
ParameterSetParser.NotInstantiableException
- is thrown if the class could not be instantiatedParameterSetParser
public StringBuffer toXML()
Storable
toXML
in interface Storable
public void simplify()
ParameterSet
Parameter.simplify()
public void reset()
ParameterSet
to their
default values or null
if not default value was provided.
Parameter.reset()
protected void fromXML(StringBuffer representation) throws NonParsableException
ParameterSet
from the XML-representation
as returned by toXML()
.
representation
- the XML-representation
NonParsableException
- is thrown if the XML-code could not be parsedprotected void recieveId()
Parameter.neededReferenceId
s in the hierarchy below this
ParameterSet
and sets the corresponding Parameter.neededReference
s.
protected void propagateId()
ParameterSet
to all Parameter
s
above and below in the hierarchy.
public long getId()
ParameterSet
.
public ParameterSetContainer getParent()
ParameterSetContainer
of this ParameterSet
or null
if none exists.
public void setParent(ParameterSetContainer parent)
ParameterSetContainer
of this ParameterSet
to parent
.
parent
- the new parent
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |