|
SolarMetric Kodo JDO 2.5.8 generated on January 11 2004 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.Dictionary | +--java.util.Hashtable | +--java.util.Properties | +--serp.util.TypedProperties | +--serp.util.Options
A specialization of the Properties
map type with the added
abilities to read application options from the command line and to
use bean patterns to set an object's properties via command-line the
stored mappings.
A typical use pattern for this class is to construct a new instance
in the main
method, then call setFromCmdLine(java.lang.String[])
with the
given args. Next, an instanceof the class being invoked is created, and
setInto(java.lang.Object)
is called with that instance as a parameter. With this
pattern, the user can configure any bean properties of the class, or even
properties of classes reachable from the class, through the command
line.
Inner classes inherited from class java.util.Map |
Map.Entry |
Fields inherited from class java.util.Properties |
defaults |
Constructor Summary | |
Options()
Default constructor. |
|
Options(Properties defaults)
Construct the options instance with the given set of defaults. |
Method Summary | |
boolean |
getBooleanProperty(String key,
String key2,
boolean def)
Specialization of getBooleanProperty(java.lang.String, java.lang.String, boolean) to allow
a value to appear under either of two keys; useful for short and
long versions of command-line flags. |
double |
getDoubleProperty(String key,
String key2,
double def)
Specialization of TypedProperties.getDoubleProperty(java.lang.String) to allow
a value to appear under either of two keys; useful for short and
long versions of command-line flags. |
float |
getFloatProperty(String key,
String key2,
float def)
Specialization of TypedProperties.getFloatProperty(java.lang.String) to allow
a value to appear under either of two keys; useful for short and
long versions of command-line flags. |
int |
getIntProperty(String key,
String key2,
int def)
Specialization of TypedProperties.getIntProperty(java.lang.String) to allow
a value to appear under either of two keys; useful for short and
long versions of command-line flags. |
long |
getLongProperty(String key,
String key2,
long def)
Specialization of TypedProperties.getLongProperty(java.lang.String) to allow
a value to appear under either of two keys; useful for short and
long versions of command-line flags. |
String |
getProperty(String key,
String key2,
String def)
Specialization of Properties.getProperty(java.lang.String) to allow
a value to appear under either of two keys; useful for short and
long versions of command-line flags. |
boolean |
removeBooleanProperty(String key,
String key2,
boolean def)
Specialization of TypedProperties.removeBooleanProperty(java.lang.String) to allow
a value to appear under either of two keys; useful for short and
long versions of command-line flags. |
double |
removeDoubleProperty(String key,
String key2,
double def)
Specialization of TypedProperties.removeDoubleProperty(java.lang.String) to allow
a value to appear under either of two keys; useful for short and
long versions of command-line flags. |
float |
removeFloatProperty(String key,
String key2,
float def)
Specialization of TypedProperties.removeFloatProperty(java.lang.String) to allow
a value to appear under either of two keys; useful for short and
long versions of command-line flags. |
int |
removeIntProperty(String key,
String key2,
int def)
Specialization of TypedProperties.removeIntProperty(java.lang.String) to allow
a value to appear under either of two keys; useful for short and
long versions of command-line flags. |
long |
removeLongProperty(String key,
String key2,
long def)
Specialization of TypedProperties.removeLongProperty(java.lang.String) to allow
a value to appear under either of two keys; useful for short and
long versions of command-line flags. |
String |
removeProperty(String key,
String key2,
String def)
Specialization of Properties#removeProperty to allow
a value to appear under either of two keys; useful for short and
long versions of command-line flags. |
String[] |
setFromCmdLine(String[] args)
Parses the given argument list into flag/value pairs, which are stored as properties. |
void |
setInto(Object obj)
This method uses reflection to set all the properties in the given object that are named by the keys in this map. |
Methods inherited from class java.util.Properties |
|
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 Options()
public Options(Properties defaults)
Properties.Properties(Properties)
Method Detail |
public String[] setFromCmdLine(String[] args)
java Foo -flag1 value1 -flag2 value2 ... arg1 arg2 ...
args
- the command-line argumentspublic void setInto(Object obj)
"age"->"12"
obj.setAge (12)
"range"->"1,20"
obj.setRange (1, 20)
"range"->"10"
obj.setRange (10, 10)
"brother.name"->"Bob"
obj.getBrother ().setName ("Bob")
RuntimeException
- on parse errorpublic boolean getBooleanProperty(String key, String key2, boolean def)
getBooleanProperty(java.lang.String, java.lang.String, boolean)
to allow
a value to appear under either of two keys; useful for short and
long versions of command-line flags.public float getFloatProperty(String key, String key2, float def)
TypedProperties.getFloatProperty(java.lang.String)
to allow
a value to appear under either of two keys; useful for short and
long versions of command-line flags.public double getDoubleProperty(String key, String key2, double def)
TypedProperties.getDoubleProperty(java.lang.String)
to allow
a value to appear under either of two keys; useful for short and
long versions of command-line flags.public long getLongProperty(String key, String key2, long def)
TypedProperties.getLongProperty(java.lang.String)
to allow
a value to appear under either of two keys; useful for short and
long versions of command-line flags.public int getIntProperty(String key, String key2, int def)
TypedProperties.getIntProperty(java.lang.String)
to allow
a value to appear under either of two keys; useful for short and
long versions of command-line flags.public String getProperty(String key, String key2, String def)
Properties.getProperty(java.lang.String)
to allow
a value to appear under either of two keys; useful for short and
long versions of command-line flags.public boolean removeBooleanProperty(String key, String key2, boolean def)
TypedProperties.removeBooleanProperty(java.lang.String)
to allow
a value to appear under either of two keys; useful for short and
long versions of command-line flags.public float removeFloatProperty(String key, String key2, float def)
TypedProperties.removeFloatProperty(java.lang.String)
to allow
a value to appear under either of two keys; useful for short and
long versions of command-line flags.public double removeDoubleProperty(String key, String key2, double def)
TypedProperties.removeDoubleProperty(java.lang.String)
to allow
a value to appear under either of two keys; useful for short and
long versions of command-line flags.public long removeLongProperty(String key, String key2, long def)
TypedProperties.removeLongProperty(java.lang.String)
to allow
a value to appear under either of two keys; useful for short and
long versions of command-line flags.public int removeIntProperty(String key, String key2, int def)
TypedProperties.removeIntProperty(java.lang.String)
to allow
a value to appear under either of two keys; useful for short and
long versions of command-line flags.public String removeProperty(String key, String key2, String def)
Properties#removeProperty
to allow
a value to appear under either of two keys; useful for short and
long versions of command-line flags.
|
SolarMetric Kodo JDO 2.5.8 generated on January 11 2004 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |