edu.vt.middleware.ldap.props
Class AbstractPropertyInvoker

java.lang.Object
  extended by edu.vt.middleware.ldap.props.AbstractPropertyInvoker
Direct Known Subclasses:
LdapConfigPropertyInvoker, SimplePropertyInvoker

public abstract class AbstractPropertyInvoker
extends Object

AbstractPropertyInvoker provides methods common to property invokers.

Version:
$Revision: 1616 $ $Date: 2010-09-21 13:22:27 -0400 (Tue, 21 Sep 2010) $
Author:
Middleware Services

Field Summary
protected  Class<?> clazz
          Class to invoke methods on.
protected  org.apache.commons.logging.Log logger
          Log for this class.
protected  Map<String,Method[]> properties
          Map of all properties to their getter and setter methods.
protected static Map<String,Map<String,Method[]>> PROPERTIES_CACHE
          Cache of properties.
 
Constructor Summary
AbstractPropertyInvoker()
           
 
Method Summary
protected abstract  Object convertValue(Class<?> type, String value)
          This converts the supplied string value into an Object of the appropriate supplied type.
static Class<?> createClass(String className)
          Creates the class with the supplied name.
 Set<String> getProperties()
          This returns the property keys.
 boolean hasProperty(String name)
          This returns whether the supplied property exists.
protected  void initialize(Class<?> c, String domain)
          Initializes the properties map with the supplied class.
static
<T> T
instantiateType(T type, String className)
          Creates an instance of the supplied type.
static Object invokeMethod(Method method, Object object, Object arg)
          Invokes the supplied method on the supplied object with the supplied argument.
 void setProperty(Object object, String name, String value)
          This invokes the setter method for the supplied property name with the supplied value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTIES_CACHE

protected static final Map<String,Map<String,Method[]>> PROPERTIES_CACHE
Cache of properties.


logger

protected final org.apache.commons.logging.Log logger
Log for this class.


clazz

protected Class<?> clazz
Class to invoke methods on.


properties

protected Map<String,Method[]> properties
Map of all properties to their getter and setter methods.

Constructor Detail

AbstractPropertyInvoker

public AbstractPropertyInvoker()
Method Detail

initialize

protected void initialize(Class<?> c,
                          String domain)
Initializes the properties map with the supplied class.

Parameters:
c - to read methods from
domain - optional domain that properties are in

setProperty

public void setProperty(Object object,
                        String name,
                        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 - Object to invoke method on
name - String property name
value - String property value
Throws:
IllegalArgumentException - if an invocation exception occurs

convertValue

protected abstract Object convertValue(Class<?> type,
                                       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 into
value - to parse
Returns:
object of the supplied type

hasProperty

public boolean hasProperty(String name)
This returns whether the supplied property exists.

Parameters:
name - String to check
Returns:
boolean whether the supplied property exists

getProperties

public Set<String> getProperties()
This returns the property keys.

Returns:
Set of property names

instantiateType

public static <T> T instantiateType(T type,
                                    String className)
Creates an instance of the supplied type.

Type Parameters:
T - type of class returned
Parameters:
type - of class to create
className - to create
Returns:
class of type T
Throws:
IllegalArgumentException - if the supplied class name cannot create a new instance of T

createClass

public static Class<?> createClass(String className)
Creates the class with the supplied name.

Parameters:
className - to create
Returns:
class
Throws:
IllegalArgumentException - if the supplied class name cannot be created

invokeMethod

public static Object invokeMethod(Method method,
                                  Object object,
                                  Object arg)
Invokes the supplied method on the supplied object with the supplied argument.

Parameters:
method - Method to invoke
object - Object to invoke method on
arg - Object to invoke method with
Returns:
Object produced by the invocation
Throws:
IllegalArgumentException - if an error occurs invoking the method


Copyright © 2003-2010 Virginia Tech. All Rights Reserved.