|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.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).
Constructor Summary | |
---|---|
OgnlUtil()
|
Method Summary | |
---|---|
Object |
compile(String expression)
|
void |
copy(Object from,
Object to,
Map<String,Object> 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<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, 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<String,Object> context,
Object root)
Looks for the real target with the specified property given a root Object which may be a CompoundRoot. |
Object |
getValue(String name,
Map<String,Object> context,
Object root)
|
Object |
getValue(String name,
Map<String,Object> context,
Object root,
Class resultType)
|
static void |
setDevMode(String mode)
|
static void |
setEnableExpressionCache(String cache)
|
void |
setProperties(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. |
void |
setProperties(Map<String,?> properties,
Object o,
boolean throwPropertyExceptions)
Sets the properties on the object using the default context. |
void |
setProperties(Map<String,?> props,
Object o,
Map<String,Object> context)
Sets the object's properties using the default type converter, defaulting to not throw exceptions for problems setting the properties. |
void |
setProperties(Map<String,?> props,
Object o,
Map<String,Object> context,
boolean throwPropertyExceptions)
Sets the object's properties using the default type converter. |
void |
setProperty(String name,
Object value,
Object o,
Map<String,Object> 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<String,Object> context,
boolean throwPropertyExceptions)
Sets the named property to the supplied value on the Object. |
void |
setValue(String name,
Map<String,Object> 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 |
Constructor Detail |
---|
public OgnlUtil()
Method Detail |
---|
public void setXWorkConverter(XWorkConverter conv)
public static void setDevMode(String mode)
public static void setEnableExpressionCache(String cache)
public void setProperties(Map<String,?> props, Object o, Map<String,Object> context)
props
- the properties being seto
- the objectcontext
- the action contextpublic void setProperties(Map<String,?> props, Object o, Map<String,Object> context, boolean throwPropertyExceptions) throws ReflectionException
props
- the properties being seto
- the objectcontext
- the action contextthrowPropertyExceptions
- boolean which tells whether it should throw exceptions for
problems setting the properties
ReflectionException
public void setProperties(Map<String,?> properties, Object o)
properties
- o
- public void setProperties(Map<String,?> 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<String,Object> 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<String,Object> 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<String,Object> context, Object root) throws ognl.OgnlException
ognl.OgnlException
public void setValue(String name, Map<String,Object> context, Object root, Object value) throws ognl.OgnlException
ognl.OgnlException
public Object getValue(String name, Map<String,Object> context, Object root) throws ognl.OgnlException
ognl.OgnlException
public Object getValue(String name, Map<String,Object> 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<String,Object> context, Collection<String> exclusions, Collection<String> 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<String,Object> 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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |