Package org.apache.struts2.ognl
Class OgnlValueStack
java.lang.Object
org.apache.struts2.ognl.OgnlValueStack
- All Implemented Interfaces:
- Serializable,- ClearableValueStack,- MemberAccessValueStack,- ValueStack
public class OgnlValueStack
extends Object
implements Serializable, ValueStack, ClearableValueStack, MemberAccessValueStack
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).
- Version:
- $Date$ $Id$
- Author:
- Patrick Lightbody, tm_jee
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected Classprotected OgnlUtilprotected CompoundRootprotected SecurityMemberAccessstatic final StringFields inherited from interface org.apache.struts2.util.ValueStackREPORT_ERRORS_ON_NO_PROP, VALUE_STACK
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedOgnlValueStack(XWorkConverter xworkConverter, RootAccessor accessor, TextProvider prov, SecurityMemberAccess securityMemberAccess) protectedOgnlValueStack(ValueStack vs, XWorkConverter xworkConverter, RootAccessor accessor, SecurityMemberAccess securityMemberAccess) protectedOgnlValueStack(ValueStack vs, XWorkConverter xworkConverter, RootAccessor accessor, TextProvider prov, SecurityMemberAccess securityMemberAccess) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidRemove all values from the contextprotected ObjectfindInContext(String name) findString(String expr) findString(String expr, boolean throwExceptionOnFailure) Find a value by evaluating the given expression against the stack in the default search order.Find a value by evaluating the given expression against the stack in the default search order.Gets the context for this value stack.Gets the override map if anyone exists.getRoot()Get the CompoundRoot which holds the objects pushed onto the stackprotected ObjecthandleOgnlException(String expr, boolean throwExceptionOnFailure, ognl.OgnlException e) protected voidhandleOgnlException(String expr, Object value, boolean throwExceptionOnFailure, ognl.OgnlException e) protected ObjecthandleOtherException(String expr, boolean throwExceptionOnFailure, Exception e) protected voidhandleRuntimeException(String expr, Object value, boolean throwExceptionOnFailure, RuntimeException re) peek()Get the object on the top of the stack without changing the stack.pop()Get the object on the top of the stack and remove it from the stack.voidPut this object onto the top of the stackvoidSets an object on the stack with the given key so it is retrievable byValueStack.findValue(String),ValueStack.findValue(String, Class)voidsetDefaultType(Class defaultType) Sets the default type to convert to if no type is provided when getting a value.protected voidsetDevMode(String mode) voidsetExprOverrides(Map<Object, Object> overrides) Set a override map containingkey -> valuesthat takes precedent when doing find operations on the ValueStack.protected voidsetLogMissingProperties(String logMissingProperties) protected voidsetOgnlUtil(OgnlUtil ognlUtil) voidsetParameter(String expr, Object value) Attempts to set a property on a bean in the stack with the given expression using the default search order.protected voidsetRoot(XWorkConverter xworkConverter, RootAccessor accessor, CompoundRoot compoundRoot, SecurityMemberAccess securityMemberAccess) protected voidsetShouldFallbackToContext(String shouldFallbackToContext) protected voidsetupExceptionOnFailure(boolean throwExceptionOnFailure) voidAttempts to set a property on a bean in the stack with the given expression using the default search order.voidAttempts to set a property on a bean in the stack with the given expression using the default search order.protected booleanshouldLogMissingPropertyWarning(ognl.OgnlException e) intsize()Get the number of objects in the stackvoiduseAcceptProperties(Set<Pattern> acceptedProperties) voiduseExcludeProperties(Set<Pattern> excludeProperties) 
- 
Field Details- 
THROW_EXCEPTION_ON_FAILURE
- 
root
- 
context
- 
defaultType
- 
overrides
- 
ognlUtil
- 
securityMemberAccess
 
- 
- 
Constructor Details- 
OgnlValueStackprotected OgnlValueStack(ValueStack vs, XWorkConverter xworkConverter, RootAccessor accessor, TextProvider prov, SecurityMemberAccess securityMemberAccess) - Since:
- 6.4.0
 
- 
OgnlValueStackprotected OgnlValueStack(XWorkConverter xworkConverter, RootAccessor accessor, TextProvider prov, SecurityMemberAccess securityMemberAccess) - Since:
- 6.4.0
 
- 
OgnlValueStackprotected OgnlValueStack(ValueStack vs, XWorkConverter xworkConverter, RootAccessor accessor, SecurityMemberAccess securityMemberAccess) - Since:
- 6.4.0
 
 
- 
- 
Method Details- 
setOgnlUtil
- 
setRootprotected void setRoot(XWorkConverter xworkConverter, RootAccessor accessor, CompoundRoot compoundRoot, SecurityMemberAccess securityMemberAccess) - Since:
- 6.4.0
 
- 
setDevMode
- 
setLogMissingProperties
- 
setShouldFallbackToContext
- 
getContextDescription copied from interface:ValueStackGets the context for this value stack. The context holds all the information in the value stack and it's surroundings.- Specified by:
- getContextin interface- ValueStack
- Returns:
- the context.
- See Also:
 
