FileDocCategorySizeDatePackage
MergeIteratorFilter.javaAPI DocExample2869Mon Jul 23 13:26:56 BST 2007org.apache.struts2.util

MergeIteratorFilter

public class MergeIteratorFilter extends IteratorFilterSupport implements com.opensymphony.xwork2.Action, Iterator
A bean that takes several iterators and outputs the merge of them. Used by MergeIteratorTag.
see
org.apache.struts2.views.jsp.iterator.MergeIteratorTag
see
org.apache.struts2.components.MergeIterator

Fields Summary
List
iterators
List
sources
int
idx
Constructors Summary
Methods Summary
public java.lang.Stringexecute()

        // Make source transformations
        for (int i = 0; i < sources.size(); i++) {
            Object source = sources.get(i);
            iterators.add(getIterator(source));
        }

        return SUCCESS;
    
public booleanhasNext()

        while (iterators.size() > 0) {
            if (((Iterator) iterators.get(idx)).hasNext()) {
                return true;
            } else {
                iterators.remove(idx);

                if (iterators.size() > 0) {
                    idx = idx % iterators.size();
                }
            }
        }

        return false;
    
public java.lang.Objectnext()

        try {
            return ((Iterator) iterators.get(idx)).next();
        } finally {
            idx = (idx + 1) % iterators.size();
        }
    
public voidremove()

        throw new UnsupportedOperationException("Remove is not supported in MergeIteratorFilter.");
    
public voidsetSource(java.lang.Object anIterator)



    // Public --------------------------------------------------------
        
        sources.add(anIterator);