Java Code Examples for java.util.Collections.emptyIterator()

The following are Jave code examples for showing how to use emptyIterator() of the java.util.Collections class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: sstable-adaptor   File: CFMetaData.java   View Source Code Vote up 6 votes
public Iterator<ColumnDefinition> allColumnsInSelectOrder()
{
    final boolean isStaticCompactTable = isStaticCompactTable();
    final boolean noNonPkColumns = isCompactTable() && CompactTables.hasEmptyCompactValue(this);
    return new AbstractIterator<ColumnDefinition>()
    {
        private final Iterator<ColumnDefinition> partitionKeyIter = partitionKeyColumns.iterator();
        private final Iterator<ColumnDefinition> clusteringIter = isStaticCompactTable ? Collections.<ColumnDefinition>emptyIterator() : clusteringColumns.iterator();
        private final Iterator<ColumnDefinition> otherColumns = noNonPkColumns
                ? Collections.<ColumnDefinition>emptyIterator()
                : (isStaticCompactTable
                ?  partitionColumns.statics.selectOrderIterator()
                :  partitionColumns.selectOrderIterator());

        protected ColumnDefinition computeNext()
        {
            if (partitionKeyIter.hasNext())
                return partitionKeyIter.next();

            if (clusteringIter.hasNext())
                return clusteringIter.next();

            return otherColumns.hasNext() ? otherColumns.next() : endOfData();
        }
    };
}
 
Example 2
Project: OpenJSharp   File: ImageIO.java   View Source Code Vote up 6 votes
/**
 * Returns an <code>Iterator</code> containing all currently
 * registered <code>ImageReader</code>s that claim to be able to
 * decode files with the given suffix.
 *
 * @param fileSuffix a <code>String</code> containing a file
 * suffix (<i>e.g.</i>, "jpg" or "tiff").
 *
 * @return an <code>Iterator</code> containing
 * <code>ImageReader</code>s.
 *
 * @exception IllegalArgumentException if <code>fileSuffix</code>
 * is <code>null</code>.
 *
 * @see javax.imageio.spi.ImageReaderSpi#getFileSuffixes
 */
public static Iterator<ImageReader>
    getImageReadersBySuffix(String fileSuffix)
{
    if (fileSuffix == null) {
        throw new IllegalArgumentException("fileSuffix == null!");
    }
    // Ensure category is present
    Iterator iter;
    try {
        iter = theRegistry.getServiceProviders(ImageReaderSpi.class,
                               new ContainsFilter(readerFileSuffixesMethod,
                                                  fileSuffix),
                                          true);
    } catch (IllegalArgumentException e) {
        return Collections.emptyIterator();
    }
    return new ImageReaderIterator(iter);
}
 
Example 3
Project: openjdk-jdk10   File: ImageIO.java   View Source Code Vote up 6 votes
/**
 * Returns an {@code Iterator} containing all currently
 * registered {@code ImageWriter}s that claim to be able to
 * encode the named format.
 *
 * @param formatName a {@code String} containing the informal
 * name of a format (<i>e.g.</i>, "jpeg" or "tiff".
 *
 * @return an {@code Iterator} containing
 * {@code ImageWriter}s.
 *
 * @exception IllegalArgumentException if {@code formatName} is
 * {@code null}.
 *
 * @see javax.imageio.spi.ImageWriterSpi#getFormatNames
 */
public static Iterator<ImageWriter>
    getImageWritersByFormatName(String formatName)
{
    if (formatName == null) {
        throw new IllegalArgumentException("formatName == null!");
    }
    Iterator<ImageWriterSpi> iter;
    // Ensure category is present
    try {
        iter = theRegistry.getServiceProviders(ImageWriterSpi.class,
                                new ContainsFilter(writerFormatNamesMethod,
                                                   formatName),
                                        true);
    } catch (IllegalArgumentException e) {
        return Collections.emptyIterator();
    }
    return new ImageWriterIterator(iter);
}
 
Example 4
Project: openjdk-jdk10   File: ScriptRuntime.java   View Source Code Vote up 6 votes
/**
 * Returns an iterator over property values used in the {@code for each...in} statement. Aside from built-in JS
 * objects, it also operates on Java arrays, any {@link Iterable}, as well as on {@link Map} objects, iterating over
 * map values.
 * @param obj object to iterate on.
 * @return iterator over the object's property values.
 */
