com.opensymphony.xwork2.util

## Interface ValueStack

- All Known Implementing Classes:
    OgnlValueStack

      public interface ValueStack

  ValueStack allows multiple beans to be pushed in and dynamic EL 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

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `REPORT_ERRORS_ON_NO_PROP`
    `static String` | `VALUE_STACK`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `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
    `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
    `void` | `set(String key, Object o)` Sets an object on the stack with the given key so it is retrievable by `findValue(String)`, `findValue(String, Class)`
    `void` | `setDefaultType(Class defaultType)` Sets the default type to convert to if no type is provided when getting a value.
    `void` | `setExprOverrides(Map<Object,Object> overrides)` Set a override map containing `key -> values` that takes precedent when doing find operations on the ValueStack.
    `void` | `setParameter(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)` 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

- - ### Field Detail

    - #### VALUE_STACK

          static final String VALUE_STACK

      See Also:
        Constant Field Values

    - #### REPORT_ERRORS_ON_NO_PROP

          static final String REPORT_ERRORS_ON_NO_PROP

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getContext

          Map<String,Object> getContext()

      Gets the context for this value stack. The context holds all the information in the value stack and it's surroundings.
      Returns:
        the context.

    - #### setDefaultType

          void setDefaultType(Class defaultType)

      Sets the default type to convert to if no type is provided when getting a value.
      Parameters:
        `defaultType` - the new default type

    - #### setExprOverrides

          void setExprOverrides(Map<Object,Object> overrides)

      Set a override map containing `key -> values` that takes precedent when doing find operations on the ValueStack.

      See the unit test for ValueStackTest for examples.

      Parameters:
        `overrides` - overrides map.

    - #### getExprOverrides

          Map<Object,Object> getExprOverrides()

      Gets the override map if anyone exists.
      Returns:
        the override map, `null` if not set.

    - #### getRoot

          CompoundRoot getRoot()

      Get the CompoundRoot which holds the objects pushed onto the stack
      Returns:
        the root

    - #### setValue

          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.
      Parameters:
        `expr` - the expression defining the path to the property to be set.
        `value` - the value to be set into the named property

    - #### setParameter

          void setParameter(String expr,
                          Object value)

      Attempts 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.
      Parameters:
        `expr` - the expression defining the path to the property to be set.
        `value` - the value to be set into the named property

    - #### setValue

          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.
      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.

    - #### findString

          String findString(String expr)

    - #### findString

          String findString(String expr,
                          boolean throwExceptionOnFailure)

    - #### findValue

          Object findValue(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

          Object findValue(String expr,
                         boolean throwExceptionOnFailure)

    - #### findValue

          Object findValue(String expr,
                         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

    - #### findValue

          Object findValue(String expr,
                         Class asType,
                         boolean throwExceptionOnFailure)

    - #### peek

          Object peek()

      Get the object on the top of the stack without changing the stack.
      Returns:
        the object on the top.
      See Also:
        `CompoundRoot.peek()`

    - #### pop

          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

          void push(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)`

    - #### set

          void set(String key,
                 Object o)

      Sets an object on the stack with the given key so it is retrievable by `findValue(String)`, `findValue(String, Class)`
      Parameters:
        `key` - the key
        `o` - the object

    - #### size

          int size()

      Get the number of objects in the stack
      Returns:
        the number of objects in the stack

Copyright © 2000–2022 Apache Software Foundation. All rights reserved.