Example usage for java.lang Iterable Iterable

List of usage examples for java.lang Iterable Iterable

Introduction

In this page you can find the example usage for java.lang Iterable Iterable.

Prototype

Iterable

Source Link

Usage

From source file:com.iorga.iraj.security.HttpServletRequestToSign.java

@Override
public Iterable<String> getHeaders(final String name) {
    return new Iterable<String>() {
        @SuppressWarnings("unchecked")
        @Override/*ww  w.j a v a  2  s .  c om*/
        public Iterator<String> iterator() {
            return new EnumerationIterator(httpServletRequest.getHeaders(name));
        }
    };
}

From source file:de.zib.gndms.kit.configlet.PublishConfiglet.java

/**
 *  Updates {@link PublishConfiglet#publishingSites} with the newest publishers. Should be invoked by {@link PublishConfiglet#update}
 *//*from  w  ww  . jav  a 2s. c om*/
private void configPublishingSites() {
    try {
        final ConfigProvider mapConfig = getMapConfig().getDynArrayOption("publishers");
        publishingSites = new Iterable<String>() {
            public Iterator<String> iterator() {
                final Iterator<String> keys = mapConfig.dynArrayKeys();
                return new Iterator<String>() {
                    public boolean hasNext() {
                        return keys.hasNext();
                    }

                    public String next() {
                        return mapConfig.getOption(keys.next(), "").trim();
                    }

                    public void remove() {
                        keys.remove();
                    }
                };
            }
        };
    } catch (ParseException e) {
        getLog().warn(e);
    } catch (MandatoryOptionMissingException e) {
        getLog().warn(e);
    }
}

From source file:com.esri.gpt.control.webharvest.client.dcat.DCATRootResource.java

@Override
public Iterable<Resource> getNodes() {
    return new Iterable<Resource>() {
        @Override/*from   w w  w  . j  av  a2 s.c o  m*/
        public Iterator<Resource> iterator() {
            return new ResourceIterator();
        }
    };
}

From source file:org.apache.hadoop.hdfs.server.blockmanagement.DatanodeStorageInfo.java

static Iterable<StorageType> toStorageTypes(final Iterable<DatanodeStorageInfo> infos) {
    return new Iterable<StorageType>() {
        @Override/*from w  w w.  j  a v  a 2s. com*/
        public Iterator<StorageType> iterator() {
            return new Iterator<StorageType>() {
                final Iterator<DatanodeStorageInfo> i = infos.iterator();

                @Override
                public boolean hasNext() {
                    return i.hasNext();
                }

                @Override
                public StorageType next() {
                    return i.next().getStorageType();
                }

                @Override
                public void remove() {
                    throw new UnsupportedOperationException();
                }
            };
        }
    };
}

From source file:org.jsonman.node.MapNode.java

@Override
public Iterable<Node> getChildren() {
    return new Iterable<Node>() {
        @Override//w w w . ja v a  2s  .co  m
        public Iterator<Node> iterator() {
            return new Iterator<Node>() {
                @Override
                public boolean hasNext() {
                    return entries.hasNext();
                }

                @Override
                public Node next() {
                    Map.Entry<String, Object> n = entries.next();
                    return NodeFactory.create(n.getValue());
                }

                @Override
                public void remove() {
                    throw new UnsupportedOperationException();
                }

                private Iterator<Map.Entry<String, Object>> entries = map.entrySet().iterator();
            };
        }
    };
}

From source file:ch.entwine.weblounge.bridge.oaipmh.harvester.ListRecordsResponse.java

/**
 * Get all records performing a complete request resuming any partial
 * responses./*  w  ww .ja  va  2s .  co  m*/
 */
public static Iterable<Node> getAllRecords(final ListRecordsResponse first,
        final OaiPmhRepositoryClient client) {
    return new Iterable<Node>() {
        public Iterator<Node> iterator() {
            return new ResponseIterator(first) {
                @Override
                protected OaiPmhRepositoryClient getClient() {
                    return client;
                }

                @Override
                protected NodeList extractNodes(ListRecordsResponse response) {
                    return response.getRecords();
                }
            };
        }
    };
}

From source file:ch.systemsx.cisd.openbis.generic.server.business.bo.common.PropertiesSetListingQueryFullTableScan.java

public Iterable<MaterialEntityPropertyRecord> getEntityPropertyMaterialValues(final LongSet entityIDs) {
    return new Iterable<MaterialEntityPropertyRecord>() {
        public Iterator<MaterialEntityPropertyRecord> iterator() {
            return new FilterIterator<MaterialEntityPropertyRecord>(query.getEntityPropertyMaterialValues(),
                    new Predicate<BaseEntityPropertyRecord>() {
                        public boolean evaluate(BaseEntityPropertyRecord baseSample) {
                            return entityIDs.contains(baseSample.entity_id);
                        }/*from  ww w  .j  ava 2s. co m*/
                    });
        }
    };
}

From source file:org.polymap.core.model.event.ModelChangeEvent.java

public Iterable<PropertyChangeEvent> events(final EventFilter f) {
    return new Iterable<PropertyChangeEvent>() {

        public Iterator<PropertyChangeEvent> iterator() {

            // Iterator
            return new Iterator<PropertyChangeEvent>() {

                Iterator<PropertyChangeEvent> delegate = events.iterator();
                PropertyChangeEvent next;

                public boolean hasNext() {
                    if (next != null) {
                        return true;
                    }// ww w .j  a v  a2  s. c  om
                    while (next == null && delegate.hasNext()) {
                        PropertyChangeEvent candidate = delegate.next();
                        if (f.apply(candidate)) {
                            next = candidate;
                        }
                    }
                    return next != null;
                }

                public PropertyChangeEvent next() {
                    if (!hasNext()) {
                        throw new NoSuchElementException();
                    }
                    try {
                        return next;
                    } finally {
                        next = null;
                    }
                }

                public void remove() {
                    throw new UnsupportedOperationException();
                }
            };
        }
    };
}

From source file:Utils.java

/**
 * Treat an {@link Enumeration} as an {@link Iterable} so it can be used in an enhanced for-loop.
 * Bear in mind that the enumeration is "consumed" by the loop and so should be used only once.
 * Generally it is best to put the code which obtains the enumeration inside the loop header.
 * <div class="nonnormative">/*  w  w w. j a v a2  s.c o m*/
 * <p>Example of correct usage:</p>
 * <pre>
 * ClassLoader loader = ...;
 * String name = ...;
 * for (URL resource : NbCollections.iterable(loader.{@link ClassLoader#getResources getResources}(name))) {
 *     // ...
 * }
 * </pre>
 * </div>
 * @param enumeration an enumeration
 * @return an iterable wrapper which will traverse the enumeration once
 *         ({@link Iterator#remove} is not supported)
 * @throws NullPointerException if the enumeration is null
 * @see <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6349852">Java bug #6349852</a>
 * @since org.openide.util 7.5
 */
public static <E> Iterable<E> iterable(final Enumeration<E> enumeration) {
    if (enumeration == null) {
        throw new NullPointerException();
    }
    return new Iterable<E>() {
        public Iterator<E> iterator() {
            return new Iterator<E>() {
                public boolean hasNext() {
                    return enumeration.hasMoreElements();
                }

                public E next() {
                    return enumeration.nextElement();
                }

                public void remove() {
                    throw new UnsupportedOperationException();
                }
            };
        }
    };
}

From source file:org.apache.isis.core.metamodel.facets.collections.CollectionFacetAbstract.java

@Override
public Iterable<ObjectAdapter> iterable(final ObjectAdapter collectionAdapter) {
    return new Iterable<ObjectAdapter>() {
        @Override/* w  w  w . ja  v  a2s.  co m*/
        public Iterator<ObjectAdapter> iterator() {
            return CollectionFacetAbstract.this.iterator(collectionAdapter);
        }
    };
}