public static Iterator<?> toValueIterator(final Object obj) {
    if (obj instanceof ScriptObject) {
        return ((ScriptObject)obj).valueIterator();
    }

    if (obj instanceof JSObject) {
        return ((JSObject)obj).values().iterator();
    }

    final Iterator<?> itr = iteratorForJavaArrayOrList(obj);
    if (itr != null) {
        return itr;
    }

    if (obj instanceof Map) {
        return ((Map<?,?>)obj).values().iterator();
    }

    final Object wrapped = Global.instance().wrapAsObject(obj);
    if (wrapped instanceof ScriptObject) {
        return ((ScriptObject)wrapped).valueIterator();
    }

    return Collections.emptyIterator();
}
 
Example 5
Project: jdk8u-jdk   File: ImageIO.java   View Source Code Vote up 6 votes
/**
 * Returns an <code>Iterator</code> containing all currently
 * registered <code>ImageWriter</code>s that claim to be able to
 * encode files with the given MIME type.
 *
 * @param MIMEType a <code>String</code> containing a file
 * suffix (<i>e.g.</i>, "image/jpeg" or "image/x-bmp").
 *
 * @return an <code>Iterator</code> containing <code>ImageWriter</code>s.
 *
 * @exception IllegalArgumentException if <code>MIMEType</code> is
 * <code>null</code>.
 *
 * @see javax.imageio.spi.ImageWriterSpi#getMIMETypes
 */
public static Iterator<ImageWriter>
    getImageWritersByMIMEType(String MIMEType)
{
    if (MIMEType == null) {
        throw new IllegalArgumentException("MIMEType == null!");
    }
    Iterator iter;
    // Ensure category is present
    try {
        iter = theRegistry.getServiceProviders(ImageWriterSpi.class,
                                  new ContainsFilter(writerMIMETypesMethod,
                                                     MIMEType),
                                        true);
    } catch (IllegalArgumentException e) {
        return Collections.emptyIterator();
    }
    return new ImageWriterIterator(iter);
}
 
Example 6
Project: kafka-0.11.0.0-src-with-comment   File: ThreadCache.java   View Source Code Vote up 5 votes
public MemoryLRUCacheBytesIterator range(final String namespace, final Bytes from, final Bytes to) {
    final NamedCache cache = getCache(namespace);
    if (cache == null) {
        return new MemoryLRUCacheBytesIterator(Collections.<Bytes>emptyIterator(), new NamedCache(namespace, this.metrics));
    }
    return new MemoryLRUCacheBytesIterator(cache.keyRange(from, to), cache);
}
 
Example 7
Project: bitsy   File: BitsyVertex.java   View Source Code Vote up 5 votes
@Override
public <V> Iterator<VertexProperty<V>> properties(String... propertyKeys) {
       ArrayList<VertexProperty<V>> ans = new ArrayList<VertexProperty<V>>();

       if (propertyKeys.length == 0) {
       	if (this.properties == null) return Collections.emptyIterator();
       	propertyKeys = this.properties.getPropertyKeys();
       }

       for (String key : propertyKeys) {
       	VertexProperty<V> prop = property(key);
           if (prop.isPresent()) ans.add(prop);
       }
       return ans.iterator();
}
 
Example 8
Project: OpenJSharp   File: ScriptRuntime.java   View Source Code Vote up 5 votes
/**
 * Returns an iterator over property identifiers used in the {@code for...in} statement. Note that the ECMAScript
 * 5.1 specification, chapter 12.6.4. uses the terminology "property names", which seems to imply that the property
 * identifiers are expected to be strings, but this is not actually spelled out anywhere, and Nashorn will in some
 * cases deviate from this. Namely, we guarantee to always return an iterator over {@link String} values for any
 * built-in JavaScript object. We will however return an iterator over {@link Integer} objects for native Java
 * arrays and {@link List} objects, as well as arbitrary objects representing keys of a {@link Map}. Therefore, the
 * expression {@code typeof i} within a {@code for(i in obj)} statement can return something other than
 * {@code string} when iterating over native Java arrays, {@code List}, and {@code Map} objects.
 * @param obj object to iterate on.
 * @return iterator over the object's property names.
 */
public static Iterator<?> toPropertyIterator(final Object obj) {
    if (obj instanceof ScriptObject) {
        return ((ScriptObject)obj).propertyIterator();
    }

    if (obj != null && obj.getClass().isArray()) {
        return new RangeIterator(Array.getLength(obj));
    }

    if (obj instanceof JSObject) {
        return ((JSObject)obj).keySet().iterator();
    }

    if (obj instanceof List) {
        return new RangeIterator(((List<?>)obj).size());
    }

    if (obj instanceof Map) {
        return ((Map<?,?>)obj).keySet().iterator();
    }

    final Object wrapped = Global.instance().wrapAsObject(obj);
    if (wrapped instanceof ScriptObject) {
        return ((ScriptObject)wrapped).propertyIterator();
    }

    return Collections.emptyIterator();
}
 
