|
||||||||||
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.ExpandableParameterSet
public class ExpandableParameterSet
A class for a ParameterSet
that can be expanded by additional Parameter
s at runtime.
The Parameter
are all of type ParameterSetContainer
. The contents of these Parameter
s
are provided by a ParameterSet
-template, which is cloned each time the addParameterToSet()
-method
is called and set as value of a ParameterSetContainer
that is added to the Parameter
s
of the ExpandableParameterSet
. Already added Parameter
s can also be removed from the set using the removeParameterFromSet
-method.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class de.jstacs.parameters.ParameterSet |
---|
ParameterSet.ParameterList |
Field Summary | |
---|---|
protected String |
commentTemplate
A template for the comment of the enclosing ParameterSetContainer |
protected String |
nameTemplate
A template for the name of the enclosing ParameterSetContainer |
protected ParameterSet |
template
The template for each ParameterSet |
Fields inherited from class de.jstacs.parameters.ParameterSet |
---|
alternativeInstanceClass, errorMessage, parameters, parent, ranged |
Constructor Summary | |
---|---|
ExpandableParameterSet(Class instanceClass,
ParameterSet[] templateAndContent,
String nameTemplate,
String commentTemplate)
Creates a new ExpandableParameterSet from a ParameterSet -array. |
|
ExpandableParameterSet(Class alternativeInstanceClass,
ParameterSet template,
String nameTemplate,
String commentTemplate)
Creates a new ExpandableParameterSet from a Class that can be instantiated using this
ExpandableParameterSet and templates for the ParameterSet in each element of the array,
the name and the comment that are displayed for the ParameterSetContainer s enclosing the ParameterSet s. |
|
ExpandableParameterSet(Class alternativeInstanceClass,
ParameterSet template,
String nameTemplate,
String commentTemplate,
int initCount)
Creates a new ExpandableParameterSet from a Class that can be instantiated using this
ExpandableParameterSet and templates for the ParameterSet in each element of the array,
the name and the comment that are displayed for the ParameterSetContainer s enclosing the ParameterSet s. |
|
ExpandableParameterSet(StringBuffer representation)
Creates a new ExpandableParameterSet from its XML-representation. |
Method Summary | |
---|---|
void |
addParameterToSet()
Adds a new ParameterSetContainer containing a clone of the ParameterSet -template
to the set of Parameter s |
ExpandableParameterSet |
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 ParameterSet.toXML() . |
String |
getInstanceComment()
Returns a comment (a textual description) of the class that can be constructed using this ParameterSet . |
String |
getInstanceName()
Returns the name of an instance of the class that can be constructed using this ParameterSet . |
protected void |
loadParameters()
Loads the parameters for this ParameterSet . |
boolean |
parameterRemovable()
Returns true if there is still a Parameter that can be removed from the set. |
void |
removeParameterFromSet()
Removes the last Parameter from set. |
boolean |
replaceContentWith(ParameterSet[] paramSetArray)
First removes all previous added ParameterSetContainer and afterwards adds all given
ParameterSet s (in the given order) enclosed in new ParameterSetContainer s. |
protected void |
replaceParametersWithRangedInstance()
Replaces all Parameter s in this ParameterSet
by their equivalents implementing the Rangeable interface. |
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, getNumberOfParameters, getNumberOfValues, getParameterAt, getParent, hasDefaultOrIsSet, initParameterList, initParameterList, isAtomic, isRanged, makeRanged, next, parametersLoaded, propagateId, recieveId, reset, resetToFirst, setAlternativeInstanceClass, setParent, simplify, valuesToString |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ParameterSet template
ParameterSet
protected String nameTemplate
ParameterSetContainer
protected String commentTemplate
ParameterSetContainer
Constructor Detail |
---|
public ExpandableParameterSet(Class alternativeInstanceClass, ParameterSet template, String nameTemplate, String commentTemplate)
ExpandableParameterSet
from a Class
that can be instantiated using this
ExpandableParameterSet
and templates for the ParameterSet
in each element of the array,
the name and the comment that are displayed for the ParameterSetContainer
s enclosing the ParameterSet
s.
Initially, the loadParameters
-method creates one copy of the template.
alternativeInstanceClass
- the Class
template
- the template of the ParameterSet
nameTemplate
- the name-templatecommentTemplate
- the comment-templatepublic ExpandableParameterSet(Class alternativeInstanceClass, ParameterSet template, String nameTemplate, String commentTemplate, int initCount)
ExpandableParameterSet
from a Class
that can be instantiated using this
ExpandableParameterSet
and templates for the ParameterSet
in each element of the array,
the name and the comment that are displayed for the ParameterSetContainer
s enclosing the ParameterSet
s.
Using this constructor, the loadParameters()
-method initially creates initCount
copies of the template.
alternativeInstanceClass
- the Class
template
- the template of the ParameterSet
nameTemplate
- the name-templatecommentTemplate
- the comment-templateinitCount
- the number of initial copies of the templatepublic ExpandableParameterSet(StringBuffer representation) throws NonParsableException
ExpandableParameterSet
from its XML-representation.
representation
- the XML-represenation
NonParsableException
- is thrown if representation
could not be parsed.public ExpandableParameterSet(Class instanceClass, ParameterSet[] templateAndContent, String nameTemplate, String commentTemplate)
ExpandableParameterSet
from a ParameterSet
-array.
The first element of this array is taken as a template for further addParameterToSet()
-calls.
instanceClass
- the class that can be instantiated from this ExpandableParameterSet
templateAndContent
- the content (and template)nameTemplate
- the name-templatecommentTemplate
- the comment-templateMethod Detail |
---|
public ExpandableParameterSet 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
protected void loadParameters() throws Exception
ParameterSet
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
- Specified by:
loadParameters
in class ParameterSet
- Throws:
Exception
- an Exception
is thrown if the parameters could not be loaded- See Also:
ParameterSet.parameters
,
Parameter
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 void addParameterToSet() throws CloneNotSupportedException
ParameterSetContainer
containing a clone of the ParameterSet
-template
to the set of Parameter
s
CloneNotSupportedException
- is thrown if the template could not be clonedpublic boolean replaceContentWith(ParameterSet[] paramSetArray)
ParameterSetContainer
and afterwards adds all given
ParameterSet
s (in the given order) enclosed in new ParameterSetContainer
s.
paramSetArray
- the ParameterSet
s to be set
ExpandableParameterSet
; false otherwise
(In this case, neither the previous added ParameterSetContainer
are removed nor is any
given ParameterSet
added. Hence the ExpandableParameterSet
stays unchanged)public boolean parameterRemovable()
Parameter
that can be removed from the set.
Parameter
can be removedpublic void removeParameterFromSet()
Parameter
from set.
public StringBuffer toXML()
Storable
toXML
in interface Storable
toXML
in class ParameterSet
protected 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 String getInstanceName()
ParameterSet
ParameterSet
.
getInstanceName
in class ParameterSet
public String getInstanceComment()
ParameterSet
ParameterSet
.
getInstanceComment
in class ParameterSet
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |