List of usage examples for java.util Collections enumeration
public static <T> Enumeration<T> enumeration(final Collection<T> c)
From source file:org.xwoot.jxta.mock.MockJxtaPeer.java
/** {@inheritDoc} **/ public Enumeration<PeerAdvertisement> getKnownPeers() { if (!this.isConnectedToNetwork()) { logger.warn("Not connected to network."); // return empty enumeration. return Collections.enumeration(new ArrayList<PeerAdvertisement>()); }/*www .j ava 2 s . c om*/ discoverPeers(null, null); return Collections.enumeration(this.localPeerAdvRegistry); }
From source file:org.apache.beehive.netui.pageflow.scoping.internal.ScopedRequestImpl.java
public final Enumeration getAttributeNames() { Set set = new HashSet(); if (!_seeOuterRequestAttributes) { for (Enumeration e = getRequest().getAttributeNames(); e.hasMoreElements();) { Object attrName = e.nextElement(); if (_visibleOuterRequestAttrs.contains(attrName)) set.add(attrName);/*from w ww.jav a2 s . com*/ } } for (Enumeration e = _scopedContainer.getAttributeNames(); e.hasMoreElements();) { set.add(e.nextElement()); } if (_seeOuterRequestAttributes) { for (Enumeration e = getRequest().getAttributeNames(); e.hasMoreElements();) { set.add(e.nextElement()); } } return Collections.enumeration(set); }
From source file:com.thoughtworks.go.http.mocks.MockServletContext.java
@Override public Enumeration<String> getAttributeNames() { return Collections.enumeration(new LinkedHashSet<>(this.attributes.keySet())); }
From source file:org.xwoot.jxta.mock.MockJxtaPeer.java
/** {@inheritDoc} **/ public Enumeration<Advertisement> getKnownAdvertisements(String attribute, String value) { Enumeration<Advertisement> result = null; if (!this.isConnectedToNetwork()) { logger.warn("Not connected to network."); // return empty enumeration. result = Collections.enumeration(new ArrayList<Advertisement>()); }/*from w w w .j a v a 2 s. com*/ result = Collections.enumeration(new HashSet<Advertisement>(this.localPipeAdvRegistry)); discoverAdvertisements(null, null, attribute, value); return result; }
From source file:org.apache.sling.servlets.post.impl.helper.SlingFileUploadHandler.java
/** * Merge all previous chunks with last chunk's stream into a temporary file * and return it./*from w w w. j av a 2 s . c om*/ */ private File mergeChunks(final Node parentNode, final InputStream lastChunkStream) throws PersistenceException, RepositoryException { OutputStream out = null; SequenceInputStream mergeStrm = null; File file = null; try { file = File.createTempFile("tmp-", "-mergechunk"); out = new FileOutputStream(file); String startPattern = SlingPostConstants.CHUNK_NODE_NAME + "_" + "0_*"; NodeIterator nodeItr = parentNode.getNodes(startPattern); Set<InputStream> inpStrmSet = new LinkedHashSet<InputStream>(); while (nodeItr.hasNext()) { if (nodeItr.getSize() > 1) { throw new RepositoryException("more than one node found for pattern: " + startPattern); } Node rangeNode = nodeItr.nextNode(); inpStrmSet.add(rangeNode.getProperty(javax.jcr.Property.JCR_DATA).getBinary().getStream()); log.debug("added chunk {} to merge stream", rangeNode.getName()); String[] indexBounds = rangeNode.getName() .substring((SlingPostConstants.CHUNK_NODE_NAME + "_").length()).split("_"); startPattern = SlingPostConstants.CHUNK_NODE_NAME + "_" + String.valueOf(Long.valueOf(indexBounds[1]) + 1) + "_*"; nodeItr = parentNode.getNodes(startPattern); } inpStrmSet.add(lastChunkStream); mergeStrm = new SequenceInputStream(Collections.enumeration(inpStrmSet)); IOUtils.copyLarge(mergeStrm, out); } catch (IOException e) { throw new PersistenceException("excepiton occured", e); } finally { IOUtils.closeQuietly(out); IOUtils.closeQuietly(mergeStrm); } return file; }
From source file:de.micromata.genome.tpsb.httpmockup.MockHttpServletRequest.java
/** Returns an enumeration of requested locales. Defaults to the system locale. */ @Override//from w w w .j ava2s . c om public Enumeration<Locale> getLocales() { if (this.locales.size() == 0) { this.locales.add(Locale.getDefault()); } return Collections.enumeration(this.locales); }
From source file:org.lwes.db.EventTemplateDB.java
/** * Returns an enumeration of all defined events * * @return an enumeration of all defined events */// ww w . jav a 2 s .c om public Enumeration<String> getEventNames() { return Collections.enumeration(this.events.keySet()); }
From source file:org.apache.cocoon.components.store.impl.EHDefaultStore.java
public Enumeration keys() { List keys = null;/*from ww w .ja va2 s .com*/ try { keys = this.cache.getKeys(); } catch (CacheException e) { if (getLogger().isWarnEnabled()) { getLogger().warn("Error while getting cache keys", e); } keys = Collections.EMPTY_LIST; } return Collections.enumeration(keys); }
From source file:org.xwoot.jxta.mock.MockJxtaPeer.java
/** {@inheritDoc} **/ public Enumeration<Advertisement> getKnownDirectCommunicationPipeAdvertisements() { ArrayList<Advertisement> pipeAdvs = new ArrayList<Advertisement>(); Enumeration<Advertisement> en = this.getKnownAdvertisements(PipeAdvertisement.NameTag, this.getDirectCommunicationPipeNamePrefix() + "*"); while (en.hasMoreElements()) { Advertisement adv = en.nextElement(); // Get only PipeAdvertisements that are different from this peer's. if (adv instanceof PipeAdvertisement) { PipeAdvertisement pipeAdv = (PipeAdvertisement) adv; if (!pipeAdv.equals(this.getMyDirectCommunicationPipeAdvertisement())) { pipeAdvs.add(adv);/*from w w w . j a v a2 s . co m*/ } } } return Collections.enumeration(pipeAdvs); }
From source file:com.sunchenbin.store.feilong.core.bean.ConvertUtil.java
/** * ??./*from w ww. j a va 2 s .c om*/ * * @param <T> * the generic type * @param collection * ? * @return Enumeration * @see Collections#enumeration(Collection) * @since 1.4.0 */ public static <T> Enumeration<T> toEnumeration(final Collection<T> collection) { return Collections.enumeration(collection); }