org.apache.openejb.loader
Class Options
java.lang.Object
org.apache.openejb.loader.Options
public class Options
- extends Object
The purpose of this class is to provide a more strongly typed version of a
java.util.Properties object. So far it is a read only view of the properties
and does not set data into the underlying Properties instance.
Similar to java.util.Properties it will delegate to a "parent" instance when
a property is not found. If a property is found but its value cannot be parsed
as the desired data type, the parent's value is used.
By default this object will log nothing, but if a Log implementation is set the
Options class will log three kinds of statements:
- When a property is not found: the property name and default value in use along
with all possible values (enums only). Debug level.
- When a property is found: the property name and value. Info level.
- When a property value cannot be parsed: the property name and invalid value. Warn level.
Logging the user supplied values onto INFO is really nice as it shows up in the standard
log output and allows us to easily see which values the user has changed from the default.
It's rather impossible to diagnose issues without this information.
ENUM SETS:
Properties that accept a Set of enum values automatically accept ALL and NONE in
addition to the explicitly created enum items.
Using ALL. This allows users to have an easy way to imply "all" without having to
hardcode an the entire list of enum items and protects against the case where that
list may grow in the future.
Using NONE. This allows users an alternative to using an empty string when explicitly
specifying that none of the options should be used.
In the internal code, this allows us to have these concepts in all enum options
without us having to add NONE or ALL enum items explicitly which leads to strange code.
Additionally TRUE is an alias for ALL and FALSE an alias for NONE. This allows options
that used to support only true/false values to be further defined in the future without
breaking compatibility.
- Version:
- $Rev: 1021903 $ $Date: 2010-10-12 22:00:51 +0200 (Di, 12. Okt 2010) $
Method Summary |
boolean |
get(String property,
boolean defaultValue)
|
Class |
get(String property,
Class defaultValue)
|
int |
get(String property,
int defaultValue)
|
long |
get(String property,
long defaultValue)
|
String |
get(String property,
String defaultValue)
|
|
get(String property,
T defaultValue)
|
|
get(String property,
T defaultValue)
|
|
getAll(String property,
Class<T> enumType)
|
|
getAll(String property,
Set<T> defaultValue)
|
protected
|
getAll(String property,
Set<T> defaultValue,
Class<T> enumType)
|
|
getAll(String property,
T... defaultValue)
|
Options.Log |
getLogger()
|
Properties |
getProperties()
|
boolean |
has(String property)
|
static String |
join(String delimiter,
Object... collection)
|
|
logAll(String property,
Set<T> value)
|
protected static
|
lowercase(Collection<T> items)
|
protected static
|
lowercase(T... items)
|
protected static String |
possibleValues(Class<? extends Enum> enumType)
|
protected static
|
possibleValues(V v)
|
void |
setLogger(Options.Log logger)
|
static
|
valueOf(Class<T> enumType,
String name)
Use this instead of Enum.valueOf() when you want to ensure that the
the enum values are case insensitive. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Options
public Options(Properties properties)
Options
public Options(Properties properties,
Options parent)
getProperties
public Properties getProperties()
setLogger
public void setLogger(Options.Log logger)
getLogger
public Options.Log getLogger()
has
public boolean has(String property)
get
public String get(String property,
String defaultValue)
get
public <T> T get(String property,
T defaultValue)
get
public int get(String property,
int defaultValue)
get
public long get(String property,
long defaultValue)
get
public boolean get(String property,
boolean defaultValue)
get
public Class get(String property,
Class defaultValue)
get
public <T extends Enum<T>> T get(String property,
T defaultValue)
getAll
public <T extends Enum<T>> Set<T> getAll(String property,
T... defaultValue)
getAll
public <T extends Enum<T>> Set<T> getAll(String property,
Set<T> defaultValue)
getAll
public <T extends Enum<T>> Set<T> getAll(String property,
Class<T> enumType)
getAll
protected <T extends Enum<T>> Set<T> getAll(String property,
Set<T> defaultValue,
Class<T> enumType)
valueOf
public static <T extends Enum<T>> T valueOf(Class<T> enumType,
String name)
- Use this instead of Enum.valueOf() when you want to ensure that the
the enum values are case insensitive.
- Type Parameters:
T
- - Parameters:
enumType
- name
-
- Returns:
logAll
public <T extends Enum<T>> Set<T> logAll(String property,
Set<T> value)
lowercase
protected static <T extends Enum<T>> String[] lowercase(T... items)
lowercase
protected static <T extends Enum<T>> String[] lowercase(Collection<T> items)
possibleValues
protected static <V extends Enum<V>> String possibleValues(V v)
possibleValues
protected static String possibleValues(Class<? extends Enum> enumType)
join
public static String join(String delimiter,
Object... collection)
Copyright © 1999-2013 The Apache OpenEJB development community. All Rights Reserved.