org.liquidsite.app.template
Class SessionBean.SessionDataBean

java.lang.Object
  extended byorg.liquidsite.app.template.SessionBean.SessionDataBean
All Implemented Interfaces:
freemarker.template.TemplateHashModel, freemarker.template.TemplateModel, freemarker.template.TemplateScalarModel, freemarker.template.TemplateSequenceModel
Enclosing class:
SessionBean

public class SessionBean.SessionDataBean
extends java.lang.Object
implements freemarker.template.TemplateScalarModel, freemarker.template.TemplateHashModel, freemarker.template.TemplateSequenceModel

The session data model bean. This bean wraps all the session data hierachy. The objects can be treated as scalars, hashes or sequences, mostly interchangably. This class really represents a pointer to the data, making it possible to modify or remove data via this bean.


Field Summary
 
Fields inherited from interface freemarker.template.TemplateScalarModel
EMPTY_STRING
 
Fields inherited from interface freemarker.template.TemplateModel
NOTHING
 
Method Summary
 void add(java.lang.Object value)
          Adds a value to this session data object.
 freemarker.template.TemplateModel get(int index)
          Returns a session data value from an array index.
 freemarker.template.TemplateModel get(java.lang.String name)
          Returns a session data value from a hash key name.
 java.lang.String getAsString()
          Returns the session data value as a string.
 boolean isEmpty()
          Checks if the hash model is empty.
 void remove()
          Removes this session data object.
 int size()
          Returns the size of the session data value list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getAsString

public java.lang.String getAsString()
                             throws freemarker.template.TemplateModelException
Returns the session data value as a string. If the value pointed to is a hash map, an empty string will be returned. If the value is a list, the first value in the list will be returned.

Specified by:
getAsString in interface freemarker.template.TemplateScalarModel
Returns:
the session data value as a string
Throws:
freemarker.template.TemplateModelException - if this object points to an index that has been removed

isEmpty

public boolean isEmpty()
Checks if the hash model is empty.

Specified by:
isEmpty in interface freemarker.template.TemplateHashModel
Returns:
false as the hash model can always be extended

get

public freemarker.template.TemplateModel get(java.lang.String name)
Returns a session data value from a hash key name. The value will always be returned as another instance of this class. If the value in this object isn't a hash map, it will be created and any previous string value discarded. If the value in this object is an array list, the first element in the list will be used implicitly.

Specified by:
get in interface freemarker.template.TemplateHashModel
Parameters:
name - the session data key name
Returns:
the template model object, or NOTHING if the object points to a removed index

get

public freemarker.template.TemplateModel get(int index)
                                      throws freemarker.template.TemplateModelException
Returns a session data value from an array index. The value will always be returned as another instance of this class. If the value in this object isn't an array, the only index allowed will be zero. Otherwise, only valid indices are allowed, or an index out of bounds exception will be launched.

Specified by:
get in interface freemarker.template.TemplateSequenceModel
Parameters:
index - the session data index
Returns:
the template model object, or NOTHING if the index was out of bounds
Throws:
freemarker.template.TemplateModelException - if a double index indirection was attempted

size

public int size()
Returns the size of the session data value list. If the value in this object isn't a list, zero or one will be returned depending on whether it exists or not.

Specified by:
size in interface freemarker.template.TemplateSequenceModel
Returns:
the size of the session data value list

add

public void add(java.lang.Object value)
         throws freemarker.template.TemplateModelException
Adds a value to this session data object. If the object already contains a value, it will be converted to a list and the new value will be added last.

Parameters:
value - the data value to add
Throws:
freemarker.template.TemplateModelException - if an attempt was made to add values to a specific index

remove

public void remove()
Removes this session data object. If the object points to an index in a list, only the specified index will be removed.