com.arsdigita.acs
Class CallStack

java.lang.Object
  |
  +--com.arsdigita.acs.CallStack
All Implemented Interfaces:
java.util.Map

public class CallStack
extends java.lang.Object
implements java.util.Map

Class to represent a call stack for parameters passed into and through the templating system. Useful for recursive includes to prevent property/datasource clobbering, because each include level should get its own namespace. A CallStack is an ordered list of sets of key-value mappings ( {(k1_1, v1_1), (k1_2, v1_2) ...}, {(k2_1, v2_1), (k2_2, v2_2), ...}, ...) where the last set of key-value mappings is the current stack frame.


Inner classes inherited from class java.util.Map
java.util.Map.Entry
 
Field Summary
static java.lang.String cvsId
           
 
Constructor Summary
CallStack()
          No-arg constructor.
 
Method Summary
 void clear()
           
 boolean containsKey(java.lang.Object o)
          Returns true if the current stack frame contains the specified key.
 boolean containsValue(java.lang.Object o)
           
 java.util.Set entrySet()
           
 java.lang.Object get(java.lang.Object key)
          Gets the value for a key in the current stack frame.
 boolean isEmpty()
           
 java.util.Set keySet()
           
 void newLevel()
          Creates a new, empty stack frame pushed on top of the current frame.
 void newLevel(java.util.HashMap frame)
          Push a new stack frame on the call stack, pre-filled.
 java.util.HashMap pop()
          Removes the stack frame at the top of the stack.
 java.lang.String prettyGet(java.lang.String key)
          Returns get(key), but throws an exception if key is not a valid key.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Put a key, value mapping into the current stack frame.
 void putAll(AdSet set)
           
 void putAll(java.util.Map m)
           
 java.lang.Object remove(java.lang.Object key)
           
 int size()
           
 java.lang.String toString()
          Prints string representation of call stack.
 java.util.Collection values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

cvsId

public static final java.lang.String cvsId
Constructor Detail

CallStack

public CallStack()
No-arg constructor. Create initial stack frame.
Method Detail

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Put a key, value mapping into the current stack frame.
Specified by:
put in interface java.util.Map
Parameters:
key - the key
value - the value

get

public java.lang.Object get(java.lang.Object key)
Gets the value for a key in the current stack frame.
Specified by:
get in interface java.util.Map
Parameters:
key - the key
Returns:
the value mapped from key, or null if not found

prettyGet

public java.lang.String prettyGet(java.lang.String key)
                           throws com.arsdigita.db.PageContractException
Returns get(key), but throws an exception if key is not a valid key.
Returns:
An empty string if the parameter is null; or throws an exception if the key is not available.

newLevel

public void newLevel()
Creates a new, empty stack frame pushed on top of the current frame.

newLevel

public void newLevel(java.util.HashMap frame)
Push a new stack frame on the call stack, pre-filled.
Parameters:
frame - the stack frame to push

pop

public java.util.HashMap pop()
Removes the stack frame at the top of the stack.
Returns:
the popped stack frame

size

public int size()
Specified by:
size in interface java.util.Map
Returns:
the depth of the call stack

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map

containsKey

public boolean containsKey(java.lang.Object o)
Returns true if the current stack frame contains the specified key.
Specified by:
containsKey in interface java.util.Map
Parameters:
o - the key to check for
Returns:
true if o is a key in the current stack frame

containsValue

public boolean containsValue(java.lang.Object o)
Specified by:
containsValue in interface java.util.Map

remove

public java.lang.Object remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map

putAll

public void putAll(java.util.Map m)
Specified by:
putAll in interface java.util.Map

putAll

public void putAll(AdSet set)

clear

public void clear()
Specified by:
clear in interface java.util.Map

keySet

public java.util.Set keySet()
Specified by:
keySet in interface java.util.Map

values

public java.util.Collection values()
Specified by:
values in interface java.util.Map

entrySet

public java.util.Set entrySet()
Specified by:
entrySet in interface java.util.Map

toString

public java.lang.String toString()
Prints string representation of call stack.
Overrides:
toString in class java.lang.Object