Example usage for org.apache.commons.collections.iterators SingletonListIterator SingletonListIterator

List of usage examples for org.apache.commons.collections.iterators SingletonListIterator SingletonListIterator

Introduction

In this page you can find the example usage for org.apache.commons.collections.iterators SingletonListIterator SingletonListIterator.

Prototype

public SingletonListIterator(Object object) 

Source Link

Document

Constructs a new SingletonListIterator.

Usage

From source file:edu.scripps.fl.pipeline.UngroupStage.java

@Override
public void process(Object obj) throws StageException {
    Iterator<Object> iterator = null;
    if (obj instanceof Iterator) // iterator itself.
        iterator = (Iterator<Object>) obj;
    else if (obj instanceof Iterable) // collections etc.
        iterator = ((Iterable<Object>) obj).iterator();
    else if (obj.getClass().isArray()) // arrays
        iterator = new ArrayIterator(obj);
    else/* ww w  . java 2s . c  o m*/
        iterator = new SingletonListIterator(obj);

    while (iterator.hasNext())
        emit(iterator.next());
}

From source file:edu.scripps.fl.pipeline.GroupStage.java

@Override
public void process(Object obj) throws StageException {
    Iterator<Object> iterator = null;
    if (obj instanceof Iterator) // iterator itself.
        iterator = (Iterator<Object>) obj;
    else if (obj instanceof Iterable) // collections etc.
        iterator = ((Iterable<Object>) obj).iterator();
    else if (obj.getClass().isArray()) // arrays
        iterator = new ArrayIterator(obj);
    else//ww w . j a  v a2  s. com
        iterator = new SingletonListIterator(obj);

    List<Object> list = new ArrayList<Object>(getGroupSize());
    while (true) {
        if (!iterator.hasNext())
            break;
        if (list.size() < getGroupSize())
            list.add(iterator.next());
        else {
            emit(list);
            list = new ArrayList<Object>(getGroupSize());
        }
    }

    if (list.size() > 0)
        emit(list);
}

From source file:org.apache.usergrid.services.ServicePayload.java

@SuppressWarnings("unchecked")
public Iterator<Map<String, Object>> payloadIterator() {
    if (isBatch()) {
        return batch.iterator();
    }//from   w  w  w.  j  a  v a 2 s  . c  o m
    if (properties != null) {
        return new SingletonListIterator(properties);
    }
    return EmptyIterator.INSTANCE;
}

From source file:org.lockss.filter.pdf.TransformFirstPage.java

protected ListIterator /* of PdfPage */ getSelectedPages(PdfDocument pdfDocument) throws IOException {
    return new SingletonListIterator(pdfDocument.getPage(0));
}