public abstract class AbstractPropertyInvoker extends Object
AbstractPropertyInvoker
provides methods common to property
invokers.Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
AbstractPropertyInvoker() |
Modifier and Type | Method and Description |
---|---|
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.
|
protected static final Map<String,Map<String,Method[]>> PROPERTIES_CACHE
protected final org.apache.commons.logging.Log logger
protected Class<?> clazz
protected void initialize(Class<?> c, String domain)
c
- to read methods fromdomain
- optional domain that properties are inpublic void setProperty(Object object, String name, String value)
object
- Object
to invoke method onname
- String
property namevalue
- String
property valueIllegalArgumentException
- if an invocation exception occursprotected abstract Object convertValue(Class<?> type, String value)
type
- of object to convert value intovalue
- to parsepublic boolean hasProperty(String name)
name
- String
to checkboolean
whether the supplied property existspublic Set<String> getProperties()
Set
of property namespublic static <T> T instantiateType(T type, String className)
T
- type of class returnedtype
- of class to createclassName
- to createIllegalArgumentException
- if the supplied class name cannot create
a new instance of Tpublic static Class<?> createClass(String className)
className
- to createIllegalArgumentException
- if the supplied class name cannot be
createdpublic static Object invokeMethod(Method method, Object object, Object arg)
method
- Method
to invokeobject
- Object
to invoke method onarg
- Object
to invoke method withObject
produced by the invocationIllegalArgumentException
- if an error occurs invoking the methodCopyright © 2016. All rights reserved.