freemarker.testcase.models
Class MultiModel1

java.lang.Object
  |
  +--freemarker.testcase.models.MultiModel1
All Implemented Interfaces:
TemplateHashModel, TemplateIndexedModel, TemplateListModel2, TemplateModel, TemplateScalarModel

public final class MultiModel1
extends java.lang.Object
implements TemplateHashModel, TemplateListModel2, TemplateIndexedModel, TemplateScalarModel

Testcase to see how FM-Classic deals with multiple Template models.

Version:
$Id: MultiModel1.java,v 1.12 2003/11/28 01:17:07 run2000 Exp $
See Also:
MultiModel2, MultiModel3, MultiModel4, MultiModel5

Constructor Summary
MultiModel1()
          Creates new MultiModel1.
 
Method Summary
 TemplateModel get(java.lang.String key)
          Gets a TemplateModel from the hash.
 java.lang.String getAsString()
          Returns the scalar's value as a String.
 TemplateModel getAtIndex(long index)
          Retrieves the specified item from the list.
 boolean isEmpty()
          Is the model empty?
 void releaseIterator(TemplateIteratorModel iterator)
          Returns the used iterator to the list model.
 TemplateIteratorModel templateIterator()
          Retrieves an iterator to iterate over this list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiModel1

public MultiModel1()
Creates new MultiModel1.
Method Detail

get

public TemplateModel get(java.lang.String key)
                  throws TemplateModelException
Gets a TemplateModel from the hash.
Specified by:
get in interface TemplateHashModel
Parameters:
key - the name by which the TemplateModel is identified in the template.
Returns:
the TemplateModel referred to by the key, or null if not found.

isEmpty

public boolean isEmpty()
                throws TemplateModelException
Is the model empty?
Specified by:
isEmpty in interface TemplateModel
Returns:
false to indicate the model is not empty

templateIterator

public TemplateIteratorModel templateIterator()
                                       throws TemplateModelException
Retrieves an iterator to iterate over this list.
Specified by:
templateIterator in interface TemplateListModel2
Returns:
an iterator to iterate over the current list.
Throws:
TemplateModelException - the next item in the list can't be retrieved, or no next item exists.

releaseIterator

public void releaseIterator(TemplateIteratorModel iterator)
Returns the used iterator to the list model.
Specified by:
releaseIterator in interface TemplateListModel2
Parameters:
iterator - the iterator to be returned to the object pool

getAtIndex

public TemplateModel getAtIndex(long index)
                         throws TemplateModelException
Retrieves the specified item from the list.
Specified by:
getAtIndex in interface TemplateIndexedModel
Parameters:
index - the index of the item to be retrieved.
Returns:
the specified index in the list.
Throws:
TemplateModelException - the specified item in the list can't be retrieved, or the index is out of bounds.

getAsString

public java.lang.String getAsString()
                             throws TemplateModelException
Returns the scalar's value as a String.
Specified by:
getAsString in interface TemplateScalarModel
Returns:
the String value of this scalar.