org.apache.struts2.spi
Interface ValueStack

All Superinterfaces:
java.lang.Iterable<java.lang.Object>

public interface ValueStack
extends java.lang.Iterable<java.lang.Object>

A central fixture of the Struts framework, the ValueStack is a stack which contains the actions which have executed in addition to other objects. Users can get and set values on the stack using expressions. The ValueStack will search down the stack starting with the most recent objects until it finds an object to which the expression can apply.

Author:
crazybob@google.com (Bob Lee)

Method Summary
 ValueStack clone()
          Creates a shallow copy of this stack.
 java.lang.Object get(java.lang.String expression)
          Queries the stack.
<T> T
get(java.lang.String expression, java.lang.Class<T> asType)
          Queries the stack and converts the result to the specified type.
 java.lang.String getString(java.lang.String expression)
          Queries the stack and converts the result to a String.
 java.lang.Object peek()
          Gets the top, most recent object from the stack without changing the stack.
 java.lang.Object pop()
          Removes the top, most recent object from the stack.
 void push(java.lang.Object o)
          Pushes an object onto the stack.
 void set(java.lang.String expression, java.lang.Object value)
          Sets a value on an object from the stack.
 int size()
          Returns the number of object on the stack.
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

peek

java.lang.Object peek()
Gets the top, most recent object from the stack without changing the stack.

Returns:
the top object

pop

java.lang.Object pop()
Removes the top, most recent object from the stack.

Returns:
the top object

push

void push(java.lang.Object o)
Pushes an object onto the stack.

Parameters:
o -

clone

ValueStack clone()
Creates a shallow copy of this stack.

Returns:
a new stack which contains the same objects as this one

get

java.lang.Object get(java.lang.String expression)
Queries the stack. Starts with the top, most recent object. If the expression can apply to the object, this method returns the result of evaluating the expression. If the expression does not apply, this method moves down the stack to the next object and repeats. Returns null if the expression doesn't apply to any objects.

Parameters:
expression -
Returns:
the evaluation of the expression against the first applicable object in the stack

get

<T> T get(java.lang.String expression,
          java.lang.Class<T> asType)
Queries the stack and converts the result to the specified type. Starts with the top, most recent object. If the expression can apply to the object, this method returns the result of evaluating the expression converted to the specified type. If the expression does not apply, this method moves down the stack to the next object and repeats. Returns null if the expression doesn't apply to any objects.

Parameters:
expression -
asType - the type to convert the result to
Returns:
the evaluation of the expression against the first applicable object in the stack converted to the specified type

getString

java.lang.String getString(java.lang.String expression)
Queries the stack and converts the result to a String. Starts with the top, most recent object. If the expression can apply to the object, this method returns the result of evaluating the expression converted to a String. If the expression does not apply, this method moves down the stack to the next object and repeats. Returns null if the expression doesn't apply to any objects.

Parameters:
expression -
Returns:
the evaluation of the expression against the first applicable object in the stack converted to a String

set

void set(java.lang.String expression,
         java.lang.Object value)
Sets a value on an object from the stack. This method starts at the top, most recent object. If the expression applies to that object, this methods sets the given value on that object using the expression and converting the type as necessary. If the expression does not apply, this method moves to the next object and repeats.

Parameters:
expression -
value -

size

int size()
Returns the number of object on the stack.

Returns:
size of stack


Copyright © 2000-2006 Apache Software Foundation. All Rights Reserved.