|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.opensymphony.xwork2.ognl.OgnlUtil
public class OgnlUtil
Utility class that provides common access to the Ognl APIs for setting and getting properties from objects (usually Actions).
Field Summary | |
---|---|
private ConcurrentHashMap<Class,BeanInfo> |
beanInfoCache
|
private ognl.TypeConverter |
defaultConverter
|
private ConcurrentHashMap<String,Object> |
expressions
|
private static Logger |
LOG
|
Constructor Summary | |
---|---|
OgnlUtil()
|
Method Summary | |
---|---|
Object |
compile(String expression)
|
void |
copy(Object from,
Object to,
Map context)
Copies the properties in the object "from" and sets them in the object "to" using specified type converter, or XWorkConverter if none
is specified. |
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. |
BeanInfo |
getBeanInfo(Class clazz)
Get's the java bean info for the given source. |
BeanInfo |
getBeanInfo(Object from)
Get's the java bean info for the given source object. |
Map |
getBeanMap(Object source)
Creates a Map with read properties for the given source object. |
PropertyDescriptor[] |
getPropertyDescriptors(Class clazz)
Get's the java beans property descriptors for the given class. |
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. |
(package private) ognl.TypeConverter |
getTypeConverterFromContext(Map context)
|
Object |
getValue(String name,
Map context,
Object root)
|
Object |
getValue(String name,
Map context,
Object root,
Class resultType)
|
(package private) void |
internalSetProperty(String name,
Object value,
Object o,
Map context,
boolean throwPropertyExceptions)
|
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 properties,
Object o,
boolean throwPropertyExceptions)
Sets the properties on the object using the default context. |
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 |
setProperty(String name,
Object value,
Object o,
Map context,
boolean throwPropertyExceptions)
Sets the named property to the supplied value on the Object. |
void |
setValue(String name,
Map context,
Object root,
Object value)
Wrapper around Ognl.setValue() to handle type conversion for collection elements. |
void |
setXWorkConverter(XWorkConverter conv)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Logger LOG
private ConcurrentHashMap<String,Object> expressions
private ConcurrentHashMap<Class,BeanInfo> beanInfoCache
private ognl.TypeConverter defaultConverter
Constructor Detail |
---|
public OgnlUtil()
Method Detail |
---|
public void setXWorkConverter(XWorkConverter conv)
public void setProperties(Map props, Object o, Map context)
props
- the properties being seto
- the objectcontext
- the action contextpublic void setProperties(Map props, Object o, Map context, boolean throwPropertyExceptions)
props
- the properties being seto
- the objectcontext
- the action contextthrowPropertyExceptions
- boolean which tells whether it should throw exceptions for
problems setting the propertiespublic void setProperties(Map properties, Object o)
properties
- o
- public void setProperties(Map properties, Object o, boolean throwPropertyExceptions)
properties
- the property map to set on the objecto
- the object to set the properties intothrowPropertyExceptions
- boolean which tells whether it should throw exceptions for
problems setting the propertiespublic void setProperty(String name, Object value, Object o, Map context)
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 TypeConverterpublic void setProperty(String name, Object value, Object o, Map context, boolean throwPropertyExceptions)
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 propertypublic Object getRealTarget(String property, Map context, Object root) throws ognl.OgnlException
ognl.OgnlException
public void setValue(String name, Map context, Object root, Object value) throws ognl.OgnlException
ognl.OgnlException
public Object getValue(String name, Map context, Object root) throws ognl.OgnlException
ognl.OgnlException
public Object getValue(String name, Map context, Object root, Class resultType) throws ognl.OgnlException
ognl.OgnlException
public Object compile(String expression) throws ognl.OgnlException
ognl.OgnlException
public void copy(Object from, Object to, Map context, Collection exclusions, Collection inclusions)
XWorkConverter
if none
is specified.
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.public void copy(Object from, Object to, Map context)
XWorkConverter
if none
is specified.
from
- the source objectto
- the target objectcontext
- the action context we're running underpublic PropertyDescriptor[] getPropertyDescriptors(Object source) throws IntrospectionException
source
- the source object.
IntrospectionException
- is thrown if an exception occurs during introspection.public PropertyDescriptor[] getPropertyDescriptors(Class clazz) throws IntrospectionException
clazz
- the source object.
IntrospectionException
- is thrown if an exception occurs during introspection.public Map getBeanMap(Object source) throws IntrospectionException, ognl.OgnlException
here is no read method for property-name
.
source
- the source object.
IntrospectionException
- is thrown if an exception occurs during introspection.
ognl.OgnlException
- is thrown by OGNL if the property value could not be retrievedpublic BeanInfo getBeanInfo(Object from) throws IntrospectionException
from
- the source object.
IntrospectionException
- is thrown if an exception occurs during introspection.public BeanInfo getBeanInfo(Class clazz) throws IntrospectionException
clazz
- the source class.
IntrospectionException
- is thrown if an exception occurs during introspection.void internalSetProperty(String name, Object value, Object o, Map context, boolean throwPropertyExceptions)
ognl.TypeConverter getTypeConverterFromContext(Map context)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |