|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectncsa.tools.common.types.Configuration
Can be used in one of two ways. Either provides a dynamic set of name-value pairs which can be used to configure an object's "set" methods by reflection; or it carries definitions of properties to be used dynamically in connection with an operation, without their being directly associated with an object's accessor methods.
The principal data type added and stored is a Property; however, its subclass, ActualValueAttribute, can also be added directly.
The "match" operation only attempts to match names and string values, even on the ActualValueAttribute.
If a property name is in the configuration propertyObjectMap and matches an accessor method on the object to be configured, that object will be given the corresponding value for that field by first deserializing the string value.
A single configuration object can be re-used to configure more than one object. Care must be taken, however, to avoid re-use of the same Configuration across objects of different types when these have intersecting method names whose values need to be different, or where default values for those names should not be changed on one of the objects.
| Field Summary | |
static java.lang.String |
TAG_SELF
|
| Constructor Summary | |
Configuration()
Default constructor. |
|
Configuration(Configuration config)
Does a shallow copy of the configuration. |
|
| Method Summary | |
void |
addActualValueAttribute(ActualValueAttribute a)
|
void |
addActualValueAttribute(java.lang.String name,
java.lang.Object value)
|
Configuration |
addBooleanProperty(java.lang.String name,
boolean b)
|
void |
addConfiguredAttribute(Property p)
This code is for backwards compatibility with OGRE tags, where a Property is passed in as "attribute" without any type designation. |
Configuration |
addDoubleProperty(java.lang.String name,
double d)
|
Configuration |
addIntProperty(java.lang.String name,
int i)
|
Configuration |
addLongProperty(java.lang.String name,
long l)
|
void |
addProperty(Property p)
|
Configuration |
addProperty(java.lang.String name,
java.lang.String value)
|
Configuration |
addProperty(java.lang.String name,
java.lang.String value,
java.lang.String type)
|
Configuration |
addProperty(java.lang.String name,
java.lang.String value,
java.lang.String type,
java.lang.String category)
|
org.dom4j.Element |
asElement()
|
void |
clear()
|
void |
configureObject(java.lang.Object o)
Invokes the static method with configuration = this. |
static void |
configureObject(java.lang.Object o,
Configuration c)
Hashes the configuration object if its "dirty" flag is true, then uses ReflectUtils.getAttributes to get the public non-static single- parameter 'set' methods on the object to be configured; for each method whose name appears in the configuration propertyObjectMap, the method is invoked on the object using the mapped value. |
java.lang.Object |
getActualValue(java.lang.String name)
|
java.util.List |
getProperties()
|
Property |
getProperty(java.lang.String name)
|
java.util.Map |
getPropertyObjectMap()
|
java.lang.String |
getPropertyValue(java.lang.String name)
|
boolean |
hasMatch(java.lang.String name,
java.lang.String value,
boolean defaultValue)
|
boolean |
hasProperty(java.lang.String name)
|
void |
initializeFromElement(org.dom4j.Element element)
|
Configuration |
mergeWith(Configuration parent)
Union of parent with this object; values in this (child) shadow/overwrite identically named values in parent. |
java.util.Map |
nameValueObjectPairs()
|
java.util.Map |
nameValueStringPairs()
|
Configuration |
remove(Property p)
|
Property |
removeProperty(java.lang.String name)
|
Configuration |
setProperties(java.util.List l)
|
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final java.lang.String TAG_SELF
| Constructor Detail |
public Configuration()
public Configuration(Configuration config)
| Method Detail |
public void clear()
public org.dom4j.Element asElement()
asElement in interface UserFacingpublic java.lang.String toString()
public void initializeFromElement(org.dom4j.Element element)
initializeFromElement in interface UserFacingpublic void addConfiguredAttribute(Property p)
public void addActualValueAttribute(ActualValueAttribute a)
a - attribute to configure.
public void addActualValueAttribute(java.lang.String name,
java.lang.Object value)
name - of attribute to configure.value - of attribute to configure.public void addProperty(Property p)
public Configuration addProperty(java.lang.String name,
java.lang.String value)
public Configuration addBooleanProperty(java.lang.String name,
boolean b)
public Configuration addIntProperty(java.lang.String name,
int i)
public Configuration addLongProperty(java.lang.String name,
long l)
public Configuration addDoubleProperty(java.lang.String name,
double d)
public Configuration addProperty(java.lang.String name,
java.lang.String value,
java.lang.String type)
public Configuration addProperty(java.lang.String name,
java.lang.String value,
java.lang.String type,
java.lang.String category)
public Configuration remove(Property p)
public Property removeProperty(java.lang.String name)
public Configuration setProperties(java.util.List l)
public Property getProperty(java.lang.String name)
name - of property.
public java.lang.String getPropertyValue(java.lang.String name)
public java.lang.Object getActualValue(java.lang.String name)
public java.util.List getProperties()
public java.util.Map getPropertyObjectMap()
public boolean hasProperty(java.lang.String name)
name - of property.
public boolean hasMatch(java.lang.String name,
java.lang.String value,
boolean defaultValue)
name - of property.value - string value of property to match.defaultValue - to return if property is not in the propertyObjectMap.
public void configureObject(java.lang.Object o)
throws java.lang.Throwable
o - object whose attributes should be configured using this
configuration.
NCSAException - if reflection or invocation on the object fails.
java.lang.Throwablepublic Configuration mergeWith(Configuration parent)
parent -
public java.util.Map nameValueStringPairs()
public java.util.Map nameValueObjectPairs()
public static void configureObject(java.lang.Object o,
Configuration c)
throws java.lang.Throwable
If either object or configuration is null, the method is a NOP.
o - object whose attributes should be configured.c - to use in configuring the object.
NCSAException - if reflection or invocation on the object fails.
java.lang.ThrowableReflectUtils.getAttributes(java.lang.Class, boolean),
ReflectUtils.invokeOn(java.lang.String, java.lang.Object)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||