public class OgnlUtil extends Object
Constructor and Description |
---|
OgnlUtil() |
Modifier and Type | Method and Description |
---|---|
protected void |
applyExpressionMaxLength(String maxLength) |
int |
beanInfoCacheSize()
Check the size of the BeanInfo cache (current number of elements).
|
Object |
callMethod(String name,
Map<String,Object> context,
Object root) |
void |
clearBeanInfoCache()
Provide a mechanism to clear the BeanInfo cache.
|
void |
clearExpressionCache()
Provide a mechanism to clear the OGNL expression cache.
|
static void |
clearRuntimeCache()
Convenience mechanism to clear the OGNL Runtime Cache via OgnlUtil.
|
Object |
compile(String expression) |
Object |
compile(String expression,
Map<String,Object> context) |
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. |
void |
copy(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, or
XWorkConverter if none
is specified. |
protected Map<String,Object> |
createDefaultContext(Object root) |
protected Map<String,Object> |
createDefaultContext(Object root,
ognl.ClassResolver classResolver) |
int |
expressionCacheSize()
Check the size of the expression cache (current number of elements).
|
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<String,Object> |
getBeanMap(Object source)
Creates a Map with read properties for the given source object.
|
Set<Class<?>> |
getExcludedClasses() |
Set<Pattern> |
getExcludedPackageNamePatterns() |
Set<String> |
getExcludedPackageNames() |
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) |
boolean |
isDisallowProxyMemberAccess() |
protected void |
setAllowStaticFieldAccess(String allowStaticFieldAccess) |
protected void |
setAllowStaticMethodAccess(String allowStaticMethodAccess) |
protected void |
setContainer(Container container) |
protected void |
setDevMode(String mode) |
protected void |
setDevModeExcludedClasses(String commaDelimitedClasses) |
protected void |
setDevModeExcludedPackageNamePatterns(String commaDelimitedPackagePatterns) |
protected void |
setDevModeExcludedPackageNames(String commaDelimitedPackageNames) |
protected void |
setDisallowProxyMemberAccess(String disallowProxyMemberAccess) |
protected void |
setEnableEvalExpression(String evalExpression) |
protected void |
setEnableExpressionCache(String cache) |
protected void |
setExcludedClasses(String commaDelimitedClasses) |
protected void |
setExcludedPackageNamePatterns(String commaDelimitedPackagePatterns) |
protected void |
setExcludedPackageNames(String commaDelimitedPackageNames) |
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.
|
protected void |
setXWorkConverter(XWorkConverter conv) |
protected void setXWorkConverter(XWorkConverter conv)
protected void setDevMode(String mode)
protected void setEnableExpressionCache(String cache)
protected void setEnableEvalExpression(String evalExpression)
protected void setExcludedClasses(String commaDelimitedClasses)
protected void setDevModeExcludedClasses(String commaDelimitedClasses)
protected void setExcludedPackageNamePatterns(String commaDelimitedPackagePatterns)
protected void setDevModeExcludedPackageNamePatterns(String commaDelimitedPackagePatterns)
protected void setExcludedPackageNames(String commaDelimitedPackageNames)
protected void setDevModeExcludedPackageNames(String commaDelimitedPackageNames)
protected void setContainer(Container container)
protected void setAllowStaticFieldAccess(String allowStaticFieldAccess)
protected void setAllowStaticMethodAccess(String allowStaticMethodAccess)
protected void setDisallowProxyMemberAccess(String disallowProxyMemberAccess)
protected void applyExpressionMaxLength(String maxLength)
maxLength
- Injects the Struts OGNL expression maximum length.public boolean isDisallowProxyMemberAccess()
public static void clearRuntimeCache()
OgnlRuntime.clearCache()
for details.
Warning: Frequent calling if this method may negatively impact performance, but may be required
to avoid memory exhaustion (resource leak) with too many OGNL expressions being cached.public void clearExpressionCache()
public int expressionCacheSize()
public void clearBeanInfoCache()
public int beanInfoCacheSize()
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 propertiesReflectionException
public void setProperties(Map<String,?> properties, Object o)
properties
- map of propertieso
- objectpublic 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
property
- the propertycontext
- context maproot
- compound rootognl.OgnlException
- in case of ognl errorspublic void setValue(String name, Map<String,Object> context, Object root, Object value) throws ognl.OgnlException
name
- the namecontext
- context maproot
- rootvalue
- valueognl.OgnlException
- in case of ognl errorspublic Object getValue(String name, Map<String,Object> context, Object root) throws ognl.OgnlException
ognl.OgnlException
public Object callMethod(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 Object compile(String expression, Map<String,Object> context) 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, Collection<String> exclusions, Collection<String> inclusions, Class<?> editable)
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.editable
- the class (or interface) to restrict property setting topublic 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<String,Object> getBeanMap(Object source) throws IntrospectionException, ognl.OgnlException
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
.
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.Copyright © 2000–2020 Apache Software Foundation. All rights reserved.