|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.jstacs.parameters.Parameter
de.jstacs.parameters.CollectionParameter
public class CollectionParameter
Class for a collection parameter, i.e. a parameter that provides some collection of possible values the user can choose from.
Instances of this class can be used as parameters in a ParameterSet.
ParameterSet| Nested Class Summary | |
|---|---|
class |
CollectionParameter.InconsistentCollectionException
This exception is thrown if the CollectionParameter is inconsistent for some reason |
| Field Summary | |
|---|---|
protected String |
errorMessage
If a value was illegal for the collection parameter, this field holds the error message. |
protected ParameterSet |
parameters
The internal ParameterSet that holds the possible values |
protected boolean |
userSelected
True if the user has selected an item |
| Fields inherited from class de.jstacs.parameters.Parameter |
|---|
neededReference, neededReferenceId, parent |
| Constructor Summary | |
|---|---|
|
CollectionParameter(DataType datatype,
String[] keys,
Object[] values,
String[] comments,
String name,
String comment,
boolean required)
Constructor for a CollectionParameter. |
|
CollectionParameter(DataType datatype,
String[] keys,
Object[] values,
String name,
String comment,
boolean required)
Constructor for a CollectionParameter. |
|
CollectionParameter(InstanceParameterSet[] values,
String name,
String comment,
boolean required)
Constructor for a CollectionParameter from an array of ParameterSets. |
|
CollectionParameter(ParameterSet[] values,
String[] keys,
String[] comments,
String name,
String comment,
boolean required)
Constructor for a CollectionParameter from an array of ParameterSet. |
protected |
CollectionParameter(ParameterSet options,
int selected,
int defaultSelected,
boolean userSelected,
String name,
String comment,
boolean required,
DataType datatype,
String errorMessage,
boolean rangeable)
Creates a new CollectionParameter from the necessary field. |
|
CollectionParameter(StringBuffer representation)
Restores an instance of CollectionParameter from a string representation |
| Method Summary | |
|---|---|
protected void |
appendCollection(StringBuffer buf)
Appends the internal ParameterSet in its XML-representation (ParameterSet.toXML()) to buf |
boolean |
checkValue(Object value)
Returns true if the key specified by value is in the set of keys of this CollectionParameter. |
CollectionParameter |
clone()
|
protected void |
createParameterSet(Object[] values,
String[] keys,
String[] comments)
Creates a new ParameterSet from an array of values, an array of names, and an array of comments. |
boolean |
equals(Object o2)
|
protected void |
extractCollection(StringBuffer buf)
Extracts the internal ParameterSet from its XML-representation (ParameterSet.toXML()). |
protected void |
fromXML(StringBuffer representation)
Parses a Parameter from an XML-representation as returned by Parameter.toXML(). |
String |
getComment()
Returns a comment on this parameter that tells something about useful values, domains, usage of this parameter, etc. |
DataType |
getDatatype()
Returns the data type of the parameter |
protected int |
getDefault()
Returns the index of the default selected value. |
String |
getErrorMessage()
If a value could not be set successfully this method returns the corresponding error message. |
String |
getName()
Returns the name of the parameter |
ParameterSet |
getParametersInCollection()
Returns the possible values in this collection |
Parameter |
getRangedInstance()
Returns an instance of RangeIterator that has the same properties as the current instance, but
accepts a range or list of values. |
int |
getSelected()
Returns the index of the selected value. |
Object |
getValue()
Returns the current value of this Parameter |
boolean |
hasDefault()
Returns true, if this CollectionParameter has a default value. |
boolean |
hasDefaultOrIsSet()
Returns true if all the parameters in this collection are either set by the user or have default values |
boolean |
isAtomic()
Returns true if the collection is of an atomic data type |
boolean |
isRangeable()
Returns true if the parameters can be varied over a range of values. |
boolean |
isRequired()
Returns true if the parameter is required, false otherwise |
boolean |
isSet()
Returns true if this collection parameter was selected by the user. |
boolean |
isUserSelected()
Returns true if the value was selected by the user. |
void |
reset()
Resets the parameter and its contents to the default values or null if not
defaults are given. |
void |
setDefault(Object defaultValue)
Sets the default value of the parameter to defaultValue |
void |
setRangeable(boolean rangeable)
Sets the value returned by isRangeable() to rangeable |
void |
setValue(Object value)
Sets the selected value to the one that is specified by the key value |
void |
simplify()
Simplifies the Parameter and its contents to the relevant information. |
StringBuffer |
toXML()
This method returns an XML-representation of an instance of the implementing class. |
| Methods inherited from class de.jstacs.parameters.Parameter |
|---|
getId, getNeededReference, getNeededReferenceId, getParent, setNeededReference, setParent |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected ParameterSet parameters
ParameterSet that holds the possible values
protected boolean userSelected
protected String errorMessage
| Constructor Detail |
|---|
protected CollectionParameter(ParameterSet options,
int selected,
int defaultSelected,
boolean userSelected,
String name,
String comment,
boolean required,
DataType datatype,
String errorMessage,
boolean rangeable)
CollectionParameter from the necessary field. This constructor should be used to clone
a current instance.
options - the options of the CollectionParameterselected - the currently selected valuedefaultSelected - the value selected by defaultuserSelected - true is the current value was selected by the username - the namecomment - the commentrequired - true if this CollectionParameter is requireddatatype - the datatype of this CollectionParametererrorMessage - the error-message of the last error or nullrangeable - if the current instance is rangeable
public CollectionParameter(DataType datatype,
String[] keys,
Object[] values,
String name,
String comment,
boolean required)
throws CollectionParameter.InconsistentCollectionException,
SimpleParameter.IllegalValueException,
SimpleParameter.DatatypeNotValidException
CollectionParameter.
datatype - the data type of the parameters in the collectionkeys - the keys/names of the values in the collection, this is the name the user will see in the user interfacevalues - the values the names stand for. This array must be of the same length as the keys. A key at a certain position belongs to the value at the same position in the array.name - the name of the parametercomment - a comment on the parameterrequired - true if the parameter is required, false otherwise
CollectionParameter.InconsistentCollectionException - if the length of the keys and the values is different or the collection is inconsistent for some other reason, an InconsistentCollectionExceptionSimpleParameter.IllegalValueException - if one of the values in values is not of type datatype, an IllegalValueException is thrown
SimpleParameter.DatatypeNotValidException - is thrown if the datatype is not one of the allowed values
public CollectionParameter(DataType datatype,
String[] keys,
Object[] values,
String[] comments,
String name,
String comment,
boolean required)
throws CollectionParameter.InconsistentCollectionException,
SimpleParameter.IllegalValueException,
SimpleParameter.DatatypeNotValidException
CollectionParameter.
datatype - the data type of the parameters in the collectionkeys - the keys/names of the values in the collection, this is the name the user will see in the user interfacevalues - the values the names stand for. This array must be of the same length as the keys. A key at a certain position belongs to the value at the same position in the array.comments - the comments on the possible valuesname - the name of the parametercomment - a comment on the parameterrequired - true if the parameter is required, false otherwise
CollectionParameter.InconsistentCollectionException - if the length of the keys and the values is different or the collection is inconsistent for some other reason, an InconsistentCollectionExceptionSimpleParameter.IllegalValueException - if one of the values in values is not of type datatype, an IllegalValueException is thrown
SimpleParameter.DatatypeNotValidException
public CollectionParameter(ParameterSet[] values,
String[] keys,
String[] comments,
String name,
String comment,
boolean required)
CollectionParameter from an array of ParameterSet. This constructor can be used
to easily construct a CollectionParameter that lets the user select from a list
of possible options that all require an own set of Parameters to be instantiated.
values - the array of ParameterSetskeys - the keys/names of the values in the collection, this is the name the user will see in the user interfacecomments - the comments on the possible valuesname - the name of the parametercomment - a comment on the parameterrequired - true if the parameter is required, false otherwise
public CollectionParameter(InstanceParameterSet[] values,
String name,
String comment,
boolean required)
CollectionParameter from an array of ParameterSets. This constructor can be used
to easily construct a CollectionParameter that lets the user select from a list
of possible options that all require an own set of Parameters to be instantiated.
values - the array of ParameterSetsname - the name of the parametercomment - a comment on the parameterrequired - true if the parameter is required, false otherwise
public CollectionParameter(StringBuffer representation)
throws NonParsableException
CollectionParameter from a string representation
representation - the string representation
NonParsableException - if the representation could not be parsed to a CollectionParameter, a NonParsableException is thrown| Method Detail |
|---|
public CollectionParameter clone()
throws CloneNotSupportedException
clone in class ParameterCloneNotSupportedException
protected void createParameterSet(Object[] values,
String[] keys,
String[] comments)
throws SimpleParameter.DatatypeNotValidException,
SimpleParameter.IllegalValueException
ParameterSet from an array of values, an array of names, and an array of comments.
values - the values the names stand for. This array must be of the same length as the keys. A key at a certain position belongs to the value at the same position in the array.keys - the keys/names of the values in the collection, this is the name the user will see in the user interfacecomments - the comments on the possible values
SimpleParameter.IllegalValueException - if one of the values in values is not of type datatype, an IllegalValueException is thrown
SimpleParameter.DatatypeNotValidException - is thrown if the data type is not allowed, i.e. is not one of the primitive data types, String or DataType.PARAMETERSETpublic boolean isAtomic()
isAtomic in class Parameterpublic boolean hasDefault()
CollectionParameter has a default value.
CollectionParameter has a default valueCollectionParameter(ParameterSet, int, int, boolean, String, String, boolean, DataType, String, boolean),
setDefault(Object)public boolean hasDefaultOrIsSet()
hasDefaultOrIsSet in class Parameterpublic boolean isSet()
isSet in class Parameterpublic ParameterSet getParametersInCollection()
public void setRangeable(boolean rangeable)
isRangeable() to rangeable
rangeable - the new valuepublic boolean isRangeable()
Rangeable
isRangeable in interface Rangeablepublic boolean checkValue(Object value)
value is in the set of keys of this CollectionParameter.
checkValue in class Parametervalue - the value to be checked
public String getErrorMessage()
Parameter
getErrorMessage in class Parameterpublic StringBuffer toXML()
Storable
toXML in interface StorabletoXML in class Parameterprotected void appendCollection(StringBuffer buf)
ParameterSet in its XML-representation (ParameterSet.toXML()) to buf
buf - the StringBuffer this method appends to
protected void fromXML(StringBuffer representation)
throws NonParsableException
ParameterParameter from an XML-representation as returned by Parameter.toXML().
fromXML in class Parameterrepresentation - the XML-representation
NonParsableException - is thrown if the XML-code could not be parsed
protected void extractCollection(StringBuffer buf)
throws NonParsableException
ParameterSet from its XML-representation (ParameterSet.toXML()).
Reverse method to appendCollection(StringBuffer).
buf - the StringBuffer containing the XML-representation
NonParsableException - is thrown if the XML-code could not be parsedpublic String getName()
Parameter
getName in class Parameterpublic DataType getDatatype()
Parameter
getDatatype in class Parameterpublic String getComment()
Parameter
getComment in class Parameterpublic boolean isRequired()
Parametertrue if the parameter is required, false otherwise
isRequired in class Parameterpublic int getSelected()
protected int getDefault()
public boolean isUserSelected()
public void setValue(Object value)
throws SimpleParameter.IllegalValueException
value
setValue in class Parametervalue - the key of the desired value
SimpleParameter.IllegalValueException - if the specified value is not valid for this Parameter an IllegalValueException is thrown
public void setDefault(Object defaultValue)
throws SimpleParameter.IllegalValueException
ParameterdefaultValue
setDefault in class ParameterdefaultValue - the default value
SimpleParameter.IllegalValueExceptionpublic void simplify()
ParameterCollectionParameter that are not
selected.
simplify in class Parameterpublic void reset()
Parameternull if not
defaults are given.
reset in class Parameterpublic Object getValue()
ParameterParameter
getValue in class Parameterpublic boolean equals(Object o2)
equals in class Object
public Parameter getRangedInstance()
throws Exception
RangeableRangeIterator that has the same properties as the current instance, but
accepts a range or list of values. These values can be obtained by the methods of RangeIterator.
getRangedInstance in interface RangeableException - is thrown if isRangeable() returns false or the ranged instance could
not be created for some other reason
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||