|
||||||||||
| 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
de.jstacs.parameters.MultiSelectionCollectionParameter
public class MultiSelectionCollectionParameter
Class for a Parameter that provides a collection of possible values. The user can then select one
or more values out of the collection as values of this Parameter.
CollectionParameter| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class de.jstacs.parameters.CollectionParameter |
|---|
CollectionParameter.InconsistentCollectionException |
| Field Summary |
|---|
| Fields inherited from class de.jstacs.parameters.CollectionParameter |
|---|
errorMessage, parameters, userSelected |
| Fields inherited from class de.jstacs.parameters.Parameter |
|---|
neededReference, neededReferenceId, parent |
| Constructor Summary | |
|---|---|
|
MultiSelectionCollectionParameter(DataType datatype,
String[] keys,
Object[] values,
String[] comments,
String name,
String comment,
boolean required)
Constructor for a MultiSelectionCollectionParameter. |
|
MultiSelectionCollectionParameter(DataType datatype,
String[] keys,
Object[] values,
String name,
String comment,
boolean required)
Constructor for a MultiSelectionCollectionParameter. |
|
MultiSelectionCollectionParameter(InstanceParameterSet[] values,
String name,
String comment,
boolean required)
Creates a new MultiSelectionCollectionParameter from an array of ParameterSets. |
|
MultiSelectionCollectionParameter(ParameterSet[] values,
String[] keys,
String[] comments,
String name,
String comment,
boolean required)
Creates a new MultiSelectionCollectionParameter from an array of ParameterSets. |
protected |
MultiSelectionCollectionParameter(ParameterSet options,
boolean[] selected,
boolean[] defaultSelected,
boolean userSelected,
String name,
String comment,
boolean required,
DataType datatype,
String errorMessage,
int current,
boolean makeRanged)
Creates a new MultiSelectionCollectionParameter from the necessary field. |
|
MultiSelectionCollectionParameter(StringBuffer representation)
Creates a new MultiSelectionCollectionParameter from its XML-representation |
| Method Summary | |
|---|---|
boolean |
checkValue(Object value)
Returns true if the key specified by value is in the set of keys of this CollectionParameter. |
MultiSelectionCollectionParameter |
clone()
|
protected void |
fromXML(StringBuffer representation)
Parses a Parameter from an XML-representation as returned by Parameter.toXML(). |
int |
getNumberOfNexts(int afterIdx)
Returns the number of calls to next() that can
be called before false is returned. |
int |
getNumberOfValues()
Returns the number of values in the collection. |
int |
getSelected()
Returns the index of the selected value. |
Object |
getValue()
Returns the current value of this Parameter |
Object |
getValueFor(int idx)
Returns the value of the option no. |
Object |
getValueFor(String key)
Returns the value for the option with key key. |
Object[] |
getValues()
Returns the values of all selected options as an array. |
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 |
isRanged()
Returns true if this range iterator is ranging over a set of values. |
boolean |
isSelected(int idx)
Returns true if the option at position idx is selected. |
boolean |
isSelected(String key)
Returns the selection value of the option key |
boolean |
isSet()
Returns true if this collection parameter was selected by the user. |
boolean |
next()
Switches to the next value in the collection of values in the specified range. |
void |
reset()
Resets the parameter and its contents to the default values or null if not
defaults are given. |
void |
resetToFirst()
Resets the current value in the collection to the first value. |
void |
setDefault(Object defaultValue)
Sets the default value of the parameter to defaultValue |
boolean |
setSelected(int idx,
boolean selected)
Sets the selection of option no. |
boolean |
setSelected(String key,
boolean selected)
Sets the selection of the option key to the value of selected |
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. |
String |
valuesToString()
Returns a String-representation of the set of values. |
| Methods inherited from class de.jstacs.parameters.CollectionParameter |
|---|
appendCollection, createParameterSet, equals, extractCollection, getComment, getDatatype, getDefault, getErrorMessage, getName, getParametersInCollection, getRangedInstance, hasDefault, isRangeable, isRequired, isUserSelected, setRangeable |
| 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 |
| Constructor Detail |
|---|
public MultiSelectionCollectionParameter(DataType datatype,
String[] keys,
Object[] values,
String name,
String comment,
boolean required)
throws CollectionParameter.InconsistentCollectionException,
SimpleParameter.IllegalValueException,
SimpleParameter.DatatypeNotValidException
MultiSelectionCollectionParameter. The first option in the selection is selected by default.
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
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
CollectionParameter.InconsistentCollectionException
public MultiSelectionCollectionParameter(DataType datatype,
String[] keys,
Object[] values,
String[] comments,
String name,
String comment,
boolean required)
throws CollectionParameter.InconsistentCollectionException,
SimpleParameter.IllegalValueException,
SimpleParameter.DatatypeNotValidException
MultiSelectionCollectionParameter. The first option in the selection is selected by default.
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 values in the collectionname - the name of the parametercomment - a comment on the parameterrequired - true if the parameter is required, false otherwise
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
CollectionParameter.InconsistentCollectionException
public MultiSelectionCollectionParameter(ParameterSet[] values,
String[] keys,
String[] comments,
String name,
String comment,
boolean required)
MultiSelectionCollectionParameter from an array of ParameterSets. The first option in the selection is selected by default.
values - the options/values in the collectionkeys - 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 this MultiSelectionCollectionParametercomment - the comment on this MultiSelectionCollectionParameterrequired - true if this MultiSelectionCollectionParameter is required
public MultiSelectionCollectionParameter(InstanceParameterSet[] values,
String name,
String comment,
boolean required)
MultiSelectionCollectionParameter from an array of ParameterSets. The first option in the selection is selected by default.
values - the options/values in the collectionname - the name of this MultiSelectionCollectionParametercomment - the comment on this MultiSelectionCollectionParameterrequired - true if this MultiSelectionCollectionParameter is required
public MultiSelectionCollectionParameter(StringBuffer representation)
throws NonParsableException
MultiSelectionCollectionParameter from its XML-representation
representation - the XML-representation
NonParsableException - is thrown if representation could not be parsed
protected MultiSelectionCollectionParameter(ParameterSet options,
boolean[] selected,
boolean[] defaultSelected,
boolean userSelected,
String name,
String comment,
boolean required,
DataType datatype,
String errorMessage,
int current,
boolean makeRanged)
throws Exception
MultiSelectionCollectionParameter from the necessary field. This constructor should be used to clone
a current instance.
options - the options of the CollectionParameterselected - the currently selected valuesdefaultSelected - the values 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 nullcurrent - the currently used value in the set of selected valuemakeRanged - replace the Parameter in options with their ranged equivalent (if allowed)
Exception| Method Detail |
|---|
public MultiSelectionCollectionParameter clone()
throws CloneNotSupportedException
clone in class CollectionParameterCloneNotSupportedException
public boolean setSelected(String key,
boolean selected)
key to the value of selected
key - the key of the optionselected - the selection value
public boolean isSelected(String key)
key
key - the key of the option
public Object getValueFor(String key)
key.
key - the key
null if the corresponding option either does not exists or is not selectedpublic boolean checkValue(Object value)
CollectionParametervalue is in the set of keys of this CollectionParameter.
checkValue in class CollectionParametervalue - the value to be checked
public void setValue(Object value)
throws SimpleParameter.IllegalValueException
CollectionParametervalue
setValue in class CollectionParametervalue - the key of the desired value
SimpleParameter.IllegalValueException - if the specified value is not valid for this Parameter an IllegalValueException is thrownpublic int getSelected()
CollectionParameter
getSelected in class CollectionParameter
public boolean setSelected(int idx,
boolean selected)
idx to selected
idx - the index of the optionselected - the selection value
public boolean isSelected(int idx)
true if the option at position idx is selected.
idx - the position
idx is selectedpublic Object getValueFor(int idx)
idx
idx - the index of the option
null if the corresponding option either does not exists or is not selectedpublic Object[] getValues()
public Object getValue()
ParameterParameter
getValue in class CollectionParameterpublic boolean hasDefaultOrIsSet()
CollectionParameter
hasDefaultOrIsSet in class CollectionParameterpublic boolean isSet()
CollectionParameter
isSet in class CollectionParameterpublic boolean isAtomic()
CollectionParameter
isAtomic in class CollectionParameterpublic void simplify()
ParameterCollectionParameter that are not
selected.
simplify in class CollectionParameterpublic void reset()
Parameternull if not
defaults are given.
reset in class CollectionParameter
public void setDefault(Object defaultValue)
throws SimpleParameter.IllegalValueException
ParameterdefaultValue
setDefault in class CollectionParameterdefaultValue - the default value
SimpleParameter.IllegalValueExceptionpublic StringBuffer toXML()
Storable
toXML in interface StorabletoXML in class CollectionParameter
protected void fromXML(StringBuffer representation)
throws NonParsableException
ParameterParameter from an XML-representation as returned by Parameter.toXML().
fromXML in class CollectionParameterrepresentation - the XML-representation
NonParsableException - is thrown if the XML-code could not be parsed
public boolean next()
throws ParameterException
RangeIterator
next in interface RangeIteratorParameterException - if the next value could not be setpublic void resetToFirst()
RangeIterator
resetToFirst in interface RangeIteratorpublic int getNumberOfValues()
RangeIterator
getNumberOfValues in interface RangeIteratorpublic int getNumberOfNexts(int afterIdx)
next() that can
be called before false is returned.
afterIdx - the index after which shall be counted
next()public String valuesToString()
RangeIteratorString-representation of the set of values.
valuesToString in interface RangeIteratorpublic boolean isRanged()
RangeIterator
isRanged in interface RangeIterator
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||