org.shredzone.repowatch.web.util
Class Sequencer

java.lang.Object
  extended by org.shredzone.repowatch.web.util.Sequencer

public class Sequencer
extends Object

A helper class that returns an endless sequence of the given item set. This is useful in JSPs, e.g. for rendering each row of a table in a different color.

Example:

 <% pageContext.setAttribute("sequence", new Sequencer("oddrow", "evenrow")); %>
 <c:forEach var="entry" items="${entryList}">
   <tr class="${sequence.next}">
     <td><c:out value="${entry.name}"/></td>
   </tr>
 </c:forEach>
 

Version:
$Revision: 317 $

Constructor Summary
Sequencer(String... sequence)
          Creates a new Sequencer with the given sequence.
 
Method Summary
 String getNext()
          Gets the next entry of the sequence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sequencer

public Sequencer(String... sequence)
Creates a new Sequencer with the given sequence.

Parameters:
sequence - The sequence of strings to be used. Must have at least one entry.
Method Detail

getNext

public String getNext()
Gets the next entry of the sequence. If the last entry was returned, it will start again with the first entry.

Returns:
Sequence entry


Copyright © 2007-2011 shredzone.org. All Rights Reserved.