|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.Dictionary | +--java.util.Hashtable | +--java.util.Properties | +--jj2000.j2k.util.ParameterList
This class holds modules options and parameters as they are provided to the encoder or the decoder. Each option and its associated parameters are stored as strings.
This class is built on the standard Java Properties class. Consequently, it offers facilities to load and write parameters from/to a file. In the meantime, a ParameterList object can also handle default parameters for each option.
Each parameter can be retrieved as a string or as an specific primitive type (int, float, etc).
For more details see the Properties class.
Note that this class does not support multiple occurrences of parameters (for a parameter name, only one value is possible). Also there is no particular order of the parameters.
Properties
,
Serialized FormNested Class Summary |
Nested classes inherited from class java.util.Hashtable |
|
Nested classes inherited from class java.util.Map |
java.util.Map.Entry |
Field Summary |
Fields inherited from class java.util.Properties |
defaults |
Fields inherited from class java.util.Hashtable |
|
Constructor Summary | |
ParameterList()
Constructs an empty ParameterList object. |
|
ParameterList(ParameterList def)
Constructs an empty ParameterList object with the provided default parameters. |
Method Summary | |
void |
checkList(char[] prfxs,
java.lang.String[] plist)
Checks if the parameters which names do not start with any of the prefixes in 'prfxs' in this ParameterList are all in the list of valid parameter names 'plist'. |
void |
checkList(char prfx,
java.lang.String[] plist)
Checks if the parameters which name starts with the prefix 'prfx' in the parameter list are all in the list of valid parameter names 'plist'. |
boolean |
getBooleanParameter(java.lang.String pname)
Returns the value of the named parameter as a boolean. |
ParameterList |
getDefaultParameterList()
Returns the default ParameterList. |
float |
getFloatParameter(java.lang.String pname)
Returns the value of the named parameter as a float. |
int |
getIntParameter(java.lang.String pname)
Returns the value of the named parameter as an int. |
java.lang.String |
getParameter(java.lang.String pname)
Returns the value of the named parameter, as a string. |
void |
parseArgs(java.lang.String[] argv)
Parses the parameters from an argument list, such as as the one in the command line, and integrates them in this parameter list. |
static java.lang.String[] |
toNameArray(java.lang.String[][] pinfo)
Converts the usage information to a list of parameter names in a single array. |
Methods inherited from class java.util.Properties |
getProperty, getProperty, list, list, load, propertyNames, save, setProperty, store |
Methods inherited from class java.util.Hashtable |
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public ParameterList()
public ParameterList(ParameterList def)
def
- The defaults parametersMethod Detail |
public ParameterList getDefaultParameterList()
public void parseArgs(java.lang.String[] argv)
All options must be preceded by '-' and then followed by one or more words, which constitues the values. The name of the options constitute the name of the parameters. The only exception is for boolean options, in which case if they are preceded by '-' they will be turned on, and if preceded by '+' they will be turned off. The string value of a boolean option is "on" or "off". Note that the '-' and '+' characters can not precede any word which would be a value for an option unless they are numeric values (otherwise it would be considered as a boolean option). Note also that the name of an option can not start with a number.
No option can appear more than once. If so happens an exception is thrown.
For instance the string:
"-Ffilters w5x3 -Wlev 5 -Qtype reversible
will create the following parameter list:
Ffilers w5x3 Wlev 5 Qtype reversible
argv
- The argument list.
StringFormatException
- if there are invalid arguments in
'argv'public java.lang.String getParameter(java.lang.String pname)
pname
- The parameter name.
public boolean getBooleanParameter(java.lang.String pname)
pname
- The parameter name.
StringFormatException
- If the parameter has a value which is
neither "on" nor "off".
java.lang.IllegalArgumentException
- If there is no parameter with the
name 'pname' in the parameter list.public int getIntParameter(java.lang.String pname)
pname
- The parameter name.
java.lang.NumberFormatException
- If the parameter has a non-numeric
value.
java.lang.IllegalArgumentException
- If there is no parameter with the
name 'pname' in the parameter list.public float getFloatParameter(java.lang.String pname)
pname
- The parameter name.
java.lang.NumberFormatException
- If the parameter has a non-numeric
value.
java.lang.IllegalArgumentException
- If there is no parameter with the
name 'pname' in the parameter list.public void checkList(char prfx, java.lang.String[] plist)
prfx
- The prefix of parameters to check.plist
- The list of valid parameter names for the 'prfx'
prefix. If null it is considered that no names are valid.
java.lang.IllegalArgumentException
- If there's a parameter name
starting with 'prfx' which is not in the valid list of parameter names.public void checkList(char[] prfxs, java.lang.String[] plist)
prfxs
- The prefixes of parameters to ignore.plist
- The list of valid parameter names. If null it is
considered that no names are valid.
java.lang.IllegalArgumentException
- If there's a parameter name not
starting with 'prfx' which is not in the valid list of parameter names.public static java.lang.String[] toNameArray(java.lang.String[][] pinfo)
pinfo
- The list of options and their usage info (see above).
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |