public class OptionManager extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULTVALUE |
Modifier and Type | Method and Description |
---|---|
void |
addLegalValue(java.lang.String optiongroup,
java.lang.String optionname,
java.lang.String value,
java.lang.String desc,
java.lang.String target) |
void |
generateMaps()
Creates several option maps for fast access to individual options.
|
int |
getNumberOfOptionValues(int containerIndex)
Returns the number of option values for a particular option container.
|
java.util.Set<java.lang.Integer> |
getOptionContainerIndices()
Returns a sorted set of container names.
|
java.lang.Object |
getOptionDefaultValue(java.lang.String optiongroup,
java.lang.String optionname) |
OptionDescriptions |
getOptionDescriptions()
Returns the option description
|
java.lang.Object |
getOptionValue(int containerIndex,
java.lang.String optiongroup,
java.lang.String optionname)
Returns the option value for an option that is specified by the option group name and option name.
|
java.lang.Object |
getOptionValueNoDefault(int containerIndex,
java.lang.String optiongroup,
java.lang.String optionname) |
java.lang.String |
getOptionValueString(int containerIndex,
java.lang.String optiongroup,
java.lang.String optionname)
Returns a string representation of the option value for an option that is specified by the option group name and the option name.
|
java.lang.String |
getOptionValueStringNoDefault(int containerIndex,
java.lang.String optiongroup,
java.lang.String optionname) |
boolean |
hasOptions() |
static OptionManager |
instance()
Returns a reference to the single instance.
|
void |
loadOptionDescriptionFile()
Loads the option description file
/appdata/options.xml |
void |
loadOptionDescriptionFile(java.net.URL url)
Loads the option description file
|
void |
loadOptions(int containerIndex,
java.io.InputStreamReader isr)
Loads the saved options (options that are marked with
usage=Option.SAVE ). |
void |
loadOptions(int containerIndex,
java.lang.String fileName)
Loads the saved options (options that are marked with
usage=save ). |
void |
overloadOptionValue(int containerIndex,
int containerType,
java.lang.String optiongroup,
java.lang.String optionname,
java.lang.String value) |
void |
overloadOptionValue(int containerIndex,
java.lang.String optiongroup,
java.lang.String optionname,
java.lang.String value)
Overloads the option value specified by the container index, the option group name, the option name.
|
boolean |
parseCommandLine(java.lang.String[] args,
int containerIndex)
Parses the command line arguments.
|
boolean |
parseCommandLine(java.lang.String argString,
int containerIndex) |
void |
parseOptionInstanceXMLfile(java.lang.String fileName)
Parses the option file for option values.
|
void |
saveOptions(int containerIndex,
java.io.OutputStreamWriter osw)
Saves all options that are marked as usage=Option.SAVE for a particular option container.
|
void |
saveOptions(int containerIndex,
java.lang.String fileName)
Saves all options that are marked as usage=Option.SAVE for a particular option container.
|
void |
saveOptions(java.io.OutputStreamWriter osw)
Saves all options that are marked as
usage=Option.SAVE |
void |
saveOptions(java.lang.String fileName)
Saves all options that are marked as
usage=Option.SAVE |
java.lang.String |
toString() |
java.lang.String |
toStringPrettyValues(int containerIndex,
java.util.Set<java.lang.String> excludeGroups)
Returns a string representation of all option value, except the options in a option group specified
by the excludeGroup argument.
|
public static final int DEFAULTVALUE
public static OptionManager instance()
public void loadOptionDescriptionFile() throws MaltChainedException
/appdata/options.xml
MaltChainedException
public void loadOptionDescriptionFile(java.net.URL url) throws MaltChainedException
url
- URL of the option description fileMaltChainedException
public OptionDescriptions getOptionDescriptions()
public boolean hasOptions()
public java.lang.Object getOptionValue(int containerIndex, java.lang.String optiongroup, java.lang.String optionname) throws MaltChainedException
containerIndex
- The index of the option container (0..n and -1 is default values).optiongroup
- The name of the option group.optionname
- The name of the option.OptionException
MaltChainedException
public java.lang.Object getOptionDefaultValue(java.lang.String optiongroup, java.lang.String optionname) throws MaltChainedException
MaltChainedException
public java.lang.Object getOptionValueNoDefault(int containerIndex, java.lang.String optiongroup, java.lang.String optionname) throws MaltChainedException
MaltChainedException
public java.lang.String getOptionValueString(int containerIndex, java.lang.String optiongroup, java.lang.String optionname) throws MaltChainedException
containerIndex
- The index of the option container (0..n and -1 is default values).optiongroup
- The name of the option group.optionname
- The name of the option.MaltChainedException
public java.lang.String getOptionValueStringNoDefault(int containerIndex, java.lang.String optiongroup, java.lang.String optionname) throws MaltChainedException
MaltChainedException
public void addLegalValue(java.lang.String optiongroup, java.lang.String optionname, java.lang.String value, java.lang.String desc, java.lang.String target) throws MaltChainedException
MaltChainedException
public void overloadOptionValue(int containerIndex, java.lang.String optiongroup, java.lang.String optionname, java.lang.String value) throws MaltChainedException
containerIndex
- the index of the option container (0..n and -1 is default values).optiongroup
- the name of the option group.optionname
- the name of the option.value
- the option value that should replace the current option value.MaltChainedException
public void overloadOptionValue(int containerIndex, int containerType, java.lang.String optiongroup, java.lang.String optionname, java.lang.String value) throws MaltChainedException
MaltChainedException
public int getNumberOfOptionValues(int containerIndex)
containerIndex
- The index of the option container (0..n).public java.util.Set<java.lang.Integer> getOptionContainerIndices()
public void loadOptions(int containerIndex, java.lang.String fileName) throws MaltChainedException
usage=save
).fileName
- The path to the file where to load the saved options.MaltChainedException
public void loadOptions(int containerIndex, java.io.InputStreamReader isr) throws MaltChainedException
usage=Option.SAVE
).isr
- the input stream reader of the saved options file.MaltChainedException
public void saveOptions(java.lang.String fileName) throws MaltChainedException
usage=Option.SAVE
fileName
- The path to the file where the saveOption should by saved.MaltChainedException
public void saveOptions(java.io.OutputStreamWriter osw) throws MaltChainedException
usage=Option.SAVE
osw
- the output stream writer of the saved option fileMaltChainedException
public void saveOptions(int containerIndex, java.lang.String fileName) throws MaltChainedException
containerIndex
- The index of the option container (0..n).fileName
- The path to the file where the saveOption should by saved.MaltChainedException
public void saveOptions(int containerIndex, java.io.OutputStreamWriter osw) throws MaltChainedException
containerIndex
- The index of the option container (0..n).osw
- the output stream writer of the saved option fileMaltChainedException
public void generateMaps() throws MaltChainedException
OptionException
MaltChainedException
public boolean parseCommandLine(java.lang.String argString, int containerIndex) throws MaltChainedException
MaltChainedException
public boolean parseCommandLine(java.lang.String[] args, int containerIndex) throws MaltChainedException
args
- An array of arguments that are supplied when starting the application.OptionException
MaltChainedException
public void parseOptionInstanceXMLfile(java.lang.String fileName) throws MaltChainedException
fileName
- The option file name (must be a xml file).OptionException
MaltChainedException
public java.lang.String toStringPrettyValues(int containerIndex, java.util.Set<java.lang.String> excludeGroups) throws MaltChainedException
containerIndex
- The index of the option container (0..n and -1 is default values).excludeGroups
- a set of option group names that should by excluded in the string representationMaltChainedException
public java.lang.String toString()
toString
in class java.lang.Object
Copyright 2007-2017 Johan Hall, Jens Nilsson and Joakim Nivre.