blob: 3309c6ec8de380f7fbb057556efed8df58c425b1 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.5.0_14) on Mon Apr 26 10:16:13 PDT 2010 -->
<TITLE>
LoopTool (VelocityTools 2.0 Documentation)
</TITLE>
<META NAME="keywords" CONTENT="org.apache.velocity.tools.generic.LoopTool class">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
parent.document.title="LoopTool (VelocityTools 2.0 Documentation)";
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../../org/apache/velocity/tools/generic/LocaleConfig.html" title="class in org.apache.velocity.tools.generic"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.Action.html" title="enum in org.apache.velocity.tools.generic"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../index.html?org/apache/velocity/tools/generic/LoopTool.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="LoopTool.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;<A HREF="#nested_class_summary">NESTED</A>&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
org.apache.velocity.tools.generic</FONT>
<BR>
Class LoopTool</H2>
<PRE>
java.lang.Object
<IMG SRC="../../../../../resources/inherit.gif" ALT="extended by "><B>org.apache.velocity.tools.generic.LoopTool</B>
</PRE>
<HR>
<DL>
<DT><PRE><FONT SIZE="-1"><A HREF="../../../../../org/apache/velocity/tools/config/DefaultKey.html" title="annotation in org.apache.velocity.tools.config">@DefaultKey</A>(<A HREF="../../../../../org/apache/velocity/tools/config/DefaultKey.html#value()">value</A>="loop")
<A HREF="../../../../../org/apache/velocity/tools/config/ValidScope.html" title="annotation in org.apache.velocity.tools.config">@ValidScope</A>(<A HREF="../../../../../org/apache/velocity/tools/config/ValidScope.html#value()">value</A>="request")
</FONT>public class <B>LoopTool</B><DT>extends java.lang.Object</DL>
</PRE>
<P>
<p>
A convenience tool to use with #foreach loops. It wraps a list
with a custom iterator to provide additional controls and feedback
for managing loops.
</p>
<p>
This tool was originally inspired the now-deprecated IteratorTool,
which provided similar base functionality but was somewhat more difficult
to understand and use. Rather than try to migrate that implementation
via deprecation and new methods, it was simplest to just create an
entirely new tool that simplified the original API and was easy
to augment with useful new features like support for nested
(and nameable) loops, skipping ahead in loops, synchronizing multiple
iterators, getting the iteration count of loops, identifying if a loop is
on its first or last iteration, and so on.
</p>
<p>
Most functions of this tool will be obsolete with the release of
Velocity 1.7, which will provide $foreach.hasNext, $foreach.isFirst,
$foreach.isLast, $foreach.index and $foreach.count automatically.
However, this will still be useful for the more advanced sync
and skip features. Also, for very complicated nested loops, the
loop naming feature may be easier than doing things like $foreach.parent.parent.
</p>
<p>
Example of use:
<pre>
Template
---
#set( $list = [1..7] )
#set( $others = [3..10] )
#foreach( $item in $loop.watch($list).sync($others, 'other') )
$item -> $loop.other
#if( $item >= 5 )$loop.stop()#end
#end
Output
------
1 -> 3
2 -> 4
3 -> 5
4 -> 6
5 -> 7
Example tools.xml config (if you want to use this with VelocityView):
&lt;tools&gt;
&lt;toolbox scope="request"&gt;
&lt;tool class="org.apache.velocity.tools.generic.LoopTool"/&gt;
&lt;/toolbox&gt;
&lt;/tools&gt;
</pre>
</p>
<P>
<P>
<DL>
<DT><B>Version:</B></DT>
<DD>$Id: LoopTool.java 590893 2007-11-01 04:40:21Z nbubna $</DD>
<DT><B>Author:</B></DT>
<DD>Nathan Bubna</DD>
</DL>
<HR>
<P>
<!-- ======== NESTED CLASS SUMMARY ======== -->
<A NAME="nested_class_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Nested Class Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;class</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.Action.html" title="enum in org.apache.velocity.tools.generic">LoopTool.Action</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Represents an automatic action taken by a <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic"><CODE>LoopTool.ManagedIterator</CODE></A>
when a <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ActionCondition.html" title="class in org.apache.velocity.tools.generic"><CODE>LoopTool.ActionCondition</CODE></A> is satisfied by the subsequent element.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;class</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ActionCondition.html" title="class in org.apache.velocity.tools.generic">LoopTool.ActionCondition</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Composition class which associates an <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.Action.html" title="enum in org.apache.velocity.tools.generic"><CODE>LoopTool.Action</CODE></A> and <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ActionCondition.html" title="class in org.apache.velocity.tools.generic"><CODE>LoopTool.ActionCondition</CODE></A>
for a <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic"><CODE>LoopTool.ManagedIterator</CODE></A>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;class</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.Comparison.html" title="class in org.apache.velocity.tools.generic">LoopTool.Comparison</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Base condition class for conditions (assumption here is that
conditions are all comparative.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;interface</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.Condition.html" title="interface in org.apache.velocity.tools.generic">LoopTool.Condition</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Represents a function into which a <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic"><CODE>LoopTool.ManagedIterator</CODE></A> can
pass it's next element to see if an <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.Action.html" title="enum in org.apache.velocity.tools.generic"><CODE>LoopTool.Action</CODE></A> should be taken.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;class</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.Equals.html" title="class in org.apache.velocity.tools.generic">LoopTool.Equals</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Simple condition that checks elements in the iterator
for equality to a specified Object.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;class</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic">LoopTool.ManagedIterator</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Iterator implementation that wraps a standard <CODE>Iterator</CODE>
and allows it to be prematurely stopped, skipped ahead, and
associated with a name for advanced nested loop control.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;class</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.SyncedIterator.html" title="class in org.apache.velocity.tools.generic">LoopTool.SyncedIterator</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Simple wrapper to make it easy to keep an arbitray Iterator
in sync with a <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic"><CODE>LoopTool.ManagedIterator</CODE></A>.</TD>
</TR>
</TABLE>
&nbsp;<!-- =========== FIELD SUMMARY =========== -->
<A NAME="field_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Field Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>private &nbsp;java.util.Stack&lt;<A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic">LoopTool.ManagedIterator</A>&gt;</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#iterators">iterators</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>private &nbsp;<A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic">LoopTool.ManagedIterator</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#last">last</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
</TABLE>
&nbsp;
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#LoopTool()">LoopTool</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
</TABLE>
&nbsp;
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;<A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic">LoopTool.ManagedIterator</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#findIterator(java.lang.String)">findIterator</A></B>(java.lang.String&nbsp;name)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Finds the <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic"><CODE>LoopTool.ManagedIterator</CODE></A> with the specified name
if it is in this instance's iterator stack.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.Object</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#get(java.lang.String)">get</A></B>(java.lang.String&nbsp;key)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This serves two purposes:
Getting the current value of a sync'ed iterator
Abbreviate syntax for properties of outer loops</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.Object</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#get(java.lang.String, java.lang.String)">get</A></B>(java.lang.String&nbsp;name,
java.lang.String&nbsp;synced)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Asks the loop with the specified name for the current value
of the specified sync'ed iterator, if any.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.Integer</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#getCount()">getCount</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the number of items the current loop has handled.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.Integer</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#getCount(java.lang.String)">getCount</A></B>(java.lang.String&nbsp;name)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the number of items the specified loop has handled.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#getDepth()">getDepth</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the number of loops currently on the stack.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.Boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#getFirst()">getFirst</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the result of <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#isFirst()"><CODE>isFirst()</CODE></A>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.Integer</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#getIndex()">getIndex</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the 0-based index of the item the current loop is handling.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.Integer</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#getIndex(java.lang.String)">getIndex</A></B>(java.lang.String&nbsp;name)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the 0-based index of the item the specified loop is handling.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected static&nbsp;java.util.Iterator</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#getIterator(java.lang.Object)">getIterator</A></B>(java.lang.Object&nbsp;obj)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Wraps access to <A HREF="../../../../../org/apache/velocity/tools/ClassUtils.html#getIterator(java.lang.Object)"><CODE>ClassUtils.getIterator(java.lang.Object)</CODE></A> is a
nice little try/catch block to prevent exceptions from
escaping into the template.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.Boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#getLast()">getLast</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the result of <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#isLast()"><CODE>isLast()</CODE></A>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic">LoopTool.ManagedIterator</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#getThis()">getThis</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the most recent <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic"><CODE>LoopTool.ManagedIterator</CODE></A> for this instance.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.Boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#isFirst()">isFirst</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns <code>true</code> if the current loop is on its first iteration.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.Boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#isFirst(java.lang.String)">isFirst</A></B>(java.lang.String&nbsp;name)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns <code>true</code> if the loop with the specified name
is on its first iteration.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.Boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#isLast()">isLast</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns <code>true</code> if the current loop is on its last iteration.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.Boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#isLast(java.lang.String)">isLast</A></B>(java.lang.String&nbsp;name)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns <code>true</code> if the loop with the specified name
is on its last iteration.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;<A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic">LoopTool.ManagedIterator</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#manage(java.util.Iterator, java.lang.String)">manage</A></B>(java.util.Iterator&nbsp;iterator,
java.lang.String&nbsp;name)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;<A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic">LoopTool.ManagedIterator</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#pop()">pop</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Don't let templates call this, but allow subclasses
and ManagedIterator to have access.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#skip(int)">skip</A></B>(int&nbsp;number)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Skips ahead the specified number of iterations (if possible).</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>private &nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#skip(int, org.apache.velocity.tools.generic.LoopTool.ManagedIterator)">skip</A></B>(int&nbsp;number,
<A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic">LoopTool.ManagedIterator</A>&nbsp;iterator)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#skip(int, java.lang.String)">skip</A></B>(int&nbsp;number,
java.lang.String&nbsp;name)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This tells the specified loop to skip ahead the specified number of
iterations.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#stop()">stop</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This tells the current loop to stop after the current iteration.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#stop(java.lang.String)">stop</A></B>(java.lang.String&nbsp;name)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This is just like <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#stop()"><CODE>stop()</CODE></A> except that the stop command is issued
<strong>only</strong> to the loop/iterator with the specified name.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#stopAll()">stopAll</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This is just like <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#stop()"><CODE>stop()</CODE></A> except that the stop command is issued
<strong>all</strong> the loops being watched by this tool.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#stopTo(java.lang.String)">stopTo</A></B>(java.lang.String&nbsp;name)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This is just like <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#stop(java.lang.String)"><CODE>stop(String)</CODE></A> except that the stop command is issued
both to the loop/iterator with the specified name and all loops nested within
it.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic">LoopTool.ManagedIterator</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#sync(java.lang.Object, java.lang.Object)">sync</A></B>(java.lang.Object&nbsp;main,
java.lang.Object&nbsp;synced)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic">LoopTool.ManagedIterator</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#watch(java.lang.Object)">watch</A></B>(java.lang.Object&nbsp;obj)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Tells the LoopTool to watch the specified Array, Collection, Map,
Iterator, Iterable, Enumeration or POJO with an iterator() method
while the template iterates over the values within it.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic">LoopTool.ManagedIterator</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#watch(java.lang.Object, java.lang.String)">watch</A></B>(java.lang.Object&nbsp;obj,
java.lang.String&nbsp;name)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This is just like <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#watch(java.lang.Object)"><CODE>watch(Object)</CODE></A> except that it also takes
a name which is given to the <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic"><CODE>LoopTool.ManagedIterator</CODE></A> that is returned.</TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD>
</TR>
</TABLE>
&nbsp;
<P>
<!-- ============ FIELD DETAIL =========== -->
<A NAME="field_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Field Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="iterators"><!-- --></A><H3>
iterators</H3>
<PRE>
private java.util.Stack&lt;<A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic">LoopTool.ManagedIterator</A>&gt; <B>iterators</B></PRE>
<DL>
<DL>
</DL>
</DL>
<HR>
<A NAME="last"><!-- --></A><H3>
last</H3>
<PRE>
private <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic">LoopTool.ManagedIterator</A> <B>last</B></PRE>
<DL>
<DL>
</DL>
</DL>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="LoopTool()"><!-- --></A><H3>
LoopTool</H3>
<PRE>
public <B>LoopTool</B>()</PRE>
<DL>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="watch(java.lang.Object)"><!-- --></A><H3>
watch</H3>
<PRE>
public <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic">LoopTool.ManagedIterator</A> <B>watch</B>(java.lang.Object&nbsp;obj)</PRE>
<DL>
<DD><p>Tells the LoopTool to watch the specified Array, Collection, Map,
Iterator, Iterable, Enumeration or POJO with an iterator() method
while the template iterates over the values within it.
</p>
<p>Under the covers, this is returning an iterable wrapper that
is also pushed onto this tool's stack. That allows this tool to
know which iterator to give later commands (i.e. stop() or skip()).
</p>
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>obj</CODE> - an object that Velocity's #foreach directive can iterate over
<DT><B>Returns:</B><DD>a <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic"><CODE>LoopTool.ManagedIterator</CODE></A> that this tool instance will track</DL>
</DD>
</DL>
<HR>
<A NAME="watch(java.lang.Object, java.lang.String)"><!-- --></A><H3>
watch</H3>
<PRE>
public <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic">LoopTool.ManagedIterator</A> <B>watch</B>(java.lang.Object&nbsp;obj,
java.lang.String&nbsp;name)</PRE>
<DL>
<DD>This is just like <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#watch(java.lang.Object)"><CODE>watch(Object)</CODE></A> except that it also takes
a name which is given to the <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic"><CODE>LoopTool.ManagedIterator</CODE></A> that is returned.
This allows the user to send stop or skip commands to that specific
iterator even when there are nested iterators within it that are being
watched. If the given name is <code>null</code>, then this will return
<code>null</code> even if the object can be watched. Provided names cannot
be <code>null</code>.
<P>
<DD><DL>
<DT><B>See Also:</B><DD><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#watch(java.lang.Object)"><CODE>watch(Object)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="sync(java.lang.Object, java.lang.Object)"><!-- --></A><H3>
sync</H3>
<PRE>
public <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic">LoopTool.ManagedIterator</A> <B>sync</B>(java.lang.Object&nbsp;main,
java.lang.Object&nbsp;synced)</PRE>
<DL>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="manage(java.util.Iterator, java.lang.String)"><!-- --></A><H3>
manage</H3>
<PRE>
protected <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic">LoopTool.ManagedIterator</A> <B>manage</B>(java.util.Iterator&nbsp;iterator,
java.lang.String&nbsp;name)</PRE>
<DL>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="stop()"><!-- --></A><H3>
stop</H3>
<PRE>
public void <B>stop</B>()</PRE>
<DL>
<DD>This tells the current loop to stop after the current iteration.
This is different from "break" common to most programming languages,
in that it does not immediately cease activity in the current iteration.
Instead, it merely tells the #foreach loop that this is the last time
around.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="stop(java.lang.String)"><!-- --></A><H3>
stop</H3>
<PRE>
public void <B>stop</B>(java.lang.String&nbsp;name)</PRE>
<DL>
<DD>This is just like <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#stop()"><CODE>stop()</CODE></A> except that the stop command is issued
<strong>only</strong> to the loop/iterator with the specified name.
If no such loop is found with that name, then no stop command is issued.
<P>
<DD><DL>
<DT><B>See Also:</B><DD><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#stop()"><CODE>stop()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="stopTo(java.lang.String)"><!-- --></A><H3>
stopTo</H3>
<PRE>
public void <B>stopTo</B>(java.lang.String&nbsp;name)</PRE>
<DL>
<DD>This is just like <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#stop(java.lang.String)"><CODE>stop(String)</CODE></A> except that the stop command is issued
both to the loop/iterator with the specified name and all loops nested within
it. If no such loop is found with that name, then no stop commands are
issued.
<P>
<DD><DL>
<DT><B>See Also:</B><DD><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#stop()"><CODE>stop()</CODE></A>,
<A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#stop(java.lang.String)"><CODE>stop(String)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="stopAll()"><!-- --></A><H3>
stopAll</H3>
<PRE>
public void <B>stopAll</B>()</PRE>
<DL>
<DD>This is just like <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#stop()"><CODE>stop()</CODE></A> except that the stop command is issued
<strong>all</strong> the loops being watched by this tool.
<P>
<DD><DL>
<DT><B>See Also:</B><DD><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#stop()"><CODE>stop()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="skip(int)"><!-- --></A><H3>
skip</H3>
<PRE>
public void <B>skip</B>(int&nbsp;number)</PRE>
<DL>
<DD>Skips ahead the specified number of iterations (if possible).
Since this is manual skipping (unlike the automatic skipping
provided by the likes of <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html#exclude(java.lang.Object)"><CODE>LoopTool.ManagedIterator.exclude(Object)</CODE></A>, any elements
skipped are still considered in the results returned by <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#getCount()"><CODE>getCount()</CODE></A>
and <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#isFirst()"><CODE>isFirst()</CODE></A>.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="skip(int, java.lang.String)"><!-- --></A><H3>
skip</H3>
<PRE>
public void <B>skip</B>(int&nbsp;number,
java.lang.String&nbsp;name)</PRE>
<DL>
<DD>This tells the specified loop to skip ahead the specified number of
iterations.
<P>
<DD><DL>
<DT><B>See Also:</B><DD><A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#skip(int)"><CODE>skip(int)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="skip(int, org.apache.velocity.tools.generic.LoopTool.ManagedIterator)"><!-- --></A><H3>
skip</H3>
<PRE>
private void <B>skip</B>(int&nbsp;number,
<A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic">LoopTool.ManagedIterator</A>&nbsp;iterator)</PRE>
<DL>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="isFirst()"><!-- --></A><H3>
isFirst</H3>
<PRE>
public java.lang.Boolean <B>isFirst</B>()</PRE>
<DL>
<DD>Returns <code>true</code> if the current loop is on its first iteration.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="isFirst(java.lang.String)"><!-- --></A><H3>
isFirst</H3>
<PRE>
public java.lang.Boolean <B>isFirst</B>(java.lang.String&nbsp;name)</PRE>
<DL>
<DD>Returns <code>true</code> if the loop with the specified name
is on its first iteration.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="getFirst()"><!-- --></A><H3>
getFirst</H3>
<PRE>
public java.lang.Boolean <B>getFirst</B>()</PRE>
<DL>
<DD>Returns the result of <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#isFirst()"><CODE>isFirst()</CODE></A>. Exists to allow $loop.first syntax.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="isLast()"><!-- --></A><H3>
isLast</H3>
<PRE>
public java.lang.Boolean <B>isLast</B>()</PRE>
<DL>
<DD>Returns <code>true</code> if the current loop is on its last iteration.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="isLast(java.lang.String)"><!-- --></A><H3>
isLast</H3>
<PRE>
public java.lang.Boolean <B>isLast</B>(java.lang.String&nbsp;name)</PRE>
<DL>
<DD>Returns <code>true</code> if the loop with the specified name
is on its last iteration.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="getLast()"><!-- --></A><H3>
getLast</H3>
<PRE>
public java.lang.Boolean <B>getLast</B>()</PRE>
<DL>
<DD>Returns the result of <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#isLast()"><CODE>isLast()</CODE></A>. Exists to allow $loop.last syntax.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="get(java.lang.String)"><!-- --></A><H3>
get</H3>
<PRE>
public java.lang.Object <B>get</B>(java.lang.String&nbsp;key)</PRE>
<DL>
<DD><p>This serves two purposes:
<ul><li>Getting the current value of a sync'ed iterator</li>
<li>Abbreviate syntax for properties of outer loops</li></ul></p>
<p>First, it searches all the loops being managed for one
with a sync'ed Iterator under the specified name and
returns the current value for that sync'ed iterator,
if any. If there is no sync'ed iterators or none with
that name, then this will check if the specified key
is requesting a "property" of an outer loop (e.g.
<code>$loop.count_foo</code> or <code>$loop.first_foo</code>).
This syntax is shorter and clearer than <code>$loop.getCount('foo')</code>.
If the key starts with a property name and ends with an outer loop
name, then the value of that property for that loop is returned.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="get(java.lang.String, java.lang.String)"><!-- --></A><H3>
get</H3>
<PRE>
public java.lang.Object <B>get</B>(java.lang.String&nbsp;name,
java.lang.String&nbsp;synced)</PRE>
<DL>
<DD>Asks the loop with the specified name for the current value
of the specified sync'ed iterator, if any.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="getIndex()"><!-- --></A><H3>
getIndex</H3>
<PRE>
public java.lang.Integer <B>getIndex</B>()</PRE>
<DL>
<DD>Returns the 0-based index of the item the current loop is handling.
So, if this is the first iteration, then the index will be 0. If
you <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#skip(int)"><CODE>skip(int)</CODE></A> ahead in this loop, those skipped iterations will
still be reflected in the index. If iteration has not begun, this
will return <code>null</code>.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="getIndex(java.lang.String)"><!-- --></A><H3>
getIndex</H3>
<PRE>
public java.lang.Integer <B>getIndex</B>(java.lang.String&nbsp;name)</PRE>
<DL>
<DD>Returns the 0-based index of the item the specified loop is handling.
So, if this is the first iteration, then the index will be 0. If
you <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#skip(int)"><CODE>skip(int)</CODE></A> ahead in this loop, those skipped iterations will
still be reflected in the index. If iteration has not begun, this
will return <code>null</code>.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="getCount()"><!-- --></A><H3>
getCount</H3>
<PRE>
public java.lang.Integer <B>getCount</B>()</PRE>
<DL>
<DD>Returns the number of items the current loop has handled. So, if this
is the first iteration, then the count will be 1. If you <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#skip(int)"><CODE>skip(int)</CODE></A>
ahead in this loop, those skipped iterations will still be included in
the count.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="getCount(java.lang.String)"><!-- --></A><H3>
getCount</H3>
<PRE>
public java.lang.Integer <B>getCount</B>(java.lang.String&nbsp;name)</PRE>
<DL>
<DD>Returns the number of items the specified loop has handled. So, if this
is the first iteration, then the count will be 1. If you <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.html#skip(int)"><CODE>skip(int)</CODE></A>
ahead in this loop, those skipped iterations will still be included in
the count.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="getThis()"><!-- --></A><H3>
getThis</H3>
<PRE>
public <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic">LoopTool.ManagedIterator</A> <B>getThis</B>()</PRE>
<DL>
<DD>Returns the most recent <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic"><CODE>LoopTool.ManagedIterator</CODE></A> for this instance.
This can be used to access properties like the count, index,
isFirst, isLast, etc which would otherwise fail on the last item
in a loop due to the necessity of popping iterators off the
stack when the last item is retrieved. (See VELTOOLS-124)
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="getDepth()"><!-- --></A><H3>
getDepth</H3>
<PRE>
public int <B>getDepth</B>()</PRE>
<DL>
<DD>Returns the number of loops currently on the stack.
This is only useful for debugging, as iterators are
popped off the stack at the start of their final iteration,
making this frequently "incorrect".
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="findIterator(java.lang.String)"><!-- --></A><H3>
findIterator</H3>
<PRE>
protected <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic">LoopTool.ManagedIterator</A> <B>findIterator</B>(java.lang.String&nbsp;name)</PRE>
<DL>
<DD>Finds the <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic"><CODE>LoopTool.ManagedIterator</CODE></A> with the specified name
if it is in this instance's iterator stack.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="pop()"><!-- --></A><H3>
pop</H3>
<PRE>
protected <A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.ManagedIterator.html" title="class in org.apache.velocity.tools.generic">LoopTool.ManagedIterator</A> <B>pop</B>()</PRE>
<DL>
<DD>Don't let templates call this, but allow subclasses
and ManagedIterator to have access.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="getIterator(java.lang.Object)"><!-- --></A><H3>
getIterator</H3>
<PRE>
protected static java.util.Iterator <B>getIterator</B>(java.lang.Object&nbsp;obj)</PRE>
<DL>
<DD>Wraps access to <A HREF="../../../../../org/apache/velocity/tools/ClassUtils.html#getIterator(java.lang.Object)"><CODE>ClassUtils.getIterator(java.lang.Object)</CODE></A> is a
nice little try/catch block to prevent exceptions from
escaping into the template. In the case of such problems,
this will return <code>null</code>.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../../org/apache/velocity/tools/generic/LocaleConfig.html" title="class in org.apache.velocity.tools.generic"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../../org/apache/velocity/tools/generic/LoopTool.Action.html" title="enum in org.apache.velocity.tools.generic"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../index.html?org/apache/velocity/tools/generic/LoopTool.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="LoopTool.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;<A HREF="#nested_class_summary">NESTED</A>&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<HR>
Copyright (c) 2003-2007 Apache Software Foundation
</BODY>
</HTML>