|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Dictionary<K,V>
java.util.Hashtable<Object,Object>
java.util.Properties
org.apache.openjpa.lib.util.TypedProperties
org.apache.openjpa.lib.util.Options
public class 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.
Field Summary | |
---|---|
static Options |
EMPTY
Immutable empty instance. |
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 | |
---|---|
static Collection |
findOptionsFor(Class type)
Finds all the options that can be set on the provided class. |
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. |
Options |
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 |
---|
getProperty, getProperty, list, list, load, loadFromXML, propertyNames, save, store, storeToXML, storeToXML |
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 |
Field Detail |
---|
public static Options EMPTY
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 arguments
public Options 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")
Map
returned by this method.
Options
of key-value pairs in this object
for which no setters could be found.
RuntimeException
- on parse errorpublic static Collection findOptionsFor(Class type)
type
- The class for which available options should be listed.
type
. The
names will have initial caps. They will be ordered alphabetically.public 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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
This documentation is deprecated and will be removed in the next release of WebLogic Server.