Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

id2050353041

...

id2050353055

...

id2050353040

On this page

Table of Contents
maxLevel4
minLevel3

...

id2050353045

...

$Loop is used with the #foreach loops. It wraps a list to let you specify a condition to terminate the loop and reuse the same list in a different loop. The following example shows how to use

...

$Loop.

Code Block
languagetext
#set( 

...

$list = [1

...

..7] )
#set( $others = [3..10] )
#foreach( $item in $loopTool.watch($list).sync($others, 'other') )
$item -> $loopTool.other
#if( $item >= 5 )$loopTool.stop()#end
#end

...


Output
------
1 -> 3
2 -> 4
3 -> 5

...


4 -> 6
5 -> 7

$Loop

...

.wrap( list )

Wrap a list with the tool.


Name Type Description 
Parameter(s) list java.util.List An array or a
list instance. 
 Return

...

LoopTool Return an

...

LoopTool
instance. 

...

$<LoopTool instance>.hasMore()

Check if the iteration has more elements.


Name Type Description 
Return boolean Return true if there
are more elements
in the wrapped list. 

...

$<LoopTool instance>.more()

Ask for the next element in the list.


Name Type Description 
Return  java.lang.Object An element
instance. 

...

$<LoopTool instance>.remove()

Remove the current element from the list.

...

$<LoopTool instance>.reset()

Reset the wrapper so that it will start over at the beginning of the list.

...

$<LoopTool instance>.stop()

Put a condition to break off a loop.

...

$<LoopTool instance>.toString()

Return an object as a string.