freemarker.testcase.models
Class ListModel2

java.lang.Object
  |
  +--freemarker.testcase.models.ListModel2
All Implemented Interfaces:
TemplateHashModel, TemplateListModel, TemplateModel

public final class ListModel2
extends java.lang.Object
implements TemplateListModel, TemplateHashModel

A simple list model for testing the list iterator functionality. This implements the old TemplateListModel interface to test backward compatibility.

Version:
$Id: ListModel2.java,v 1.2 2003/11/28 01:17:07 run2000 Exp $
Author:
Nicholas Cull

Constructor Summary
ListModel2()
          Default constructor that creates a simple list.
 
Method Summary
 TemplateModel get(int index)
          Retrieve an item at the given index
 TemplateModel get(java.lang.String key)
          Implement special keys to retrieve the size of the list and the index of the current item.
 boolean hasNext()
          Are there any more elements?
 boolean isEmpty()
          Is the model empty?
 boolean isRewound()
          Is the current item at the beginning of the list?
 TemplateModel next()
          Retrieve the next item in the list.
 void rewind()
          Rewind the current item to the beginning of the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListModel2

public ListModel2()
Default constructor that creates a simple list.
Method Detail

isEmpty

public boolean isEmpty()
Is the model empty?
Specified by:
isEmpty in interface TemplateModel
Returns:
true if the list is empty, otherwise false

hasNext

public boolean hasNext()
Are there any more elements?
Specified by:
hasNext in interface TemplateListModel
Returns:
true if there are more elements, otherwise false

next

public TemplateModel next()
Retrieve the next item in the list.
Specified by:
next in interface TemplateListModel
Returns:
the next item in the list

rewind

public void rewind()
Rewind the current item to the beginning of the list.
Specified by:
rewind in interface TemplateListModel

isRewound

public boolean isRewound()
Is the current item at the beginning of the list?
Specified by:
isRewound in interface TemplateListModel
Returns:
true if we are at the beginning of the list, otherwise false

get

public TemplateModel get(int index)
Retrieve an item at the given index
Specified by:
get in interface TemplateListModel
Parameters:
index - the index of the item to be retrieved
Returns:
the item at the specified index

get

public TemplateModel get(java.lang.String key)
                  throws TemplateModelException
Implement special keys to retrieve the size of the list and the index of the current item.
Specified by:
get in interface TemplateHashModel
Parameters:
key - the name of the value to be retrieved
Returns:
the named value, or null