com.opensymphony.xwork2.util.reflection
Interface ReflectionProvider

All Known Implementing Classes:
OgnlReflectionProvider

public interface ReflectionProvider


Method Summary
 void copy(Object from, Object to, Map context, Collection exclusions, Collection inclusions)
          Copies the properties in the object "from" and sets them in the object "to" using specified type converter, or XWorkConverter if none is specified.
 Map getBeanMap(Object source)
          Creates a Map with read properties for the given source object.
 Field getField(Class inClass, String name)
           
 Method getGetMethod(Class targetClass, String propertyName)
           
 PropertyDescriptor getPropertyDescriptor(Class targetClass, String propertyName)
          This method returns a PropertyDescriptor for the given class and property name using a Map lookup (using getPropertyDescriptorsMap()).
 PropertyDescriptor[] getPropertyDescriptors(Object source)
          Get's the java beans property descriptors for the given source.
 Object getRealTarget(String property, Map context, Object root)
          Looks for the real target with the specified property given a root Object which may be a CompoundRoot.
 Method getSetMethod(Class targetClass, String propertyName)
           
 Object getValue(String expression, Map context, Object root)
          Evaluates the given OGNL expression to extract a value from the given root object in a given context
 void setProperties(Map properties, Object o)
          Sets the properties on the object using the default context, defaulting to not throwing exceptions for problems setting the properties.
 void setProperties(Map props, Object o, Map context)
          Sets the object's properties using the default type converter, defaulting to not throw exceptions for problems setting the properties.
 void setProperties(Map props, Object o, Map context, boolean throwPropertyExceptions)
          Sets the object's properties using the default type converter.
 void setProperty(String name, Object value, Object o, Map context)
          Sets the named property to the supplied value on the Object, defaults to not throwing property exceptions.
 void setValue(String expression, Map context, Object root, Object value)
          Evaluates the given OGNL expression to insert a value into the object graph rooted at the given root object given the context.
 

Method Detail

getGetMethod

Method getGetMethod(Class targetClass,
                    String propertyName)
                    throws IntrospectionException,
                           ReflectionException
Throws:
IntrospectionException
ReflectionException

getSetMethod

Method getSetMethod(Class targetClass,
                    String propertyName)
                    throws IntrospectionException,
                           ReflectionException
Throws:
IntrospectionException
ReflectionException

getField

Field getField(Class inClass,
               String name)

setProperties

void setProperties(Map props,
                   Object o,
                   Map context)
Sets the object's properties using the default type converter, defaulting to not throw exceptions for problems setting the properties.

Parameters:
props - the properties being set
o - the object
context - the action context

setProperties

void setProperties(Map props,
                   Object o,
                   Map context,
                   boolean throwPropertyExceptions)
Sets the object's properties using the default type converter.

Parameters:
props - the properties being set
o - the object
context - the action context
throwPropertyExceptions - boolean which tells whether it should throw exceptions for problems setting the properties

setProperties

void setProperties(Map properties,
                   Object o)
Sets the properties on the object using the default context, defaulting to not throwing exceptions for problems setting the properties.

Parameters:
properties -
o -

getPropertyDescriptor

PropertyDescriptor getPropertyDescriptor(Class targetClass,
                                         String propertyName)
                                         throws IntrospectionException,
                                                ReflectionException
This method returns a PropertyDescriptor for the given class and property name using a Map lookup (using getPropertyDescriptorsMap()).

Throws:
IntrospectionException
ReflectionException

copy

void copy(Object from,
          Object to,
          Map context,
          Collection exclusions,
          Collection inclusions)
Copies the properties in the object "from" and sets them in the object "to" using specified type converter, or XWorkConverter if none is specified.

Parameters:
from - the source object
to - the target object
context - the action context we're running under
exclusions - collection of method names to excluded from copying ( can be null)
inclusions - collection of method names to included copying (can be null) note if exclusions AND inclusions are supplied and not null nothing will get copied.

getRealTarget

Object getRealTarget(String property,
                     Map context,
                     Object root)
                     throws ReflectionException
Looks for the real target with the specified property given a root Object which may be a CompoundRoot.

Returns:
the real target or null if no object can be found with the specified property
Throws:
ReflectionException

setProperty

void setProperty(String name,
                 Object value,
                 Object o,
                 Map context)
Sets the named property to the supplied value on the Object, defaults to not throwing property exceptions.

Parameters:
name - the name of the property to be set
value - the value to set into the named property
o - the object upon which to set the property
context - the context which may include the TypeConverter

getBeanMap

Map getBeanMap(Object source)
               throws IntrospectionException,
                      ReflectionException
Creates a Map with read properties for the given source object.

If the source object does not have a read property (i.e. write-only) then the property is added to the map with the value here is no read method for property-name.

Parameters:
source - the source object.
Returns:
a Map with (key = read property name, value = value of read property).
Throws:
IntrospectionException - is thrown if an exception occurs during introspection.
ReflectionException

getValue

Object getValue(String expression,
                Map context,
                Object root)
                throws ReflectionException
Evaluates the given OGNL expression to extract a value from the given root object in a given context

Parameters:
expression - the OGNL expression to be parsed
context - the naming context for the evaluation
root - the root object for the OGNL expression
Returns:
the result of evaluating the expression
Throws:
ReflectionException

setValue

void setValue(String expression,
              Map context,
              Object root,
              Object value)
              throws ReflectionException
Evaluates the given OGNL expression to insert a value into the object graph rooted at the given root object given the context.

Parameters:
expression - the OGNL expression to be parsed
root - the root object for the OGNL expression
context - the naming context for the evaluation
value - the value to insert into the object graph
Throws:
ReflectionException

getPropertyDescriptors

PropertyDescriptor[] getPropertyDescriptors(Object source)
                                            throws IntrospectionException
Get's the java beans property descriptors for the given source.

Parameters:
source - the source object.
Returns:
property descriptors.
Throws:
IntrospectionException - is thrown if an exception occurs during introspection.


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.