|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.metamatrix.common.properties.PropertyManager com.metamatrix.common.properties.TextManager com.metamatrix.common.properties.ObjectPropertyManager
public class ObjectPropertyManager
ObjectPropertyManager adds to TextManager the ability to apply a Java interpreter to evaluate property values at runtime. This means that all property values evaluate to Objects, which provides an easy means to specify complex property values.
Since the values within the resource bundles are interpreted, they must be specified using Java syntax (although trailing semicolons are optional). A special variable, "mgr", can be used within property values to reference the instance of ObjectPropertyManager retrieving the value, and is intended for accessing the getter methods of that instance.
Notes:
Example:
Resource Bundle (com/metamatrix/toolbox/uiDefaults.properties)
- message.key = "line1\\nline2"
- other.key = 3
- integer.property.key = mgr.get("other.key")
Code
- public static void main() {
- final ObjectPropertyManager propMgr = new ObjectPropertyManager("com/metamatrix/toolbox/uiDefaults");
- final int intProp = propMgr.getInt("integer.property.key");
- }
ResourceBundle
Field Summary |
---|
Fields inherited from class com.metamatrix.common.properties.TextManager |
---|
DEFAULT_NAMESPACES, INSTANCE |
Fields inherited from interface com.metamatrix.common.util.LogCommonConstants |
---|
CTX_BUFFER_MGR, CTX_CONFIG, CTX_CONTROLLER, CTX_DBIDGEN, CTX_DISTRIB_CACHE, CTX_EXTENSION_SOURCE, CTX_EXTENSION_SOURCE_JDBC, CTX_LOGGING, CTX_LOGON, CTX_MESSAGE_BUS, CTX_POOLING, CTX_PROXY, CTX_SERVICE, CTX_STANDARD_ERR, CTX_STANDARD_OUT, CTX_STORAGE_MGR, CTX_TXN_LOG, CTX_XA_TXN, TYPE_DEBUG, TYPE_ERROR, TYPE_EXCEPTION, TYPE_INFO, TYPE_TRACE, TYPE_WARNING |
Constructor Summary | |
---|---|
ObjectPropertyManager()
Creates an instance of ObjectPropertyManager with no namespaces. |
|
ObjectPropertyManager(java.util.List namespaces)
Creates an instance of ObjectPropertyManager that will retrieve property values from the specified list of namespaces. |
|
ObjectPropertyManager(java.lang.String namespace)
Creates an instance of ObjectPropertyManager that will retrieve property values from the specified namespace. |
|
ObjectPropertyManager(java.lang.String[] namespaces)
Creates an instance of ObjectPropertyManager that will retrieve property values from the specified list of namespaces. |
|
ObjectPropertyManager(java.lang.String namespace,
java.util.Map propertyMap)
Creates an instance of ObjectPropertyManager that will retrieve property values from the specified namespace. |
Method Summary | |
---|---|
protected static void |
assertClass(java.lang.String key,
java.lang.Object value,
java.lang.Class expectedClass)
Verifies that the specified value is an instance of the specified class. |
protected void |
constructObjectPropertyManager(java.util.List namespaces,
java.util.Map propertyMap)
Called by each constructor to initialize the namespaces list and register any namespaces passed in the constructor. |
protected java.lang.Object |
evaluateValue(java.lang.String key,
java.lang.String value)
Provided for subclasses to control the evaluation of retrieved property values. |
boolean |
getBoolean(java.lang.String key)
Retrieves the boolean value of the property identified by the specified key. |
boolean |
getBoolean(java.lang.String key,
boolean defaultValue)
Retrieves the boolean value of the property identified by the specified key, or if not found, returns the specified default value. |
byte |
getByte(java.lang.String key)
Retrieves the byte value of the property identified by the specified key. |
byte |
getByte(java.lang.String key,
byte defaultValue)
Retrieves the byte value of the property identified by the specified key, or if not found, returns the specified default value. |
char |
getChar(java.lang.String key)
Retrieves the char value of the property identified by the specified key. |
char |
getChar(java.lang.String key,
char defaultValue)
Retrieves the char value of the property identified by the specified key, or if not found, returns the specified default value. |
double |
getDouble(java.lang.String key)
Retrieves the double value of the property identified by the specified key. |
double |
getDouble(java.lang.String key,
double defaultValue)
Retrieves the double value of the property identified by the specified key, or if not found, returns the specified default value. |
float |
getFloat(java.lang.String key)
Retrieves the float value of the property identified by the specified key. |
float |
getFloat(java.lang.String key,
float defaultValue)
Retrieves the float value of the property identified by the specified key, or if not found, returns the specified default value. |
int |
getInt(java.lang.String key)
Retrieves the int value of the property identified by the specified key. |
int |
getInt(java.lang.String key,
int defaultValue)
Retrieves the int value of the property identified by the specified key, or if not found, returns the specified default value. |
Interpreter |
getInterpreter()
Returns the Java interpreter used to evaluate poroperty values. |
long |
getLong(java.lang.String key)
Retrieves the long value of the property identified by the specified key. |
long |
getLong(java.lang.String key,
long defaultValue)
Retrieves the long value of the property identified by the specified key, or if not found, returns the specified default value. |
protected java.lang.Object |
getNonNullObject(java.lang.String key)
Retrieves the value of the property identified by the specified key. |
short |
getShort(java.lang.String key)
Retrieves the short value of the property identified by the specified key. |
short |
getShort(java.lang.String key,
short defaultValue)
Retrieves the short value of the property identified by the specified key, or if not found, returns the specified default value. |
java.lang.String |
getString(java.lang.String key)
Retrieves the String value of the property identified by the specified key. |
java.lang.String |
getString(java.lang.String key,
java.lang.String defaultValue)
Retrieves the String value of the property identified by the specified key, or if not found, returns the specified default value. |
protected static void |
throwRuntimeException(java.lang.Exception error)
Throws the specified exception as a RuntimeException. |
Methods inherited from class com.metamatrix.common.properties.TextManager |
---|
getText, getText, getText, getText, getText, getText, getText, getText, getText, getText, getText, getText, getText, getText, translate |
Methods inherited from class com.metamatrix.common.properties.PropertyManager |
---|
addNamespace, addNamespace, addNamespaces, addNamespaces, clearNamespaces, constructPropertyManager, get, getLoadedNamespaces, getNamespaces, initializeNamespaces, isNamespaceLoaded, isNamespaceRegistered, load, load, load, reload, reload, removeNamespace |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ObjectPropertyManager()
public ObjectPropertyManager(java.lang.String namespace)
namespace
- The namespace identifierpublic ObjectPropertyManager(java.lang.String[] namespaces)
namespaces
- The list of namespace identifierspublic ObjectPropertyManager(java.util.List namespaces)
namespaces
- The list of namespace identifierspublic ObjectPropertyManager(java.lang.String namespace, java.util.Map propertyMap)
namespace
- The namespace identifierpropertyMap
- The map into which the property values are loadedMethod Detail |
---|
protected static void assertClass(java.lang.String key, java.lang.Object value, java.lang.Class expectedClass)
key
- The key used to retrieve the valuevalue
- The value to verifyexpectedClass
- The class of which the value must be an instance
java.lang.ClassCastException
- If the value is not an instance of the specified class.protected static void throwRuntimeException(java.lang.Exception error)
error
- An exceptionprotected void constructObjectPropertyManager(java.util.List namespaces, java.util.Map propertyMap)
namespaces
- The list of namespace identifiers passed in the constructorpropertyMap
- The map into which the property values are loaded if a single namespace is specifiedprotected java.lang.Object evaluateValue(java.lang.String key, java.lang.String value)
PropertyManager
evaluateValue
in class PropertyManager
key
- The property's case-sensitive key; never null.
public boolean getBoolean(java.lang.String key)
key
- The property key
java.util.MissingResourceException
- If the value could not be foundpublic boolean getBoolean(java.lang.String key, boolean defaultValue)
key
- The property keydefaultValue
- The default value
public byte getByte(java.lang.String key)
key
- The property key
java.util.MissingResourceException
- If the value could not be foundpublic byte getByte(java.lang.String key, byte defaultValue)
key
- The property keydefaultValue
- The default value
public char getChar(java.lang.String key)
key
- The property key
java.util.MissingResourceException
- If the value could not be foundpublic char getChar(java.lang.String key, char defaultValue)
key
- The property keydefaultValue
- The default value
public double getDouble(java.lang.String key)
key
- The property key
java.util.MissingResourceException
- If the value could not be foundpublic double getDouble(java.lang.String key, double defaultValue)
key
- The property keydefaultValue
- The default value
public float getFloat(java.lang.String key)
key
- The property key
java.util.MissingResourceException
- If the value could not be foundpublic float getFloat(java.lang.String key, float defaultValue)
key
- The property keydefaultValue
- The default value
public int getInt(java.lang.String key)
key
- The property key
java.util.MissingResourceException
- If the value could not be foundpublic int getInt(java.lang.String key, int defaultValue)
key
- The property keydefaultValue
- The default value
public Interpreter getInterpreter()
public long getLong(java.lang.String key)
key
- The property key
java.util.MissingResourceException
- If the value could not be foundpublic long getLong(java.lang.String key, long defaultValue)
key
- The property keydefaultValue
- The default value
protected java.lang.Object getNonNullObject(java.lang.String key)
key
- The property key
java.util.MissingResourceException
- If the value could not be foundpublic short getShort(java.lang.String key)
key
- The property key
java.util.MissingResourceException
- If the value could not be foundpublic short getShort(java.lang.String key, short defaultValue)
key
- The property keydefaultValue
- The default value
public java.lang.String getString(java.lang.String key)
key
- The property key
public java.lang.String getString(java.lang.String key, java.lang.String defaultValue)
key
- The property keydefaultValue
- The default value
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |