Package org.apache.struts2.ognl
Class OgnlReflectionProvider
java.lang.Object
org.apache.struts2.ognl.OgnlReflectionProvider
- All Implemented Interfaces:
ReflectionProvider
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcopy(Object from, Object to, Map<String, Object> context, Collection<String> exclusions, Collection<String> inclusions) Copies the properties in the object "from" and sets them in the object "to" using specified type converter, orXWorkConverterif none is specified.voidcopy(Object from, Object to, Map<String, Object> context, Collection<String> exclusions, Collection<String> inclusions, Class<?> editable) Copies the properties in the object "from" and sets them in the object "to" only setting properties defined in the given "editable" class (or interface) using specified type converter, orXWorkConverterif none is specified.getBeanMap(Object source) Creates a Map with read properties for the given source object.getGetMethod(Class targetClass, String propertyName) getPropertyDescriptor(Class targetClass, String propertyName) This method returns a PropertyDescriptor for the given class and property name using a Map lookup (using getPropertyDescriptorsMap()).getPropertyDescriptors(Object source) Get's the java beans property descriptors for the given source.Looks for the real target with the specified property given a root Object which may be a CompoundRoot.getSetMethod(Class targetClass, String propertyName) Evaluates the given OGNL expression to extract a value from the given root object in a given contextvoidsetOgnlUtil(OgnlUtil ognlUtil) voidsetProperties(Map<String, ?> properties, Object o) Sets the properties on the object using the default context, defaulting to not throwing exceptions for problems setting the properties.voidSets the object's properties using the default type converter, defaulting to not throw exceptions for problems setting the properties.voidsetProperties(Map<String, ?> props, Object o, Map<String, Object> context, boolean throwPropertyExceptions) Sets the object's properties using the default type converter.voidSets the named property to the supplied value on the Object, defaults to not throwing property exceptions.voidsetProperty(String name, Object value, Object o, Map<String, Object> context, boolean throwPropertyExceptions) Sets the named property to the supplied value on the Object,voidEvaluates the given OGNL expression to insert a value into the object graph rooted at the given root object given the context.
-
Constructor Details
-
OgnlReflectionProvider
public OgnlReflectionProvider()
-
-
Method Details
-
setOgnlUtil
-
getField
- Specified by:
getFieldin interfaceReflectionProvider
-
getGetMethod
public Method getGetMethod(Class targetClass, String propertyName) throws IntrospectionException, ReflectionException - Specified by:
getGetMethodin interfaceReflectionProvider- Throws:
IntrospectionExceptionReflectionException
-
getSetMethod
public Method getSetMethod(Class targetClass, String propertyName) throws IntrospectionException, ReflectionException - Specified by:
getSetMethodin interfaceReflectionProvider- Throws:
IntrospectionExceptionReflectionException
-
setProperties
Description copied from interface:ReflectionProviderSets the object's properties using the default type converter, defaulting to not throw exceptions for problems setting the properties.- Specified by:
setPropertiesin interfaceReflectionProvider- Parameters:
props- the properties being seto- the objectcontext- the action context
-
setProperties
public void setProperties(Map<String, ?> props, Object o, Map<String, throws ReflectionExceptionObject> context, boolean throwPropertyExceptions) Description copied from interface:ReflectionProviderSets the object's properties using the default type converter.- Specified by:
setPropertiesin interfaceReflectionProvider- Parameters:
props- the properties being seto- the objectcontext- the action contextthrowPropertyExceptions- boolean which tells whether it should throw exceptions for problems setting the properties- Throws:
ReflectionException
-
setProperties
Description copied from interface:ReflectionProviderSets the properties on the object using the default context, defaulting to not throwing exceptions for problems setting the properties.- Specified by:
setPropertiesin interfaceReflectionProvider- Parameters:
properties- property mapo- object
-
getPropertyDescriptor
public PropertyDescriptor getPropertyDescriptor(Class targetClass, String propertyName) throws IntrospectionException, ReflectionException Description copied from interface:ReflectionProviderThis method returns a PropertyDescriptor for the given class and property name using a Map lookup (using getPropertyDescriptorsMap()).- Specified by:
getPropertyDescriptorin interfaceReflectionProvider- Parameters:
targetClass- target class of the property descriptorpropertyName- property name- Returns:
- PropertyDescriptor for the given class and property name
- Throws:
IntrospectionException- in case of introspection errorReflectionException- in case of reflection problems
-
copy
public void copy(Object from, Object to, Map<String, Object> context, Collection<String> exclusions, Collection<String> inclusions) Description copied from interface:ReflectionProviderCopies the properties in the object "from" and sets them in the object "to" using specified type converter, orXWorkConverterif none is specified.- Specified by:
copyin interfaceReflectionProvider- Parameters:
from- the source objectto- the target objectcontext- the action context we're running underexclusions- 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.
-
copy
public void copy(Object from, Object to, Map<String, Object> context, Collection<String> exclusions, Collection<String> inclusions, Class<?> editable) Description copied from interface:ReflectionProviderCopies the properties in the object "from" and sets them in the object "to" only setting properties defined in the given "editable" class (or interface) using specified type converter, orXWorkConverterif none is specified.- Specified by:
copyin interfaceReflectionProvider- Parameters:
from- the source objectto- the target objectcontext- the action context we're running underexclusions- 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.editable- the class (or interface) to restrict property setting to
-
getRealTarget
public Object getRealTarget(String property, Map<String, Object> context, Object root) throws ReflectionExceptionDescription copied from interface:ReflectionProviderLooks for the real target with the specified property given a root Object which may be a CompoundRoot.- Specified by:
getRealTargetin interfaceReflectionProvider- Parameters:
property- specified propertycontext- the contextroot- the root object- Returns:
- the real target or null if no object can be found with the specified property
- Throws:
ReflectionException- in case of reflection problems
-
setProperty
Description copied from interface:ReflectionProviderSets the named property to the supplied value on the Object, defaults to not throwing property exceptions.- Specified by:
setPropertyin interfaceReflectionProvider- Parameters:
name- the name of the property to be setvalue- the value to set into the named propertyo- the object upon which to set the propertycontext- the context which may include the TypeConverter
-
setProperty
public void setProperty(String name, Object value, Object o, Map<String, Object> context, boolean throwPropertyExceptions) Description copied from interface:ReflectionProviderSets the named property to the supplied value on the Object,- Specified by:
setPropertyin interfaceReflectionProvider- Parameters:
name- the name of the property to be setvalue- the value to set into the named propertyo- the object upon which to set the propertycontext- the context which may include the TypeConverterthrowPropertyExceptions- boolean which tells whether it should throw exceptions for problems setting the properties
-
getBeanMap
Description copied from interface:ReflectionProviderCreates 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.- Specified by:
getBeanMapin interfaceReflectionProvider- 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
public Object getValue(String expression, Map<String, Object> context, Object root) throws ReflectionExceptionDescription copied from interface:ReflectionProviderEvaluates the given OGNL expression to extract a value from the given root object in a given context- Specified by:
getValuein interfaceReflectionProvider- Parameters:
expression- the OGNL expression to be parsedcontext- the naming context for the evaluationroot- the root object for the OGNL expression- Returns:
- the result of evaluating the expression
- Throws:
ReflectionException
-
setValue
public void setValue(String expression, Map<String, Object> context, Object root, Object value) throws ReflectionExceptionDescription copied from interface:ReflectionProviderEvaluates the given OGNL expression to insert a value into the object graph rooted at the given root object given the context.- Specified by:
setValuein interfaceReflectionProvider- Parameters:
expression- the OGNL expression to be parsedcontext- the naming context for the evaluationroot- the root object for the OGNL expressionvalue- the value to insert into the object graph- Throws:
ReflectionException
-
getPropertyDescriptors
Description copied from interface:ReflectionProviderGet's the java beans property descriptors for the given source.- Specified by:
getPropertyDescriptorsin interfaceReflectionProvider- Parameters:
source- the source object.- Returns:
- property descriptors.
- Throws:
IntrospectionException- is thrown if an exception occurs during introspection.
-