List of usage examples for java.lang Iterable Iterable
Iterable
From source file:org.sakaiproject.nakamura.lite.content.InternalContent.java
/** * @return an iterable of all relative child paths of this object. *//*from w w w . ja v a 2s . c om*/ public Iterable<String> listChildPaths() { if (newcontent) { return Iterables.emptyIterable(); } return new Iterable<String>() { public Iterator<String> iterator() { try { return contentManager.listChildPaths(path); } catch (StorageClientException e) { LOGGER.error(e.getMessage(), e); } return Iterators.emptyIterator(); } }; }
From source file:net.sf.maltcms.chromaui.project.spi.descriptors.CachingChromatogram1D.java
@Override public Iterable<IScan1D> subsetByScanIndex(final int startIndex, final int stopIndex) { if (startIndex < 0) { throw new ArrayIndexOutOfBoundsException(startIndex); }/*from w w w .ja va 2 s .c om*/ if (stopIndex > getNumberOfScans() - 1) { throw new ArrayIndexOutOfBoundsException(stopIndex); } final Iterator<IScan1D> iter = new Iterator<IScan1D>() { private int currentPos = startIndex; @Override public boolean hasNext() { return this.currentPos < stopIndex; } @Override public IScan1D next() { return getScan(this.currentPos++); } @Override public void remove() { throw new UnsupportedOperationException("Can not remove scans with iterator!"); } }; return new Iterable<IScan1D>() { @Override public Iterator<IScan1D> iterator() { return iter; } }; }
From source file:com.aliyun.odps.graph.local.TaskContextImpl.java
@Override public Iterable<byte[]> readCacheArchive(String resourceName, String relativePath) throws IOException { File baseDir = new File(mCtx.getResourceDir(), resourceName); File dir = new File(baseDir, relativePath); File[] files = dir.listFiles(); final List<byte[]> list = new ArrayList<byte[]>(); for (File file : files) { list.add(IOUtils.toByteArray(new BufferedInputStream(new FileInputStream(file)))); }/*from w w w . ja v a 2 s . co m*/ return new Iterable<byte[]>() { @Override public Iterator<byte[]> iterator() { return list.iterator(); } }; }
From source file:org.sakaiproject.nakamura.lite.content.InternalContent.java
public Iterable<String> listStreams() { final Set<String> streams = Sets.newHashSet(); for (Entry<String, Object> e : content.entrySet()) { String k = e.getKey();/*www . j a va 2 s.c o m*/ String[] streamIds = StringUtils.split(k, "/", 2); if (streamIds.length == 2) { streams.add(streamIds[1]); } } return new Iterable<String>() { public Iterator<String> iterator() { return streams.iterator(); } }; }
From source file:com.aliyun.odps.graph.local.TaskContextImpl.java
@Override public Iterable<BufferedInputStream> readCacheArchiveAsStream(String resourceName, String relativePath) throws IOException { File baseDir = new File(mCtx.getResourceDir(), resourceName); File dir = new File(baseDir, relativePath); File[] files = dir.listFiles(); final List<BufferedInputStream> list = new ArrayList<BufferedInputStream>(); for (File file : files) { list.add(new BufferedInputStream(new FileInputStream(file))); }/*from w w w . ja v a 2 s. c om*/ return new Iterable<BufferedInputStream>() { @Override public Iterator<BufferedInputStream> iterator() { return list.iterator(); } }; }
From source file:com.infinira.aerospike.dataaccess.repository.AerospikeRepository.java
/** * Find all entities for a given filter and qualifiers * @param filter input filter//w w w . j a va 2s . c o m * @param qualifiers qualifiers * @return Iterable list of entities. */ private Iterable<T> findAllUsingQuery(Filter filter, Qualifier... qualifiers) { Statement stmt = new Statement(); stmt.setNamespace(namespace); stmt.setSetName(setName); Iterable<T> results; final KeyRecordIterator recIterator = AerospikeClientUtil.getQueryEngine().select(namespace, setName, filter, qualifiers); results = new Iterable<T>() { @Override public Iterator<T> iterator() { return new EntityIterator<T>(recIterator); } }; return results; }
From source file:oculus.aperture.common.JSONProperties.java
@Override public Iterable<Properties> getPropertiesSets(String key) { try {/*from w ww . j av a2 s . c o m*/ final JSONArray array = obj.getJSONArray(key); return new Iterable<Properties>() { @Override public Iterator<Properties> iterator() { return new Iterator<Properties>() { private final int n = array.length(); private int i = 0; @Override public boolean hasNext() { return n > i; } @Override public Properties next() { try { return (n > i) ? new JSONProperties(array.getJSONObject(i++)) : null; } catch (JSONException e) { return null; } } @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; } catch (JSONException e) { return EmptyIterable.instance(); } }
From source file:org.kuali.kfs.sys.batch.service.impl.FinancialSystemDocumentHeaderPopulationServiceImpl.java
/** * Returns a new Iterable to iterate over batches of FinancialSystemDocumentHeaders * @param batchSize the size of the batches to build * @param jobRunSize the number of records * @return the newly created Iterable//from ww w. j a v a 2 s .com */ protected Iterable<Collection<FinancialSystemDocumentHeader>> getFinancialSystemDocumentHeaderBatchIterable( final int batchSize, final Integer jobRunSize) { return new Iterable<Collection<FinancialSystemDocumentHeader>>() { @Override public Iterator<Collection<FinancialSystemDocumentHeader>> iterator() { return new FinancialSystemDocumentHeaderBatchIterator(batchSize, jobRunSize); } }; }
From source file:edu.brown.utils.CollectionUtil.java
public static <T> Iterable<T> iterable(final T values[]) { return (new Iterable<T>() { @Override//from w ww .j a v a2 s .c o m public Iterator<T> iterator() { return new Iterator<T>() { private int idx = 0; @Override public boolean hasNext() { return (this.idx < values.length); } @Override public T next() { return (values[this.idx++]); } @Override public void remove() { throw new NotImplementedException(); } }; } }); }
From source file:com.aliyun.odps.graph.local.TaskContextImpl.java
@Override public Iterable<WritableRecord> readResourceTable(String resourceName) throws IOException { final File tableDir = new File(mCtx.getResourceDir(), resourceName); if (!tableDir.exists()) { throw new RuntimeException("resource " + resourceName + " not found!"); }//from w w w . java 2 s . co m if (tableDir.isFile()) { throw new RuntimeException("resource " + resourceName + " is not a table resource!"); } final List<File> dataFiles = new ArrayList<File>(); LocalRunUtils.listAllDataFiles(tableDir, dataFiles); return new Iterable<WritableRecord>() { @Override public Iterator<WritableRecord> iterator() { return new WrappedRecordIterator(tableDir, dataFiles); } }; }