@Override public Enumeration<String> getHeaderNames() { return Collections.enumeration(this.headers.keySet()); } }
@Override public Enumeration<String> getInitParameterNames() { return Collections.enumeration(initParams.values()); } }
/** * Returns an enumeration of all {@code PackagePermission} objects in the * container. * * @return Enumeration of all {@code PackagePermission} objects. */ @Override public synchronized Enumeration<Permission> elements() { List<Permission> all = new ArrayList<Permission>(permissions.values()); Map<String, PackagePermission> pc = filterPermissions; if (pc != null) { all.addAll(pc.values()); } return Collections.enumeration(all); }
final Map <String,Integer> test = new HashMap<String,Integer>(); test.put("one",1); test.put("two",2); test.put("three",3); final Enumeration<String> strEnum = Collections.enumeration(test.keySet()); while(strEnum.hasMoreElements()) { System.out.println(strEnum.nextElement()); }
/** Returns the input stream of the trace data. */ protected InputStream readFiles() throws IOException { List<InputStream> inputs = new ArrayList<>(filePaths.size()); for (String filePath : filePaths) { inputs.add(readFile(filePath)); } return new SequenceInputStream(Collections.enumeration(inputs)); }
public Enumeration<Object> elements() { Collection<Object> values = properties.values(); List<Object> result = new ArrayList<Object>(values.size() + 1); result.add(topic); result.addAll(values); return Collections.enumeration(result); }
@Override public Enumeration<String> getParameterNames() { if (this.multipartParameterNames == null) { initializeMultipart(); } if (this.multipartParameterNames.isEmpty()) { return super.getParameterNames(); } // Servlet 3.0 getParameterNames() not guaranteed to include multipart form items // (e.g. on WebLogic 12) -> need to merge them here to be on the safe side Set<String> paramNames = new LinkedHashSet<>(); Enumeration<String> paramEnum = super.getParameterNames(); while (paramEnum.hasMoreElements()) { paramNames.add(paramEnum.nextElement()); } paramNames.addAll(this.multipartParameterNames); return Collections.enumeration(paramNames); }
@Override public Enumeration<URL> getResources(String name) throws IOException { final List<URL> urls = new ArrayList<>(); for (ClassLoader classLoader : classLoaders) { final Enumeration<URL> resources = classLoader.getResources(name); if (resources.hasMoreElements()) { urls.addAll(Collections.list(resources)); } } if (urls.isEmpty() && LOG.isTraceEnabled()) { LOG.trace("Resource " + name + " not found."); } return Collections.enumeration(urls); }
/** * Finds all the resources with the given name. This method will first search the class loader of * the context class for the resource before searching all other {@link ClassLoader}s. * * @param contextClass The class whose class loader will first be searched * @param name The resource name * @return An enumeration of {@link java.net.URL <tt>URL</tt>} objects for the resource. If no * resources could be found, the enumeration will be empty. Resources that the class * loader doesn't have access to will not be in the enumeration. * @throws IOException If I/O errors occur * @see ClassLoader#getResources(String) */ private Enumeration<URL> getResources(final Class<?> contextClass, final String name) throws IOException { final LinkedHashSet<URL> urls = new LinkedHashSet<URL>(); if (contextClass != null) { CollectionUtils.addAll(urls, contextClass.getClassLoader().getResources(name)); } for (ClassLoader classLoader : getClassLoaders()) { Enumeration<URL> resources = classLoader.getResources(name); if (resources != null && resources.hasMoreElements()) { CollectionUtils.addAll(urls, resources); } } return Collections.enumeration(urls); }
@Override public Enumeration<String> getHeaderNames() { Set list = new HashSet(); list.addAll(b.headers.keySet()); list.addAll(Collections.list(b.request.getHeaderNames())); if (b.request != null) { Enumeration e = b.request.getAttributeNames(); while (e.hasMoreElements()) { String name = e.nextElement().toString(); if (name.startsWith(X_ATMOSPHERE)) { list.add(name); } } } if (b.contentType != null) { list.add("Content-Type"); } return Collections.enumeration(list); }
List<InputStream> opened = new ArrayList<InputStream>(files.size()); for (File f : files) opened.add(new FileInputStream(f)); InputStream is = new SequenceInputStream(Collections.enumeration(opened));
@Override public Enumeration<String> getInitParameterNames() { return Collections.enumeration(this.initParameters.keySet()); }
public Enumeration<String> keys() { Collection<String> keys = properties.keySet(); List<String> result = new ArrayList<String>(keys.size() + 1); result.add(EVENT_TOPIC); result.addAll(keys); return Collections.enumeration(result); }
/** * Returns an enumeration of all {@code AdaptPermission} objects in the * container. * * @return Enumeration of all {@code AdaptPermission} objects. */ @Override public synchronized Enumeration<Permission> elements() { List<Permission> all = new ArrayList<Permission>(permissions.values()); return Collections.enumeration(all); }
/** * Returns an enumeration of all the {@code ServicePermission} objects in * the container. * * @return Enumeration of all the ServicePermission objects. */ @Override public synchronized Enumeration<Permission> elements() { List<Permission> all = new ArrayList<Permission>(permissions.values()); Map<String, ServicePermission> pc = filterPermissions; if (pc != null) { all.addAll(pc.values()); } return Collections.enumeration(all); }
public Enumeration<String> getInitParameterNames() { if (!done.getAndSet(true)) { Enumeration en = sc.getInitParameterNames(); if (en != null) { while (en.hasMoreElements()) { String name = (String) en.nextElement(); if (!initParams.containsKey(name)) { initParams.put(name, sc.getInitParameter(name)); } } } } return Collections.enumeration(initParams.keySet()); } };
/** * {@inheritDoc} */ @Override public Enumeration<URL> getResources(String name) throws IOException { // First get resources from this classloader List<URL> resources = Collections.list(findResources(name)); // Then add resources from the parent if (getParent() != null) { Enumeration<URL> parentResources = getParent().getResources(name); if (parentResources.hasMoreElements()) { resources.addAll(Collections.list(parentResources)); } } return Collections.enumeration(resources); }
private boolean ensureNext() { for (;;) { if (en != null && en.hasMoreElements()) { return true; } if (isEmpty()) { return false; } Node n2 = poll(); if (n2.children != null) { addAll(n2.children); } if (n2.items != null && !n2.items.isEmpty()) { en = Collections.enumeration(n2.items); } } }
@Override public Enumeration getParameterNames() { Set<String> paramNames = new LinkedHashSet<>(); paramNames.addAll(formParams.keySet()); Enumeration<String> original = super.getParameterNames(); while (original.hasMoreElements()) { paramNames.add(original.nextElement()); } return Collections.enumeration(paramNames); }
/** * Gets the current contents of this byte stream as a Input Stream. The * returned stream is backed by buffers of <code>this</code> stream, * avoiding memory allocation and copy, thus saving space and time.<br> * * @return the current contents of this output stream. * @see java.io.ByteArrayOutputStream#toByteArray() * @see #reset() * @since 2.5 */ public synchronized InputStream toInputStream() { int remaining = count; if (remaining == 0) { return new ClosedInputStream(); } final List<ByteArrayInputStream> list = new ArrayList<>(buffers.size()); for (final byte[] buf : buffers) { final int c = Math.min(buf.length, remaining); list.add(new ByteArrayInputStream(buf, 0, c)); remaining -= c; if (remaining == 0) { break; } } reuseBuffers = false; return new SequenceInputStream(Collections.enumeration(list)); }