- 
getActionContext- Specified by:
- getActionContextin interface- ValueStack
 
- 
setDefaultTypeDescription copied from interface:ValueStackSets the default type to convert to if no type is provided when getting a value.- Specified by:
- setDefaultTypein interface- ValueStack
- Parameters:
- defaultType- the new default type
- See Also:
 
- 
setExprOverridesDescription copied from interface:ValueStackSet a override map containingkey -> valuesthat takes precedent when doing find operations on the ValueStack.See the unit test for ValueStackTest for examples. - Specified by:
- setExprOverridesin interface- ValueStack
- Parameters:
- overrides- overrides map.
- See Also:
 
- 
getExprOverridesDescription copied from interface:ValueStackGets the override map if anyone exists.- Specified by:
- getExprOverridesin interface- ValueStack
- Returns:
- the override map, null if not set.
- See Also:
 
- 
getRootDescription copied from interface:ValueStackGet the CompoundRoot which holds the objects pushed onto the stack- Specified by:
- getRootin interface- ValueStack
- Returns:
- the root
- See Also:
 
- 
setParameterDescription copied from interface:ValueStackAttempts to set a property on a bean in the stack with the given expression using the default search order. N.B.: unlike #setValue(String,Object) it doesn't allow eval expression.- Specified by:
- setParameterin interface- ValueStack
- Parameters:
- expr- the expression defining the path to the property to be set.
- value- the value to be set into the named property
- See Also:
 
- 
setValueDescription copied from interface:ValueStackAttempts to set a property on a bean in the stack with the given expression using the default search order.- Specified by:
- setValuein interface- ValueStack
- Parameters:
- expr- the expression defining the path to the property to be set.
- value- the value to be set into the named property
- See Also:
 
- 
setValueDescription copied from interface:ValueStackAttempts to set a property on a bean in the stack with the given expression using the default search order.- Specified by:
- setValuein interface- ValueStack
- Parameters:
- expr- the expression defining the path to the property to be set.
- value- the value to be set into the named property
- throwExceptionOnFailure- a flag to tell whether an exception should be thrown if there is no property with the given name.
- See Also:
 
- 
handleRuntimeExceptionprotected void handleRuntimeException(String expr, Object value, boolean throwExceptionOnFailure, RuntimeException re) 
- 
handleOgnlException
- 
findString- Specified by:
- findStringin interface- ValueStack
- See Also:
 
- 
findString- Specified by:
- findStringin interface- ValueStack
 
- 
findValue- Specified by:
- findValuein interface- ValueStack
- See Also:
 
- 
setupExceptionOnFailureprotected void setupExceptionOnFailure(boolean throwExceptionOnFailure) 
- 
handleOtherException
- 
findValueDescription copied from interface:ValueStackFind a value by evaluating the given expression against the stack in the default search order.- Specified by:
- findValuein interface- ValueStack
- Parameters:
- expr- the expression giving the path of properties to navigate to find the property value to return
- Returns:
- the result of evaluating the expression
 
- 
findValue- Specified by:
- findValuein interface- ValueStack
- See Also:
 
- 
handleOgnlException
- 
shouldLogMissingPropertyWarningprotected boolean shouldLogMissingPropertyWarning(ognl.OgnlException e) 
- 
findInContext
- 
findValueDescription copied from interface:ValueStackFind a value by evaluating the given expression against the stack in the default search order.- Specified by:
- findValuein interface- ValueStack
- Parameters:
- expr- the expression giving the path of properties to navigate to find the property value to return
- asType- the type to convert the return value to
- Returns:
- the result of evaluating the expression
 
- 
peekDescription copied from interface:ValueStackGet the object on the top of the stack without changing the stack.- Specified by:
- peekin interface- ValueStack
- Returns:
- the object on the top.
- See Also:
 
- 
popDescription copied from interface:ValueStackGet the object on the top of the stack and remove it from the stack.- Specified by:
- popin interface- ValueStack
- Returns:
- the object on the top of the stack
- See Also:
 
- 
pushDescription copied from interface:ValueStackPut this object onto the top of the stack- Specified by:
- pushin interface- ValueStack
- Parameters:
- o- the object to be pushed onto the stack
- See Also:
 
- 
setDescription copied from interface:ValueStackSets an object on the stack with the given key so it is retrievable byValueStack.findValue(String),ValueStack.findValue(String, Class)- Specified by:
- setin interface- ValueStack
- Parameters:
- key- the key
- o- the object
- See Also:
 
- 
sizepublic int size()Description copied from interface:ValueStackGet the number of objects in the stack- Specified by:
- sizein interface- ValueStack
- Returns:
- the number of objects in the stack
- See Also:
 
- 
clearContextValuespublic void clearContextValues()Description copied from interface:ClearableValueStackRemove all values from the context- Specified by:
- clearContextValuesin interface- ClearableValueStack
 
- 
useAcceptProperties- Specified by:
- useAcceptPropertiesin interface- MemberAccessValueStack
 
- 
useExcludeProperties- Specified by:
- useExcludePropertiesin interface- MemberAccessValueStack
 
 
-