|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object freemarker.template.FastIndexedWriteableIterator
public class FastIndexedWriteableIterator
An iterator that operates over a TemplateIndexedModel
implementation
that also implements TemplateWriteableIndexedModel
.
The assumption here is that we have constant-time random access to the
underlying implementation.
FastIndexedIterator
Field Summary | |
---|---|
protected long |
currentIndex
The current index into the model. |
protected long |
endIndex
The end index of the model. |
protected TemplateWriteableIndexedModel |
indexModel
The model that we will index into. |
protected long |
startIndex
The beginning index of the model. |
Constructor Summary | |
---|---|
FastIndexedWriteableIterator(TemplateWriteableIndexedModel model,
long startIndex,
long endIndex)
Constructor that takes the object we're iterating over as an argument |
Method Summary | |
---|---|
TemplateModel |
get(java.lang.String key)
Gets a TemplateModel from the hash. |
boolean |
hasNext()
Do we have a next value? |
boolean |
isEmpty()
Is the iterator empty? |
TemplateModel |
next()
Return the next value in the indexModel, and increment the counter to point to the next value. |
void |
set(TemplateModel model)
Inserts the specified element into the list. |
java.lang.String |
toString()
Returns a string representation of the object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final TemplateWriteableIndexedModel indexModel
protected final long startIndex
protected final long endIndex
protected long currentIndex
Constructor Detail |
---|
public FastIndexedWriteableIterator(TemplateWriteableIndexedModel model, long startIndex, long endIndex)
model
- the indexed list model to iterate overMethod Detail |
---|
public boolean isEmpty() throws TemplateModelException
isEmpty
in interface TemplateModel
false
, indicating the iterator is not empty
TemplateModelException
public boolean hasNext()
hasNext
in interface TemplateIteratorModel
true
if more values exist in the list,
otherwise false
public TemplateModel next() throws TemplateModelException
next
in interface TemplateIteratorModel
TemplateModel
representing the next value
in the list
TemplateModelException
- the next item couldn't be retrieved,
or we're at the end of the listpublic void set(TemplateModel model) throws TemplateModelException
set
in interface TemplateWriteableIteratorModel
model
- the model to insert into the list
TemplateModelException
- the model could not be assigned
to the listpublic TemplateModel get(java.lang.String key) throws TemplateModelException
TemplateModel
from the hash. The one key is "index",
which returns the current index of the iterator.
get
in interface TemplateHashModel
key
- the name by which the TemplateModel
is identified in the template.
TemplateModel
referred to by the key,
or null
if not found.
TemplateModelException
- there was a problem getting the value
for the given keypublic java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |