public class OgnlUtil extends Object
Constructor and Description |
---|
OgnlUtil()
Deprecated.
since 6.0.0. Use {@link #OgnlUtil(ExpressionCacheFactory, BeanInfoCacheFactory, OgnlGuard) instead.
|
OgnlUtil(ExpressionCacheFactory<String,Object> ognlExpressionCacheFactory,
BeanInfoCacheFactory<Class<?>,BeanInfo> ognlBeanInfoCacheFactory,
OgnlGuard ognlGuard)
Construct a new OgnlUtil instance for use with the framework, with optional cache factories for OGNL Expression
and BeanInfo caches.
|
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 resolver) |
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<String> |
getExcludedClasses()
Deprecated.
since 6.4.0, no replacement.
|
Set<String> |
getExcludedPackageExemptClasses()
Deprecated.
since 6.4.0, no replacement.
|
Set<Pattern> |
getExcludedPackageNamePatterns()
Deprecated.
since 6.4.0, no replacement.
|
Set<String> |
getExcludedPackageNames()
Deprecated.
since 6.4.0, no replacement.
|
PropertyDescriptor[] |
getPropertyDescriptors(Class<?> clazz)
Get's the java beans property descriptors for the given class.
|
PropertyDescriptor[] |
getPropertyDescriptors(Object source)
Gets 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 |
isDisallowDefaultPackageAccess()
Deprecated.
since 6.4.0, no replacement.
|
boolean |
isDisallowProxyMemberAccess()
Deprecated.
since 6.4.0, no replacement.
|
protected void |
setAllowStaticFieldAccess(String allowStaticFieldAccess)
Deprecated.
since 6.4.0, no replacement.
|
protected void |
setBeanInfoCacheMaxSize(String maxSize)
Deprecated.
since 6.4.0, changing maximum cache size after initialisation is not necessary.
|
protected void |
setContainer(Container container) |
protected void |
setDevMode(String mode) |
protected void |
setDevModeExcludedClasses(String commaDelimitedClasses)
Deprecated.
since 6.5.0, no replacement.
|
void |
setDevModeExcludedPackageExemptClasses(String commaDelimitedClasses)
Deprecated.
since 6.5.0, no replacement.
|
protected void |
setDevModeExcludedPackageNamePatterns(String commaDelimitedPackagePatterns)
Deprecated.
since 6.5.0, no replacement.
|
protected void |
setDevModeExcludedPackageNames(String commaDelimitedPackageNames)
Deprecated.
since 6.5.0, no replacement.
|
protected void |
setDisallowDefaultPackageAccess(String disallowDefaultPackageAccess)
Deprecated.
since 6.4.0, no replacement.
|
protected void |
setDisallowProxyMemberAccess(String disallowProxyMemberAccess)
Deprecated.
since 6.4.0, no replacement.
|
protected void |
setEnableEvalExpression(String evalExpression) |
protected void |
setEnableExpressionCache(String cache) |
protected void |
setExcludedClasses(String commaDelimitedClasses)
Deprecated.
since 6.4.0, no replacement.
|
void |
setExcludedPackageExemptClasses(String commaDelimitedClasses)
Deprecated.
since 6.4.0, no replacement.
|
protected void |
setExcludedPackageNamePatterns(String commaDelimitedPackagePatterns)
Deprecated.
since 6.4.0, no replacement.
|
protected void |
setExcludedPackageNames(String commaDelimitedPackageNames)
Deprecated.
since 6.4.0, no replacement.
|
protected void |
setExpressionCacheMaxSize(String maxSize)
Deprecated.
since 6.4.0, changing maximum cache size after initialisation is not necessary.
|
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
|
protected void |
setXWorkConverter(XWorkConverter conv) |
@Deprecated public OgnlUtil()
public OgnlUtil(ExpressionCacheFactory<String,Object> ognlExpressionCacheFactory, BeanInfoCacheFactory<Class<?>,BeanInfo> ognlBeanInfoCacheFactory, OgnlGuard ognlGuard)
ognlExpressionCacheFactory
- factory for Expression cache instanceognlBeanInfoCacheFactory
- factory for BeanInfo cache instanceognlGuard
- OGNL Guard instanceprotected void setXWorkConverter(XWorkConverter conv)
protected void setDevMode(String mode)
protected void setEnableExpressionCache(String cache)
@Deprecated protected void setExpressionCacheMaxSize(String maxSize)
@Deprecated protected void setBeanInfoCacheMaxSize(String maxSize)
protected void setEnableEvalExpression(String evalExpression)
@Deprecated protected void setExcludedClasses(String commaDelimitedClasses)
@Deprecated protected void setDevModeExcludedClasses(String commaDelimitedClasses)
@Deprecated protected void setExcludedPackageNamePatterns(String commaDelimitedPackagePatterns)
@Deprecated protected void setDevModeExcludedPackageNamePatterns(String commaDelimitedPackagePatterns)
@Deprecated protected void setExcludedPackageNames(String commaDelimitedPackageNames)
@Deprecated protected void setDevModeExcludedPackageNames(String commaDelimitedPackageNames)
@Deprecated public void setExcludedPackageExemptClasses(String commaDelimitedClasses)
@Deprecated public void setDevModeExcludedPackageExemptClasses(String commaDelimitedClasses)
@Deprecated public Set<String> getExcludedClasses()
@Deprecated public Set<Pattern> getExcludedPackageNamePatterns()
@Deprecated public Set<String> getExcludedPackageNames()
@Deprecated public Set<String> getExcludedPackageExemptClasses()
protected void setContainer(Container container)
@Deprecated protected void setAllowStaticFieldAccess(String allowStaticFieldAccess)
@Deprecated protected void setDisallowProxyMemberAccess(String disallowProxyMemberAccess)
@Deprecated protected void setDisallowDefaultPackageAccess(String disallowDefaultPackageAccess)
protected void applyExpressionMaxLength(String maxLength)
maxLength
- Injects the Struts OGNL expression maximum length.@Deprecated public boolean isDisallowProxyMemberAccess()
@Deprecated public boolean isDisallowDefaultPackageAccess()
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–2024 Apache Software Foundation. All rights reserved.