pmp
Class CallStack

java.lang.Object
  extended by pmp.CallStack

public final class CallStack
extends java.lang.Object

Stack for storing macro parameters.

Title: PMP: Macroprocessor

Description: Java macroprocessor

Copyright: Copyright (c) 2005

Version:
1.0
Author:
Luděk Hlaváček

Constructor Summary
CallStack()
           
 
Method Summary
 CallStackItem addField(java.lang.String str)
          Adds new field into array on top of the stack.
 CallStackItem appendToLastField(java.lang.String str)
          Appends strto last field in array on top of the stack.
 void clear()
          Removes all items from stack.
 boolean isEmpty()
          Returns true if stack is empty.
 CallStackItem popItem()
          Pops item from stack.
 CallStackItem pushItem(CallStackItem.Type type, java.lang.String[] params)
          Pushes new item to stack.
 CallStackItem pushItem(CallStackItem item)
          Pushes new item to stack.
 CallStackItem pushMacroItem(java.lang.String macroName, AbstractMacro macro)
          Pushes new item to stack.
 CallStackItem stripParamFields()
          Removes all parameter fields from item on top of the stack.
 CallStackItem topItem()
          Returns item on top of the stack or null if stack is empty.
 CallStackItem.Type topItemType()
          Returns type of item on top of the stack.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CallStack

public CallStack()
Method Detail

pushItem

public CallStackItem pushItem(CallStackItem.Type type,
                              java.lang.String[] params)
Pushes new item to stack.

Parameters:
type - type of item
params - parameters
Returns:
newly createm CallStackItem object

pushMacroItem

public CallStackItem pushMacroItem(java.lang.String macroName,
                                   AbstractMacro macro)
Pushes new item to stack. This item has type field set to TYPE_MACRO and parameters are { macroName, ""}.

Parameters:
macroName - name of macro as appeared in program
macro - that will be invoked when all paameters are read
Returns:
newly createm CallStackItem object

pushItem

public CallStackItem pushItem(CallStackItem item)
Pushes new item to stack.

Parameters:
item - item to be added to the top of the stack.
Returns:
item

popItem

public CallStackItem popItem()
Pops item from stack.

Returns:
item removed from the top of the stack

isEmpty

public boolean isEmpty()
Returns true if stack is empty.

Returns:
true if empty

clear

public void clear()
Removes all items from stack.


topItemType

public CallStackItem.Type topItemType()
Returns type of item on top of the stack. If stack is empty returns CallStackItem.TYPE_EMPTY.

Returns:
type of item
See Also:
CallStackItem

topItem

public CallStackItem topItem()
Returns item on top of the stack or null if stack is empty.

Returns:
top item from the stack

addField

public CallStackItem addField(java.lang.String str)
Adds new field into array on top of the stack.

Parameters:
str - value
Returns:
item on top of the stack

stripParamFields

public CallStackItem stripParamFields()
Removes all parameter fields from item on top of the stack. This method is used when macro is invoked without parameters.

Returns:
item on top of the stack

appendToLastField

public CallStackItem appendToLastField(java.lang.String str)
Appends strto last field in array on top of the stack.

Parameters:
str - value
Returns:
item on top of the stack