FileDocCategorySizeDatePackage
Counter.javaAPI DocExample3006Mon Jul 23 13:26:56 BST 2007org.apache.struts2.util

Counter

public class Counter extends Object implements Serializable, Iterator
A bean that can be used to keep track of a counter.

Since it is an Iterator it can be used by the iterator tag

Fields Summary
private static final long
serialVersionUID
boolean
wrap
long
first
long
current
long
interval
long
last
Constructors Summary
Methods Summary
public longgetCurrent()

        return current;
    
public longgetFirst()

        return first;
    
public longgetInterval()

        return interval;
    
public longgetLast()

        return last;
    
public longgetNext()

        long next = current;
        current += interval;

        if (wrap && (current > last)) {
            current -= ((1 + last) - first);
        }

        return next;
    
public longgetPrevious()

        current -= interval;

        if (wrap && (current < first)) {
            current += (last - first + 1);
        }

        return current;
    
public booleanhasNext()

        return ((last == -1) || wrap) ? true : (current <= last);
    
public booleanisWrap()

        return wrap;
    
public java.lang.Objectnext()

        return new Long(getNext());
    
public voidremove()

        // Do nothing
    
public voidsetAdd(long addition)



        
        current += addition;
    
public voidsetCurrent(long current)

        this.current = current;
    
public voidsetFirst(long first)

        this.first = first;
        current = first;
    
public voidsetInterval(long interval)

        this.interval = interval;
    
public voidsetLast(long last)

        this.last = last;
    
public voidsetWrap(boolean wrap)

        this.wrap = wrap;