|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.opensymphony.xwork2.ognl.OgnlValueStack
public class OgnlValueStack
Ognl implementation of a value stack that allows for dynamic Ognl expressions to be evaluated against it. When evaluating an expression, the stack will be searched down the stack, from the latest objects pushed in to the earliest, looking for a bean with a getter or setter for the given property or a method of the given name (depending on the expression being evaluated).
Field Summary | |
---|---|
(package private) Map<String,Object> |
context
|
(package private) Class |
defaultType
|
private boolean |
devMode
|
private static Logger |
LOG
|
private boolean |
logMissingProperties
|
private static String |
MAP_IDENTIFIER_KEY
|
(package private) OgnlUtil |
ognlUtil
|
(package private) Map<Object,Object> |
overrides
|
(package private) CompoundRoot |
root
|
(package private) SecurityMemberAccess |
securityMemberAccess
|
private static long |
serialVersionUID
|
static String |
THROW_EXCEPTION_ON_FAILURE
|
Fields inherited from interface com.opensymphony.xwork2.util.ValueStack |
---|
REPORT_ERRORS_ON_NO_PROP, VALUE_STACK |
Constructor Summary | |
---|---|
protected |
OgnlValueStack(ValueStack vs,
XWorkConverter xworkConverter,
CompoundRootAccessor accessor,
boolean allowStaticAccess)
|
protected |
OgnlValueStack(XWorkConverter xworkConverter,
CompoundRootAccessor accessor,
TextProvider prov,
boolean allowStaticAccess)
|
Method Summary | |
---|---|
private void |
cleanUpContext(Map<String,Object> context)
|
void |
clearContextValues()
Remove all values from the context |
private Object |
findInContext(String name)
|
String |
findString(String expr)
|
String |
findString(String expr,
boolean throwExceptionOnFailure)
|
Object |
findValue(String expr)
Find a value by evaluating the given expression against the stack in the default search order. |
Object |
findValue(String expr,
boolean throwExceptionOnFailure)
|
Object |
findValue(String expr,
Class asType)
Find a value by evaluating the given expression against the stack in the default search order. |
Object |
findValue(String expr,
Class asType,
boolean throwExceptionOnFailure)
|
Map<String,Object> |
getContext()
Gets the context for this value stack. |
Map<Object,Object> |
getExprOverrides()
Gets the override map if anyone exists. |
CompoundRoot |
getRoot()
Get the CompoundRoot which holds the objects pushed onto the stack |
private Object |
getValue(String expr,
Class asType)
|
private Object |
getValueUsingOgnl(String expr)
|
private Object |
handleOgnlException(String expr,
boolean throwExceptionOnFailure,
ognl.OgnlException e)
|
private void |
handleOgnlException(String expr,
Object value,
boolean throwExceptionOnFailure,
ognl.OgnlException e)
|
private Object |
handleOtherException(String expr,
boolean throwExceptionOnFailure,
Exception e)
|
private void |
handleRuntimeException(String expr,
Object value,
boolean throwExceptionOnFailure,
RuntimeException re)
|
private void |
logLookupFailure(String expr,
Exception e)
Log a failed lookup, being more verbose when devMode=true. |
private String |
lookupForOverrides(String expr)
|
Object |
peek()
Get the object on the top of the stack without changing the stack. |
Object |
pop()
Get the object on the top of the stack and remove it from the stack. |
void |
push(Object o)
Put this object onto the top of the stack |
private Object |
readResolve()
|
private Map |
retrieveSetMap()
|
void |
set(String key,
Object o)
Sets an object on the stack with the given key so it is retrievable by ValueStack.findValue(String) , ValueStack.findValue(String, Class) |
void |
setAcceptProperties(Set<Pattern> acceptedProperties)
|
void |
setDefaultType(Class defaultType)
Sets the default type to convert to if no type is provided when getting a value. |
void |
setDevMode(String mode)
|
void |
setExcludeProperties(Set<Pattern> excludeProperties)
|
void |
setExprOverrides(Map<Object,Object> overrides)
Set a override map containing key -> values that takes precedent when doing find operations on the ValueStack. |
void |
setLogMissingProperties(String logMissingProperties)
|
void |
setOgnlUtil(OgnlUtil ognlUtil)
|
protected void |
setRoot(XWorkConverter xworkConverter,
CompoundRootAccessor accessor,
CompoundRoot compoundRoot,
boolean allowStaticMethodAccess)
|
private void |
setupExceptionOnFailure(boolean throwExceptionOnFailure)
|
void |
setValue(String expr,
Object value)
Attempts to set a property on a bean in the stack with the given expression using the default search order. |
void |
setValue(String expr,
Object value,
boolean throwExceptionOnFailure)
Attempts to set a property on a bean in the stack with the given expression using the default search order. |
private boolean |
shouldLogNoSuchPropertyWarning(ognl.OgnlException e)
|
private boolean |
shouldUseOldMap(Object topObj)
check if this is a Map put on the stack for setting if so just use the old map (reduces waste) |
int |
size()
Get the number of objects in the stack |
private Object |
tryFindValue(String expr)
|
private Object |
tryFindValue(String expr,
Class asType)
|
private Object |
tryFindValueWhenExpressionIsNotNull(String expr)
|
private Object |
tryFindValueWhenExpressionIsNotNull(String expr,
Class asType)
|
private void |
trySetValue(String expr,
Object value,
boolean throwExceptionOnFailure,
Map<String,Object> context)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String THROW_EXCEPTION_ON_FAILURE
private static final long serialVersionUID
private static final String MAP_IDENTIFIER_KEY
private static final Logger LOG
CompoundRoot root
transient Map<String,Object> context
Class defaultType
Map<Object,Object> overrides
transient OgnlUtil ognlUtil
transient SecurityMemberAccess securityMemberAccess
private boolean devMode
private boolean logMissingProperties
Constructor Detail |
---|
protected OgnlValueStack(XWorkConverter xworkConverter, CompoundRootAccessor accessor, TextProvider prov, boolean allowStaticAccess)
protected OgnlValueStack(ValueStack vs, XWorkConverter xworkConverter, CompoundRootAccessor accessor, boolean allowStaticAccess)
Method Detail |
---|
public void setOgnlUtil(OgnlUtil ognlUtil)
protected void setRoot(XWorkConverter xworkConverter, CompoundRootAccessor accessor, CompoundRoot compoundRoot, boolean allowStaticMethodAccess)
public void setDevMode(String mode)
public void setLogMissingProperties(String logMissingProperties)
public Map<String,Object> getContext()
ValueStack
getContext
in interface ValueStack
ValueStack.getContext()
public void setDefaultType(Class defaultType)
ValueStack
setDefaultType
in interface ValueStack
defaultType
- the new default typeValueStack.setDefaultType(java.lang.Class)
public void setExprOverrides(Map<Object,Object> overrides)
ValueStack
key -> values
that takes precedent when doing find operations on the ValueStack.
See the unit test for ValueStackTest for examples.
setExprOverrides
in interface ValueStack
overrides
- overrides map.ValueStack.setExprOverrides(java.util.Map)
public Map<Object,Object> getExprOverrides()
ValueStack
getExprOverrides
in interface ValueStack
ValueStack.getExprOverrides()
public CompoundRoot getRoot()
ValueStack
getRoot
in interface ValueStack
ValueStack.getRoot()
public void setValue(String expr, Object value)
ValueStack
setValue
in interface ValueStack
expr
- the expression defining the path to the property to be set.value
- the value to be set into the named propertyValueStack.setValue(java.lang.String, java.lang.Object)
public void setValue(String expr, Object value, boolean throwExceptionOnFailure)
ValueStack
setValue
in interface ValueStack
expr
- the expression defining the path to the property to be set.value
- the value to be set into the named propertythrowExceptionOnFailure
- a flag to tell whether an exception should be thrown if there is no property with
the given name.ValueStack.setValue(java.lang.String, java.lang.Object, boolean)
private void trySetValue(String expr, Object value, boolean throwExceptionOnFailure, Map<String,Object> context) throws ognl.OgnlException
ognl.OgnlException
private void cleanUpContext(Map<String,Object> context)
private void handleRuntimeException(String expr, Object value, boolean throwExceptionOnFailure, RuntimeException re)
private void handleOgnlException(String expr, Object value, boolean throwExceptionOnFailure, ognl.OgnlException e)
public String findString(String expr)
findString
in interface ValueStack
ValueStack.findString(java.lang.String)
public String findString(String expr, boolean throwExceptionOnFailure)
findString
in interface ValueStack
public Object findValue(String expr, boolean throwExceptionOnFailure)
findValue
in interface ValueStack
ValueStack.findValue(java.lang.String)
private void setupExceptionOnFailure(boolean throwExceptionOnFailure)
private Object tryFindValueWhenExpressionIsNotNull(String expr) throws ognl.OgnlException
ognl.OgnlException
private Object handleOtherException(String expr, boolean throwExceptionOnFailure, Exception e)
private Object tryFindValue(String expr) throws ognl.OgnlException
ognl.OgnlException
private String lookupForOverrides(String expr)
private Object getValueUsingOgnl(String expr) throws ognl.OgnlException
ognl.OgnlException
public Object findValue(String expr)
ValueStack
findValue
in interface ValueStack
expr
- the expression giving the path of properties to navigate to find the property value to return
public Object findValue(String expr, Class asType, boolean throwExceptionOnFailure)
findValue
in interface ValueStack
ValueStack.findValue(java.lang.String, java.lang.Class)
private Object tryFindValueWhenExpressionIsNotNull(String expr, Class asType) throws ognl.OgnlException
ognl.OgnlException
private Object handleOgnlException(String expr, boolean throwExceptionOnFailure, ognl.OgnlException e)
private boolean shouldLogNoSuchPropertyWarning(ognl.OgnlException e)
private Object tryFindValue(String expr, Class asType) throws ognl.OgnlException
ognl.OgnlException
private Object getValue(String expr, Class asType) throws ognl.OgnlException
ognl.OgnlException
private Object findInContext(String name)
public Object findValue(String expr, Class asType)
ValueStack
findValue
in interface ValueStack
expr
- the expression giving the path of properties to navigate to find the property value to returnasType
- the type to convert the return value to
private void logLookupFailure(String expr, Exception e)
expr
- The failed expressione
- The thrown exception.public Object peek()
ValueStack
peek
in interface ValueStack
ValueStack.peek()
public Object pop()
ValueStack
pop
in interface ValueStack
ValueStack.pop()
public void push(Object o)
ValueStack
push
in interface ValueStack
o
- the object to be pushed onto the stackValueStack.push(java.lang.Object)
public void set(String key, Object o)
ValueStack
ValueStack.findValue(String)
, ValueStack.findValue(String, Class)
set
in interface ValueStack
key
- the keyo
- the objectValueStack.set(java.lang.String, java.lang.Object)
private Map retrieveSetMap()
private boolean shouldUseOldMap(Object topObj)
public int size()
ValueStack
size
in interface ValueStack
ValueStack.size()
private Object readResolve()
public void clearContextValues()
ClearableValueStack
clearContextValues
in interface ClearableValueStack
public void setAcceptProperties(Set<Pattern> acceptedProperties)
setAcceptProperties
in interface MemberAccessValueStack
public void setExcludeProperties(Set<Pattern> excludeProperties)
setExcludeProperties
in interface MemberAccessValueStack
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |