org.apache.xpath
Class VariableStack

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.Vector
                    |
                    +--java.util.Stack
                          |
                          +--org.apache.xpath.VariableStack

public class VariableStack
extends java.util.Stack

**For internal use only** Defines a class to keep track of a stack for template arguments and variables. The VariableStack extends Stack, and each element in the stack is a stack frame, i.e. a Stack itself. The zero element is the global stack frame. Note: Someone recently made the suggestion that the globals should not be kept at the bottom of the stack, but should be implemented in a hash table.

See Also:
Serialized Form

Constructor Summary
VariableStack()
          Constructor for a variable stack.
 
Method Summary
 int getContextPos()
          Get the current context position.
 Arg getDeclaredVariable(QName qname)
          Returns a variable or parameter that is already declared, either in the current context or in the global space.
 Arg getParamArg(QName qname)
          Get the variable argument.
 int getSearchStart()
          Get the position to start the search, or -1 if the search should start from the top.
 int getSearchStartOrTop()
          Get the position from where the search should start, which is either the searchStart property, or the top of the stack if that value is -1.
 XObject getVariable(XPathContext xctxt, QName name)
          Given a name, return an object representing the value.
 void markGlobalStackFrame()
          Mark the top of the global stack frame.
 void popContextPosition()
          Pop the current context position onto the contextPositions.
 void popCurrentContext()
          Pop the current context from the current context stack.
 void popElemFrame()
          Pop the current context from the current context stack.
 void pushContextMarker()
          Push the current top of the stack as a context marker into the variables stack to let us know when to stop searching for a var.
 void pushContextPosition(int pos)
          Push a context marker onto the contextPositions stack to let us know when to stop searching for a var.
 void pushElemFrame()
          Push an argument onto the stack.
 void pushOrReplaceParameter(QName qname, XObject xval)
          Push a parameter onto the stack, or replace it if it already exists.
 void pushVariable(QName qname, XObject val)
          Push an argument onto the stack.
 void pushVariableArg(Arg arg)
          Push an argument onto the stack.
 void remarkParams()
          Re-mark the variables in the current frame as all being parameters.
 void setSearchStart(int startPos)
          Set where to start the current search for a variable.
 
Methods inherited from class java.util.Stack
empty, peek, pop, push, search
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VariableStack

public VariableStack()
Constructor for a variable stack.
Method Detail

setSearchStart

public void setSearchStart(int startPos)
Set where to start the current search for a variable. If this is -1, the search should start at the top of the stack.
Parameters:
startPos - The position to start the search, or -1 if the search should start from the top.

getSearchStartOrTop

public int getSearchStartOrTop()
Get the position from where the search should start, which is either the searchStart property, or the top of the stack if that value is -1.
Returns:
The position from where the search should start, which is always greater than or equal to zero.

getSearchStart

public int getSearchStart()
Get the position to start the search, or -1 if the search should start from the top.
Returns:
The position to start the search, or -1 if the search should start from the top.

markGlobalStackFrame

public void markGlobalStackFrame()
Mark the top of the global stack frame.

pushContextPosition

public void pushContextPosition(int pos)
Push a context marker onto the contextPositions stack to let us know when to stop searching for a var. This operation usually corresponds to the start of a template.

popContextPosition

public void popContextPosition()
Pop the current context position onto the contextPositions. This operation usually corresponds to the ending of a template.

getContextPos

public int getContextPos()
Get the current context position.
Returns:
The context marker into the stack to let us know when to stop searching for a var.

pushContextMarker

public void pushContextMarker()
Push the current top of the stack as a context marker into the variables stack to let us know when to stop searching for a var. This operation usually corresponds to the start of a template.

popCurrentContext

public void popCurrentContext()
Pop the current context from the current context stack.

pushOrReplaceParameter

public void pushOrReplaceParameter(QName qname,
                                   XObject xval)
Push a parameter onto the stack, or replace it if it already exists. Don't forget to call startContext before pushing a series of arguments for a given macro call.
Parameters:
qname - The qualified name of the variable.
val - The wrapped value of the variable.

remarkParams

public void remarkParams()
Re-mark the variables in the current frame as all being parameters.

pushVariable

public void pushVariable(QName qname,
                         XObject val)
Push an argument onto the stack. Don't forget to call startContext before pushing a series of arguments for a given macro call.
Parameters:
qname - The qualified name of the variable.
val - The wrapped value of the variable.

pushVariableArg

public void pushVariableArg(Arg arg)
Push an argument onto the stack. Don't forget to call startContext before pushing a series of arguments for a given macro call.
Parameters:
arg - The variable argument.

getDeclaredVariable

public Arg getDeclaredVariable(QName qname)
                        throws TransformerException
Returns a variable or parameter that is already declared, either in the current context or in the global space.
Parameters:
qname - The qualified name of the variable.
Returns:
the Arg if the variable is already declared, otherwise null.
Throws:
TransformerException -  

getParamArg

public Arg getParamArg(QName qname)
                throws TransformerException
Get the variable argument.
Parameters:
qname - The qualified name of the variable.
Returns:
the argument object.
Throws:
TransformerException -  

getVariable

public XObject getVariable(XPathContext xctxt,
                           QName name)
                    throws TransformerException
Given a name, return an object representing the value.
Parameters:
qname - The qualified name of the variable.
Returns:
The wrapped value of the variable.
Throws:
TransformerException -  

pushElemFrame

public void pushElemFrame()
Push an argument onto the stack. Don't forget to call startContext before pushing a series of arguments for a given macro call.

popElemFrame

public void popElemFrame()
Pop the current context from the current context stack.


Copyright © 2000 Apache XML Project. All Rights Reserved.