Example usage for org.apache.commons.collections.iterators EmptyIterator INSTANCE

List of usage examples for org.apache.commons.collections.iterators EmptyIterator INSTANCE

Introduction

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

Prototype

Iterator INSTANCE

To view the source code for org.apache.commons.collections.iterators EmptyIterator INSTANCE.

Click Source Link

Document

Singleton instance of the iterator.

Usage

From source file:edu.cornell.mannlib.vitro.webapp.dao.jena.EmptyReifier.java

@Override
public ExtendedIterator<Triple> findEither(TripleMatch arg0, boolean arg1) {
    return WrappedIterator.create(EmptyIterator.INSTANCE);
}

From source file:edu.cornell.mannlib.vitro.webapp.dao.jena.EmptyReifier.java

@Override
public ExtendedIterator<Triple> findExposed(TripleMatch arg0) {
    return WrappedIterator.create(EmptyIterator.INSTANCE);
}

From source file:com.phoenixst.collections.AbstractSingletonCollection.java

public Iterator iterator() {
    return isEmpty() ? EmptyIterator.INSTANCE : new IteratorImpl(this);
}

From source file:com.intel.hadoop.graphbuilder.demoapps.wikipedia.linkgraph.LinkGraphTokenizer.java

@Override
public Iterator<Edge<StringType, EmptyType>> getEdges() {
    if (links.isEmpty())
        return EmptyIterator.INSTANCE;

    elist.clear();// w w  w. java 2  s.co  m
    Iterator<String> iter = links.iterator();
    while (iter.hasNext()) {
        elist.add(new Edge<StringType, EmptyType>(new StringType(title), new StringType(iter.next()),
                EmptyType.INSTANCE));
    }
    return elist.iterator();
}

From source file:com.phoenixst.collections.CartesianProduct.java

/**
 *  Returns an <code>Iterator</code> over the elements of the
 *  product of the specified collections with the left one
 *  controlling the outer loop.  This factory method is preferable
 *  when the left collection is more expensive to use than the
 *  right one.//from   w w w . ja v a  2 s .c  o m
 */
public static final Iterator leftIterator(Collection left, Collection right) {
    if (left == null) {
        throw new IllegalArgumentException("Left operand is null.");
    }
    if (right == null) {
        throw new IllegalArgumentException("Right operand is null.");
    }
    Iterator leftIter = left.iterator();
    // We have to check for this case, because passing an empty
    // right collection to the Iterator constructor would result
    // in incorrect behavior for hasNext() as it is written.  The
    // alternative is a more complex Iterator implementation.
    if (!leftIter.hasNext() || right.isEmpty()) {
        return EmptyIterator.INSTANCE;
    }
    return new LeftIterator(leftIter, right);
}

From source file:com.bah.culvert.tableadapters.HBaseLocalTableAdapter.java

@Override
public Iterator<Result> get(Get get) {
    // Get the range list
    List<CRange> culvertRangeList = get.getRanges();

    // Only scan the tables if we have a range
    if (culvertRangeList.size() > 0) {

        List<Result> results = new ArrayList<Result>();

        // Get the reference to the HRegion
        HRegion hregion = null;/* www. ja  v a2 s. c  o m*/
        try {
            hregion = ((RegionCoprocessorEnvironment) this.ENDPOINT.getEnvironment()).getRegion();
        } catch (Exception e) {
            throw new RuntimeException(this.getTableName() + " Unable to get HRegion", e);
        }
        try {
            // Loop through the ranges
            for (CRange cr : culvertRangeList) {
                Scan scan = new Scan(cr.getStart(), cr.getEnd());
                // add columns to the scanner
                for (CColumn cc : get.getColumns()) {
                    scan.addColumn(cc.getColumnFamily(), cc.getColumnQualifier());
                }
                InternalScanner scanner = hregion.getScanner(scan);
                try {
                    List<KeyValue> curVals = new ArrayList<KeyValue>();
                    boolean hasMore = false;
                    do {
                        curVals.clear();
                        hasMore = scanner.next(curVals);
                        KeyValue kv = curVals.get(0);
                        results.add(new Result(kv.getRow(), new CKeyValue(kv.getKey(), kv.getFamily(),
                                kv.getQualifier(), kv.getTimestamp(), kv.getValue())));
                    } while (hasMore);
                } finally {
                    scanner.close();
                }
            }
        } catch (IOException e) {
            throw new RuntimeException(this.getTableName() + " Failed to iterate through table", e);
        }

        return results.iterator();
    }
    // There were no ranges in the list, so return an empty iterator
    return EmptyIterator.INSTANCE;
}

From source file:com.phoenixst.collections.CartesianProduct.java

/**
 *  Returns an <code>Iterator</code> over the elements of the
 *  product of the specified collections with the right one
 *  controlling the outer loop.  This factory method is preferable
 *  when the right collection is more expensive to use than the
 *  left one.//  www  .  ja va2s  .  c om
 */
public static final Iterator rightIterator(Collection left, Collection right) {
    if (left == null) {
        throw new IllegalArgumentException("Left operand is null.");
    }
    if (right == null) {
        throw new IllegalArgumentException("Right operand is null.");
    }
    Iterator rightIter = right.iterator();
    // We have to check for this case, because passing an empty
    // left collection to the Iterator constructor would result
    // in incorrect behavior for hasNext() as it is written.  The
    // alternative is a more complex Iterator implementation.
    if (!rightIter.hasNext() || left.isEmpty()) {
        return EmptyIterator.INSTANCE;
    }
    return new RightIterator(left, rightIter);
}

From source file:com.modelsolv.kaboom.model.resource.nativeImpl.RDMPropertyCollection.java

@SuppressWarnings("unchecked")
@Override
public Iterator<RDMProperty> iterator() {
    return isEmpty() ? EmptyIterator.INSTANCE : rdmProperties.iterator();
}

From source file:de.csw.expertfinder.ExpertFinder.java

/**
 * Returns an iterator over all super classes of the class specified by the
 * given uri or an empty iterator if no such class exists or if it has no
 * super classes.//from ww w.  j a  v a 2s  .co  m
 * 
 * @param uri
 * @return an iterator over all super classes of the class specified by the
 *         given uri or an empty iterator if no such class exists or if it
 *         has no super classes.
 */
@SuppressWarnings("unchecked")
public Iterator<OntClass> getSuperClasses(String uri) {
    OntModel model = OntologyIndex.get().getModel();
    OntClass clazz = model.getOntClass(uri);
    if (clazz != null) {
        return clazz.listSuperClasses(true);
    }

    return EmptyIterator.INSTANCE;
}

From source file:com.intel.hadoop.graphbuilder.demoapps.wikipedia.docwordgraph.WordCountGraphTokenizer.java

@Override
public Iterator<Edge<StringType, StringType>> getEdges() {
    if (counts.isEmpty())
        return EmptyIterator.INSTANCE;

    ArrayList<Edge<StringType, StringType>> elist = new ArrayList<Edge<StringType, StringType>>(counts.size());
    Iterator<Entry<String, Integer>> iter = counts.entrySet().iterator();
    while (iter.hasNext()) {
        Entry<String, Integer> e = iter.next();
        elist.add(new Edge<StringType, StringType>(new StringType(id), new StringType(e.getKey()),
                new StringType(e.getValue().toString())));
    }//from w  ww .  jav a 2 s  .c  o  m
    return elist.iterator();
}