|
||||||||||
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 |
context
|
(package private) Class |
defaultType
|
private boolean |
devMode
|
private static Logger |
LOG
|
private static String |
MAP_IDENTIFIER_KEY
|
(package private) OgnlUtil |
ognlUtil
|
(package private) Map |
overrides
|
(package private) CompoundRoot |
root
|
private static long |
serialVersionUID
|
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 |
checkForInvalidProperties(String expr)
This method looks for matching methods/properties in an action to warn the user if they specified a property that doesn't exist. |
private void |
findAvailableProperties(Class c,
String expr,
Set availableProperties,
String parent)
Look for available properties on an existing class. |
private Object |
findInContext(String name)
|
String |
findString(String expr)
|
Object |
findValue(String expr)
Find a value by evaluating the given expression against the stack in the default search order. |
Object |
findValue(String expr,
Class asType)
Find a value by evaluating the given expression against the stack in the default search order. |
Map |
getContext()
Gets the context for this value stack. |
Map |
getExprOverrides()
Gets the override map if anyone exists. |
CompoundRoot |
getRoot()
Get the CompoundRoot which holds the objects pushed onto the stack |
static void |
link(Map context,
Class clazz,
String name)
|
private void |
logLookupFailure(String expr,
Exception e)
Log a failed lookup, being more verbose when devMode=true. |
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()
|
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 |
setDefaultType(Class defaultType)
Sets the default type to convert to if no type is provided when getting a value. |
void |
setDevMode(String mode)
|
void |
setExprOverrides(Map overrides)
Set a override map containing key -> values that takes precedent when doing find operations on the ValueStack. |
void |
setOgnlUtil(OgnlUtil ognlUtil)
|
protected void |
setRoot(XWorkConverter xworkConverter,
CompoundRootAccessor accessor,
CompoundRoot compoundRoot,
boolean allowStaticMethodAccess)
|
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. |
int |
size()
Get the number of objects in the stack |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
private static Logger LOG
private boolean devMode
CompoundRoot root
transient Map context
Class defaultType
Map overrides
transient OgnlUtil ognlUtil
private static final String MAP_IDENTIFIER_KEY
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 static void link(Map context, Class clazz, String name)
public void setOgnlUtil(OgnlUtil ognlUtil)
protected void setRoot(XWorkConverter xworkConverter, CompoundRootAccessor accessor, CompoundRoot compoundRoot, boolean allowStaticMethodAccess)
public void setDevMode(String mode)
public Map getContext()
ValueStack
getContext
in interface ValueStack
public void setDefaultType(Class defaultType)
ValueStack
setDefaultType
in interface ValueStack
defaultType
- the new default typepublic void setExprOverrides(Map 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.public Map getExprOverrides()
ValueStack
getExprOverrides
in interface ValueStack
public CompoundRoot getRoot()
ValueStack
getRoot
in interface ValueStack
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 propertypublic 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.public String findString(String expr)
findString
in interface ValueStack
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)
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 Object findInContext(String name)
private void checkForInvalidProperties(String expr)
expr
- the property expressionprivate void findAvailableProperties(Class c, String expr, Set availableProperties, String parent) throws IntrospectionException
c
- the class to search onexpr
- the property expressionavailableProperties
- a set of properties foundparent
- a parent property
IntrospectionException
- when Ognl can't get property descriptorsprivate void logLookupFailure(String expr, Exception e)
expr
- The failed expressione
- The thrown exception.public Object peek()
ValueStack
peek
in interface ValueStack
CompoundRoot.peek()
public Object pop()
ValueStack
pop
in interface ValueStack
CompoundRoot.pop()
public void push(Object o)
ValueStack
push
in interface ValueStack
o
- the object to be pushed onto the stackCompoundRoot.push(Object)
public void set(String key, Object o)
ValueStack
ValueStack.findValue(String)
, ValueStack.findValue(String, Class)
set
in interface ValueStack
key
- the keyo
- the objectpublic int size()
ValueStack
size
in interface ValueStack
private Object readResolve()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |