Package edu.vt.middleware.ldap.props
Class AbstractPropertyInvoker
- java.lang.Object
-
- edu.vt.middleware.ldap.props.AbstractPropertyInvoker
-
- Direct Known Subclasses:
LdapConfigPropertyInvoker,SimplePropertyInvoker
public abstract class AbstractPropertyInvoker extends java.lang.ObjectAbstractPropertyInvokerprovides methods common to property invokers.- Version:
- $Revision: 1616 $ $Date: 2010-09-21 19:22:27 +0200 (Tue, 21 Sep 2010) $
- Author:
- Middleware Services
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Class<?>clazzClass to invoke methods on.protected org.apache.commons.logging.LogloggerLog for this class.protected java.util.Map<java.lang.String,java.lang.reflect.Method[]>propertiesMap of all properties to their getter and setter methods.protected static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.reflect.Method[]>>PROPERTIES_CACHECache of properties.
-
Constructor Summary
Constructors Constructor Description AbstractPropertyInvoker()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract java.lang.ObjectconvertValue(java.lang.Class<?> type, java.lang.String value)This converts the supplied string value into an Object of the appropriate supplied type.static java.lang.Class<?>createClass(java.lang.String className)Creates the class with the supplied name.java.util.Set<java.lang.String>getProperties()This returns the property keys.booleanhasProperty(java.lang.String name)This returns whether the supplied property exists.protected voidinitialize(java.lang.Class<?> c, java.lang.String domain)Initializes the properties map with the supplied class.static <T> TinstantiateType(T type, java.lang.String className)Creates an instance of the supplied type.static java.lang.ObjectinvokeMethod(java.lang.reflect.Method method, java.lang.Object object, java.lang.Object arg)Invokes the supplied method on the supplied object with the supplied argument.voidsetProperty(java.lang.Object object, java.lang.String name, java.lang.String value)This invokes the setter method for the supplied property name with the supplied value.
-
-
-
Field Detail
-
PROPERTIES_CACHE
protected static final java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.reflect.Method[]>> PROPERTIES_CACHE
Cache of properties.
-
logger
protected final org.apache.commons.logging.Log logger
Log for this class.
-
clazz
protected java.lang.Class<?> clazz
Class to invoke methods on.
-
properties
protected java.util.Map<java.lang.String,java.lang.reflect.Method[]> properties
Map of all properties to their getter and setter methods.
-
-
Method Detail
-
initialize
protected void initialize(java.lang.Class<?> c, java.lang.String domain)Initializes the properties map with the supplied class.- Parameters:
c- to read methods fromdomain- optional domain that properties are in
-
setProperty
public void setProperty(java.lang.Object object, java.lang.String name, java.lang.String value)This invokes the setter method for the supplied property name with the supplied value. If name or value is null, then this method does nothing.- Parameters:
object-Objectto invoke method onname-Stringproperty namevalue-Stringproperty value- Throws:
java.lang.IllegalArgumentException- if an invocation exception occurs
-
convertValue
protected abstract java.lang.Object convertValue(java.lang.Class<?> type, java.lang.String value)This converts the supplied string value into an Object of the appropriate supplied type. If value cannot be converted it is returned as is.- Parameters:
type- of object to convert value intovalue- to parse- Returns:
- object of the supplied type
-
hasProperty
public boolean hasProperty(java.lang.String name)
This returns whether the supplied property exists.- Parameters:
name-Stringto check- Returns:
booleanwhether the supplied property exists
-
getProperties
public java.util.Set<java.lang.String> getProperties()
This returns the property keys.- Returns:
Setof property names
-
instantiateType
public static <T> T instantiateType(T type, java.lang.String className)Creates an instance of the supplied type.- Type Parameters:
T- type of class returned- Parameters:
type- of class to createclassName- to create- Returns:
- class of type T
- Throws:
java.lang.IllegalArgumentException- if the supplied class name cannot create a new instance of T
-
createClass
public static java.lang.Class<?> createClass(java.lang.String className)
Creates the class with the supplied name.- Parameters:
className- to create- Returns:
- class
- Throws:
java.lang.IllegalArgumentException- if the supplied class name cannot be created
-
invokeMethod
public static java.lang.Object invokeMethod(java.lang.reflect.Method method, java.lang.Object object, java.lang.Object arg)Invokes the supplied method on the supplied object with the supplied argument.- Parameters:
method-Methodto invokeobject-Objectto invoke method onarg-Objectto invoke method with- Returns:
Objectproduced by the invocation- Throws:
java.lang.IllegalArgumentException- if an error occurs invoking the method
-
-