|
|
|||||||||||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.lmu.ifi.dbs.elki.logging.AbstractLoggable
de.lmu.ifi.dbs.elki.utilities.optionhandling.OptionHandler
public class OptionHandler
Provides an OptionHandler for holding the given options.
The options specified are stored in a <String,Option>-Map (Map
)
with the names of the options being the keys. New options can be added by
using the method put(Option)
.
Field Summary | |
---|---|
private String[] |
currentParameters
Holds the parameter array as given to the last call of grabOptions(String[]) . |
private List<GlobalParameterConstraint> |
globalParameterConstraints
Contains constraints addressing several parameters |
static String |
NEWLINE
The newline-String dependent on the system. |
static String |
OPTION_PREFIX
Prefix of optionmarkers on the commandline. |
private Map<String,Option<?>> |
parameters
Contains the optionHandler's options, the option names are used as the map's keys |
private String |
programCall
The programCall as it should be denoted in an eventual usage-message. |
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable |
---|
debug |
Constructor Summary | |
---|---|
OptionHandler(Map<String,Option<?>> parameters,
String programCall)
Provides an OptionHandler. |
Method Summary | ||
---|---|---|
void |
addOptionSettings(AttributeSettings settings)
Adds the settings of the options assigned to this option handler to the specified attribute settings. |
|
protected void |
checkGlobalParameterConstraints()
|
|
private void |
checkNonOptionalParameters()
|
|
Option<?> |
getOption(String name)
|
|
Option<?>[] |
getOptions()
|
|
|
getOptionValue(String option)
Deprecated. use getParameterValue(parameter) instead. |
|
String[] |
getParameterArray()
Returns a copy of the parameter array as given to the last call of grabOptions(String[]) . |
|
String[] |
grabOptions(String[] currentOptions)
Reads the options out of a given String-array (usually the args of any main-method). |
|
boolean |
isSet(Option<?> option)
Returns true if the value of the given option is set, false otherwise. |
|
boolean |
isSet(String option)
Returns true if the value of the given option is set, false otherwise. |
|
void |
put(Map<String,Option<?>> params)
Deprecated. |
|
void |
put(Option<?> option)
Adds the given option to the OptionHandler's current parameter map. |
|
void |
remove(String optionName)
Removes the given option from the OptionHandler's parameter map. |
|
private void |
setDefaultValues()
Checks all parameters not specified in currentParameters for default values and sets them, if existing |
|
void |
setGlobalParameterConstraint(GlobalParameterConstraint gpc)
|
|
void |
setProgrammCall(String call)
Sets the OptionHandler's programmCall (@link #programCall} to the given call. |
|
String |
usage(String message)
Returns an usage-String according to the descriptions given in the constructor. |
|
String |
usage(String message,
boolean standalone)
Returns an usage-String according to the descriptions given in the constructor. |
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable |
---|
debugFine, debugFiner, debugFinest, exception, message, progress, progress, progress, verbose, verbose, warning |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String NEWLINE
public static final String OPTION_PREFIX
private String programCall
private String[] currentParameters
grabOptions(String[])
.
private Map<String,Option<?>> parameters
private List<GlobalParameterConstraint> globalParameterConstraints
Constructor Detail |
---|
public OptionHandler(Map<String,Option<?>> parameters, String programCall)
parameters
- Map containing the optionsprogramCall
- String for the program-call using this OptionHandler (for
usage in usage(String))Method Detail |
---|
public String[] grabOptions(String[] currentOptions) throws ParameterException
currentOptions
- an array of given options, flags without values. E.g. the args
of some main-method. In this array every option should have a
leading "-".
NoParameterValueException
- if a parameter, for which a value is required, has none (e.g.
because the next value is itself some option)
ParameterException
public <T> T getOptionValue(String option) throws UnusedParameterException, NoParameterValueException
getParameterValue(parameter)
instead.
option
- option to get value of. The option should be asked for without
leading "-" or closing ":".
UnusedParameterException
- if the given option is not used
NoParameterValueException
- if the given option is only a flag and should therefore have
no valuepublic Option<?> getOption(String name) throws UnusedParameterException
UnusedParameterException
public boolean isSet(String option)
option
- The option should be asked for without leading "-"
or closing ":".
public boolean isSet(Option<?> option)
option
- The option should be asked for without leading "-"
or closing ":".
public String usage(String message)
usage(message,true)
.
message
- some error-message, if needed (may be null or empty String)
public String usage(String message, boolean standalone)
message
- some error-message, if needed (may be null or empty String)standalone
- whether the class using this OptionHandler provides a main
method
public String[] getParameterArray()
grabOptions(String[])
. The resulting
array will contain only those values that were recognized and needed by
this OptionHandler.
grabOptions(String[])
@Deprecated public void put(Map<String,Option<?>> params)
params
- Parameter map to be added.public void put(Option<?> option)
option
- Option to be added.public void setGlobalParameterConstraint(GlobalParameterConstraint gpc)
public void setProgrammCall(String call)
call
- The new programm call.public void remove(String optionName) throws UnusedParameterException
optionName
- Option to be removed.
UnusedParameterException
- If there is no such option.public Option<?>[] getOptions()
public void addOptionSettings(AttributeSettings settings) throws UnusedParameterException
settings
- the attribute settings to add
the settings of the options assigned to this option handler to
UnusedParameterException
- todoprivate void setDefaultValues()
private void checkNonOptionalParameters() throws ParameterException
ParameterException
protected void checkGlobalParameterConstraints() throws ParameterException
ParameterException
|
|
||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |