|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectfreemarker.template.SimpleList
freemarker.ext.misc.ExtendedList
public class ExtendedList
Simple extension to the SimpleList implementation.
This class implements a number of convenience facilities in the form of template
hash keys. The hash keys are:
_size - retrieves the size of the list_first - retrieves the first item in the list (always), or
null if the list is empty_last - retrieves the last item in the list (always), or
null if the list is emptyNote: the _isLast key has now been moved to the
ExtendedIterator class.
An ExtendedList can also be given a shelf life; it
then keeps track of the time elapsed since the last time it copied
another TemplateListModel,
TemplateModel array, or the last time its
shelf life was set. Its owner can check whether it has become stale,
and refresh it if necessary by copying data into it again.
When this model is serialized and deserialized, the newly deserialized
object has its timeCreated member variable reset to the
current time. In other words, the time until expiry will be reset to
the current shelf life following deserialization.
ExtendedHash,
Serialized Form| Field Summary | |
|---|---|
protected boolean |
isPermanent
|
protected static int |
MS_PER_MINUTE
|
protected long |
shelfLife
|
protected long |
timeCreated
The creation time to be used for determining staleness. |
| Fields inherited from class freemarker.template.SimpleList |
|---|
list |
| Constructor Summary | |
|---|---|
ExtendedList()
Creates new ExtendedList. |
|
ExtendedList(java.util.List<? extends TemplateModel> list)
Creates new ExtendedList given a List of values. |
|
ExtendedList(TemplateListModel listToCopy)
Creates new ExtendedList populated by copying the given TemplateListModel. |
|
ExtendedList(TemplateListModel2 listToCopy)
Creates new ExtendedList populated by copying the given TemplateListModel2. |
|
ExtendedList(TemplateModel[] arr)
Creates new ExtendedList populated by the TemplateModel array. |
|
| Method Summary | |
|---|---|
void |
copy(TemplateListModel listToCopy)
Delegates to the underlying SimpleList copy method. |
void |
copy(TemplateListModel2 listToCopy)
Delegates to the underlying SimpleList copy method. |
void |
copy(TemplateModel[] arr)
Delegates to the underlying SimpleList copy method. |
boolean |
equals(java.lang.Object o)
Attempt to compare ExtendedList objects for equality. |
TemplateModel |
get(java.lang.String key)
Gets one of the special keys that the ExtendedList
implementation provides. |
int |
getShelfLife()
|
int |
hashCode()
Generate a hash code for this object based on the hash code for the SimpleList. |
boolean |
isPermanent()
|
boolean |
isStale()
|
void |
releaseIterator(TemplateIteratorModel iterator)
Returns the used iterator to the list model. |
void |
setPermanent()
Gives this ExtendedList an indefinite shelf life. |
void |
setShelfLife(int minutes)
Sets the amount of time before this ExtendedList
will become stale. |
TemplateIteratorModel |
templateIterator()
Retrieves an iterator to iterate over this list. |
| Methods inherited from class freemarker.template.SimpleList |
|---|
add, add, add, add, add, clear, getAsObject, getAtIndex, isEmpty, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface freemarker.template.TemplateModel |
|---|
isEmpty |
| Field Detail |
|---|
protected static final int MS_PER_MINUTE
protected transient long timeCreated
protected long shelfLife
protected boolean isPermanent
| Constructor Detail |
|---|
public ExtendedList()
public ExtendedList(java.util.List<? extends TemplateModel> list)
List of values.
A defensive copy of the list is made.
list - the list of values to be copied into this
ExtendedList
java.lang.NullPointerException - the list value is nullpublic ExtendedList(TemplateModel[] arr)
TemplateModel array.
arr - the array to be copied into the underlying List.
public ExtendedList(TemplateListModel listToCopy)
throws TemplateModelException
TemplateListModel.
listToCopy - the list to be copied into this one.
TemplateModelException - something went wrong while copying the
given list into the ExtendedList.
public ExtendedList(TemplateListModel2 listToCopy)
throws TemplateModelException
TemplateListModel2.
listToCopy - the list to be copied into this one.
TemplateModelException - something went wrong while copying the
given list into the ExtendedList.| Method Detail |
|---|
public TemplateModel get(java.lang.String key)
throws TemplateModelException
ExtendedList
implementation provides.
get in interface TemplateHashModelkey - the name of the special value to be retrieved.
TemplateModel referred to by the key,
or null if not found.
TemplateModelException - there was a problem getting the value
for the given key
public void copy(TemplateListModel listToCopy)
throws TemplateModelException
SimpleList copy method. This
variation sets the time that this list was created.
copy in class SimpleListlistToCopy - the list to be copied into this one.
TemplateModelException - something went wrong while copying the
given list into the SimpleList.
public void copy(TemplateListModel2 listToCopy)
throws TemplateModelException
SimpleList copy method. This
variation sets the time that this list was created.
copy in class SimpleListlistToCopy - the list to be copied into this one.
TemplateModelException - something went wrong while copying the
given list into the SimpleList.public void copy(TemplateModel[] arr)
SimpleList copy method. This
variation sets the time that this list was created.
copy in class SimpleListarr - the array to be copied into the underlying list.public void setShelfLife(int minutes)
ExtendedList
will become stale.
minutes - the number of minutes before this
ExtendedList will become stale.public int getShelfLife()
ExtendedList's shelf life in minutes.public void setPermanent()
ExtendedList an indefinite shelf life.
public boolean isPermanent()
true if this ExtendedList has an
indefinite shelf life.public boolean isStale()
true if this ExtendedList has become stale.
public TemplateIteratorModel templateIterator()
throws TemplateModelException
templateIterator in interface TemplateListModel2templateIterator in class SimpleListTemplateModelException - the next item in the list can't be
retrieved, or no next item exists.public void releaseIterator(TemplateIteratorModel iterator)
releaseIterator in interface TemplateListModel2releaseIterator in class SimpleListiterator - the iterator to be returned to the object pool, if anypublic boolean equals(java.lang.Object o)
equals in class SimpleListo - the object to compare against
true if the objects are equal, otherwise
falsepublic int hashCode()
SimpleList.
hashCode in class SimpleList
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||