Example 9
Project: HardVox   File: CommandParser.java   View Source Code Vote up 5 votes
public Iterator<String> getCompletions(ParserContext context) {
    int argIndex = argIndex(context);
    CommandArgument<?> arg = arg(argIndex);
    if (arg == null) {
        return Collections.emptyIterator();
    }
    ArgumentContext argCtx = context.contextAt(argIndex);
    if (!arg.validText(argCtx)) {
        return Collections.emptyIterator();
    }
    return arg.getCompletions(argCtx);
}
 
Example 10
Project: kafka-0.11.0.0-src-with-comment   File: ThreadCache.java   View Source Code Vote up 5 votes
public MemoryLRUCacheBytesIterator all(final String namespace) {
    final NamedCache cache = getCache(namespace);
    if (cache == null) {
        return new MemoryLRUCacheBytesIterator(Collections.<Bytes>emptyIterator(), new NamedCache(namespace, this.metrics));
    }
    return new MemoryLRUCacheBytesIterator(cache.allKeys(), cache);
}
 
Example 11
Project: s3-inventory-usage-examples   File: WriteNewInventoryReportFunc.java   View Source Code Vote up 5 votes
@Override
public Iterator<InventoryManifest.Locator> call(Iterator<InventoryReportLine> inventoryReport) throws IOException {
    // Exclude the empty iterators which are caused by the mapPartitions
    // when one partition only owns empty InventoryReportLine iterator after the filtering
    if (!inventoryReport.hasNext()){
        return Collections.emptyIterator();
    }
    List<InventoryReportLine> inventoryReportLineList = IteratorUtils.toList(inventoryReport);
    InventoryReportLineWriter scvWriter = new InventoryReportLineWriter(s3ClientFactory.getValue().get(),
            destBucket, destPrefix, srcBucket, manifestStorage);
    return Collections.singletonList(scvWriter.writeCsvFile(inventoryReportLineList)).iterator();
}
 
Example 12
Project: dremio-oss   File: ValueExpressions.java   View Source Code Vote up 4 votes
@Override
public Iterator<LogicalExpression> iterator() {
  return Collections.emptyIterator();
}
 
Example 13
Project: QDrill   File: ScanPrel.java   View Source Code Vote up 4 votes
@Override
public Iterator<Prel> iterator() {
  return Collections.emptyIterator();
}
 
Example 14
Project: dremio-oss   File: ValueExpressions.java   View Source Code Vote up 4 votes
@Override
public Iterator<LogicalExpression> iterator() {
  return Collections.emptyIterator();
}
 
Example 15
Project: LT-ABSA   File: ListDoubleSplit.java   View Source Code Vote up 4 votes
public Iterator<URI> locationsIterator() {
    return Collections.emptyIterator();
}
 
Example 16
Project: dremio-oss   File: ValueExpressions.java   View Source Code Vote up 4 votes
@Override
public Iterator<LogicalExpression> iterator() {
  return Collections.emptyIterator();
}
 
Example 17
Project: QDrill   File: JdbcPrel.java   View Source Code Vote up 4 votes
@Override
public Iterator<Prel> iterator() {
  return Collections.emptyIterator();
}
 
Example 18
Project: kafka-0.11.0.0-src-with-comment   File: SegmentedBytesStoreStub.java   View Source Code Vote up 4 votes
@Override
public KeyValueIterator<Bytes, byte[]> fetch(Bytes keyFrom, Bytes keyTo, long from, long to) {
    fetchCalled = true;
    return new KeyValueIteratorStub<>(Collections.<KeyValue<Bytes, byte[]>>emptyIterator());
}
 
Example 19
Project: hdt-gremlin   File: HDTEdge.java   View Source Code Vote up 4 votes
@Override
public <V> Iterator<Property<V>> properties(String... propertyKeys) {
	// Edges have no properties in RDF
	return Collections.emptyIterator();
}
 
Example 20
Project: microbean-helm   File: StreamOrientedChartLoader.java   View Source Code Vote up 2 votes
/**
 * Returns the return value of the {@link
 * Collections#emptyIterator()} method when invoked.
 *
 * <p>This method never returns {@code null}.</p>
 *
 * @return an empty {@link Iterator}; never {@code null}
 */
@Override
public final Iterator<Entry<String, InputStream>> iterator() {
  return Collections.emptyIterator();
}