jodd.util
Class LoopIterator

java.lang.Object
  extended by jodd.util.LoopIterator

public class LoopIterator
extends java.lang.Object

Loop iterator. Should be used as in while construct: while (loopIterator.next()) { // do something }


Field Summary
protected  int count
           
protected  int end
           
protected  boolean first
           
protected  boolean last
           
protected  boolean looping
           
protected  int modulus
           
protected  int start
           
protected  int step
           
protected  int value
           
 
Constructor Summary
LoopIterator(int start, int end)
           
LoopIterator(int start, int end, int step)
           
LoopIterator(int start, int end, int step, int modulus)
           
 
Method Summary
 int getCount()
          Returns current item count (1-based).
 int getIndex()
          Returns current item index (0-based).
 int getIndexModulus()
          Returns modulus of current index.
 int getModulus()
          Returns modulus of current count.
 int getModulusValue()
          Returns modulus value.
 int getValue()
          Returns current loop value.
 boolean isEven()
          Returns true if current count is even.
 boolean isFirst()
          Returns true if current item is the first one.
 boolean isLast()
          Returns true if current item is the last one.
protected  boolean isLastIteration(int value)
           
 boolean isOdd()
          Returns true if current count is odd.
 int modulus(int operand)
          Calculates modulus of current count.
 boolean next()
          Iterates to next value at the beginning of the loop.
 void reset()
          Resets the loop from the beginning.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

start

protected final int start

end

protected final int end

step

protected final int step

modulus

protected final int modulus

first

protected boolean first

last

protected boolean last

value

protected int value

count

protected int count

looping

protected final boolean looping
Constructor Detail

LoopIterator

public LoopIterator(int start,
                    int end)

LoopIterator

public LoopIterator(int start,
                    int end,
                    int step)

LoopIterator

public LoopIterator(int start,
                    int end,
                    int step,
                    int modulus)
Method Detail

getCount

public int getCount()
Returns current item count (1-based).


getIndex

public int getIndex()
Returns current item index (0-based).


getValue

public int getValue()
Returns current loop value.


isEven

public boolean isEven()
Returns true if current count is even.


isOdd

public boolean isOdd()
Returns true if current count is odd.


modulus

public int modulus(int operand)
Calculates modulus of current count.


getModulus

public int getModulus()
Returns modulus of current count.


getModulusValue

public int getModulusValue()
Returns modulus value.


getIndexModulus

public int getIndexModulus()
Returns modulus of current index.


isFirst

public boolean isFirst()
Returns true if current item is the first one.


isLast

public boolean isLast()
Returns true if current item is the last one.


next

public boolean next()
Iterates to next value at the beginning of the loop.


reset

public void reset()
Resets the loop from the beginning.


isLastIteration

protected boolean isLastIteration(int value)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2003-2012 Jodd Team