|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.parameters.ParameterSetTagger
public class ParameterSetTagger
This class implements a tagger for Parameter
of ParameterSet
. This enable a parameter usage in command line
tool. Argument can be parsed from the specific syntax tag<delimiter>value
.
This class accesses the ParameterSet
via ParameterSet.getParameterAt(int)
only once during creation of
a new instance (in the constructor). If the number of parameters changes after the creation of a specific instance, this
instance will not detect this.
Nested Class Summary | |
---|---|
static class |
ParameterSetTagger.KeyEntryComparator<K extends Comparable<K>,V>
This class implements a comparator on Map.Entry that sorts by the key of the Map.Entry . |
class |
ParameterSetTagger.RankEntryComparator<K,V>
This class implements a comparator on Map.Entry where value is a ComparableElement with weight Integer . |
Constructor Summary | |
---|---|
ParameterSetTagger(String[] tags,
ParameterSet... sets)
The constructor creates an new instance by collecting and tagging all parameters of the ParameterSet s. |
Method Summary | ||
---|---|---|
void |
fillParameters(String delimiter,
String... args)
|
|
Parameter |
getParameterFromTag(String tag)
This method returns the Parameter specified by the tag |
|
Object |
getValueFromTag(String tag)
This method returns the value of the Parameter specified by the tag . |
|
|
getValueFromTag(String tag,
Class<T> c)
This method returns the casted value of the Parameter specified by the tag . |
|
boolean |
hasDefaultOrIsSet()
This method allows to check whether all tagged parameters that require a value also have some value. |
|
boolean |
isSet(String tag)
|
|
void |
setValueFromTag(String tag,
Object value)
This method allows to easily set the value of a parameter defined by the tag. |
|
String |
toString()
|
|
String |
toString(Comparator<Map.Entry<String,ComparableElement<Parameter,Integer>>> ec)
This method allows to get a String representation where the tagged parameters are sorted in some specific way. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ParameterSetTagger(String[] tags, ParameterSet... sets)
ParameterSet
s.
tags
- the unambiguous tags for all parameterssets
- the sets of Parameter
sParameterSet.getNumberOfParameters()
,
ParameterSet.getParameterAt(int)
Method Detail |
---|
public void fillParameters(String delimiter, String... args) throws IllegalArgumentException, SimpleParameter.IllegalValueException
delimiter
- the delimiter between each tag and valueargs
- the arguments, each argument has the form tag<delimiter>value
IllegalArgumentException
- if any argument could not be assigned to a parameter
SimpleParameter.IllegalValueException
- if any argument could not be parsedpublic Parameter getParameterFromTag(String tag)
Parameter
specified by the tag
tag
- the tag of the Parameter
Parameter
specified by the tag
ParameterSet.getParameterAt(int)
public boolean isSet(String tag)
tag
- the tag of the Parameter
true
if the the parameter is setgetParameterFromTag(String)
,
Parameter.isSet()
public Object getValueFromTag(String tag)
Parameter
specified by the tag
.
tag
- the tag of the Parameter
Parameter
specified by the tag
getParameterFromTag(String)
,
AnnotatedEntity.getValue()
public <T> T getValueFromTag(String tag, Class<T> c)
Parameter
specified by the tag
.
T
- the type of the classtag
- the tag of the Parameter
c
- the class that is used for casting
Parameter
specified by the tag
getValueFromTag(String)
public void setValueFromTag(String tag, Object value) throws SimpleParameter.IllegalValueException
tag
- the tag of the Parameter
value
- the value to be set
SimpleParameter.IllegalValueException
- if the value could not be setgetParameterFromTag(String)
,
Parameter.setValue(Object)
public boolean hasDefaultOrIsSet()
true
if each Parameter
that requires a value also has a default value or has been setParameter.hasDefaultOrIsSet()
public String toString(Comparator<Map.Entry<String,ComparableElement<Parameter,Integer>>> ec)
ec
- the comparator for sorting
String
representation of this instanceParameterSetTagger.KeyEntryComparator
,
ParameterSetTagger.RankEntryComparator
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |