com.opensymphony.xwork.util
Class OgnlValueStack

java.lang.Object
  extended by com.opensymphony.xwork.util.OgnlValueStack
All Implemented Interfaces:
java.io.Serializable

public class OgnlValueStack
extends java.lang.Object
implements java.io.Serializable

OgnlValueStack allows multiple beans to be pushed in and 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).

Author:
Patrick Lightbody
See Also:
Serialized Form

Nested Class Summary
static class OgnlValueStack.ObjectAccessor
           
 
Field Summary
static java.lang.String REPORT_ERRORS_ON_NO_PROP
           
static java.lang.String VALUE_STACK
           
 
Constructor Summary
OgnlValueStack()
           
OgnlValueStack(OgnlValueStack vs)
           
 
Method Summary
 java.lang.String findString(java.lang.String expr)
           
 java.lang.Object findValue(java.lang.String expr)
          Find a value by evaluating the given expression against the stack in the default search order.
 java.lang.Object findValue(java.lang.String expr, java.lang.Class asType)
          Find a value by evaluating the given expression against the stack in the default search order.
static CompoundRootAccessor getAccessor()
           
 java.util.Map getContext()
           
 CompoundRoot getRoot()
          Get the CompoundRoot which holds the objects pushed onto the stack
 boolean isDevModeEnabled()
          Determine whether devMode is enabled.
static void link(java.util.Map context, java.lang.Class clazz, java.lang.String name)
           
 java.lang.Object peek()
          Get the object on the top of the stack without changing the stack.
 java.lang.Object pop()
          Get the object on the top of the stack and remove it from the stack.
 void push(java.lang.Object o)
          Put this object onto the top of the stack
static void reset()
           
 void setDefaultType(java.lang.Class defaultType)
          Sets the default type to convert to if no type is provided when getting a value.
 void setExprOverrides(java.util.Map overrides)
           
 void setValue(java.lang.String expr, java.lang.Object value)
          Attempts to set a property on a bean in the stack with the given expression using the default search order.
 void setValue(java.lang.String expr, java.lang.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 s
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VALUE_STACK

public static final java.lang.String VALUE_STACK
See Also:
Constant Field Values

REPORT_ERRORS_ON_NO_PROP

public static final java.lang.String REPORT_ERRORS_ON_NO_PROP
See Also:
Constant Field Values
Constructor Detail

OgnlValueStack

public OgnlValueStack()

OgnlValueStack

public OgnlValueStack(OgnlValueStack vs)
Method Detail

reset

public static void reset()

link

public static void link(java.util.Map context,
                        java.lang.Class clazz,
                        java.lang.String name)

getAccessor

public static CompoundRootAccessor getAccessor()

getContext

public java.util.Map getContext()

setDefaultType

public void setDefaultType(java.lang.Class defaultType)
Sets the default type to convert to if no type is provided when getting a value.

Parameters:
defaultType -

setExprOverrides

public void setExprOverrides(java.util.Map overrides)

getRoot

public CompoundRoot getRoot()
Get the CompoundRoot which holds the objects pushed onto the stack


isDevModeEnabled

public boolean isDevModeEnabled()
Determine whether devMode is enabled.

Returns:
true if devMode was enabled, false otherwise.

setValue

public void setValue(java.lang.String expr,
                     java.lang.Object value)
Attempts to set a property on a bean in the stack with the given expression using the default search order.

Parameters:
expr - the expression defining the path to the property to be set.
value - the value to be set into the neamed property

setValue

public void setValue(java.lang.String expr,
                     java.lang.Object value,
                     boolean throwExceptionOnFailure)
Attempts to set a property on a bean in the stack with the given expression using the default search order.

Parameters:
expr - the expression defining the path to the property to be set.
value - the value to be set into the neamed property
throwExceptionOnFailure - a flag to tell whether an exception should be thrown if there is no property with the given name.

findString

public java.lang.String findString(java.lang.String expr)

findValue

public java.lang.Object findValue(java.lang.String expr)
Find a value by evaluating the given expression against the stack in the default search order.

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

public java.lang.Object findValue(java.lang.String expr,
                                  java.lang.Class asType)
Find a value by evaluating the given expression against the stack in the default search order.

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

peek

public java.lang.Object peek()
Get the object on the top of the stack without changing the stack.

See Also:
CompoundRoot.peek()

pop

public java.lang.Object pop()
Get the object on the top of the stack and remove it from the stack.

Returns:
the object on the top of the stack
See Also:
CompoundRoot.pop()

push

public void push(java.lang.Object o)
Put this object onto the top of the stack

Parameters:
o - the object to be pushed onto the stack
See Also:
CompoundRoot.push(Object)

size

public int size()
Get the number of objects in the stack s

Returns:
the number of objects in the stack

XWork Project Page