List of usage examples for java.util Enumeration Enumeration
Enumeration
From source file:org.echocat.nodoodle.classloading.FileClassLoader.java
@Override public Enumeration<URL> getResources(String name) throws IOException { final Enumeration<URL> localResources = findResources(name); final ClassLoader parent = getParent(); // noinspection unchecked final Enumeration<URL> globalResources = parent != null ? parent.getResources(name) : asEnumeration(emptyIterator()); return new Enumeration<URL>() { private boolean _local = true; @Override// w ww. ja va2s. com public boolean hasMoreElements() { if (_local && !localResources.hasMoreElements()) { _local = false; } return _local ? localResources.hasMoreElements() : globalResources.hasMoreElements(); } @Override public URL nextElement() { if (_local && localResources.nextElement() == null) { _local = false; } return _local ? localResources.nextElement() : globalResources.nextElement(); } }; }
From source file:org.impalaframework.classloader.URLClassRetriever.java
public Enumeration<URL> findResources(String resourceName) { Enumeration<URL> findResource = null; try {/* w w w . j av a 2 s. co m*/ findResource = urlClassLoader.findResources(resourceName); if (logger.isTraceEnabled()) { if (findResource != null) { logger.trace("Successfully found URL " + findResource + " from " + this); } else { logger.trace("Unable to find URL for " + resourceName + " from " + this); } } } catch (IOException e) { if (logger.isDebugEnabled()) { logger.debug("IO exception caught in findResources(): ", e); } return new Enumeration<URL>() { public boolean hasMoreElements() { return false; } public URL nextElement() { throw new NoSuchElementException(); } }; } return findResource; }
From source file:net.ymate.platform.mvc.web.support.MultipartRequestWrapper.java
public Enumeration<String> getParameterNames() { Enumeration<String> names = new Enumeration<String>() { private Iterator<String> it = getParameterMap().keySet().iterator(); public boolean hasMoreElements() { return it.hasNext(); }/* w ww. j a va2 s . com*/ public String nextElement() { return it.next(); } }; return names; }
From source file:org.pentaho.platform.web.servlet.JAXRSServlet.java
@Override public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (logger.isDebugEnabled()) { logger.debug("servicing request for resource " + request.getPathInfo()); //$NON-NLS-1$ }/*from ww w. j a v a 2s . c o m*/ if (request.getMethod().equals(GET)) { // Extension to allow accept type override from mime-type query param final String mimeType = request.getParameter(MIME_TYPE); if (mimeType != null) { final HttpServletRequest originalRequest = request; request = (HttpServletRequest) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { HttpServletRequest.class }, new InvocationHandler() { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (method.getName().equals(GET_HEADERS) && args.length > 0 && args[0].equals(ACCEPT)) { return new Enumeration() { boolean hasMore = true; @Override public boolean hasMoreElements() { return hasMore; } @Override public Object nextElement() { hasMore = false; return mimeType; } }; } return method.invoke(originalRequest, args); } }); } } super.service(request, response); }
From source file:net.gleamynode.conversion.support.discovery.tools.Service.java
/** * This version lets you specify constructor arguments.. * //from www . j a va 2 s . c om * @param spi SPI to look for and load. * @param classLoaders loaders to use in search. * If <code>null</code> then use ClassLoaders.getAppLoaders(). */ public static Enumeration providers(final SPInterface spi, ClassLoaders loaders) { if (loaders == null) { loaders = ClassLoaders.getAppLoaders(spi.getSPClass(), Service.class, true); } ResourceNameIterator servicesIter = (new DiscoverServiceNames(loaders)).findResourceNames(spi.getSPName()); final ResourceClassIterator services = (new DiscoverClasses(loaders)).findResourceClasses(servicesIter); return new Enumeration() { private Object object = null; public boolean hasMoreElements() { if (object == null) { object = getNextClassInstance(); } return object != null; } public Object nextElement() { Object obj = object; object = null; return obj; } private Object getNextClassInstance() { while (services.hasNext()) { ResourceClass info = services.nextResourceClass(); try { return spi.newInstance(info.loadClass()); } catch (Exception e) { // ignore } } return null; } }; }
From source file:org.apache.axis.i18n.ProjectResourceBundle.java
public Enumeration getKeys() { Enumeration myKeys = resourceBundle.getKeys(); if (parent == null) { return myKeys; } else {//from w ww. jav a2 s .c o m final HashSet set = new HashSet(); while (myKeys.hasMoreElements()) { set.add(myKeys.nextElement()); } Enumeration pKeys = parent.getKeys(); while (pKeys.hasMoreElements()) { set.add(pKeys.nextElement()); } return new Enumeration() { private Iterator it = set.iterator(); public boolean hasMoreElements() { return it.hasNext(); } public Object nextElement() { return it.next(); } }; } }
From source file:org.eclipse.ui.internal.wizards.datatransfer.TarFile.java
/** * Returns an enumeration cataloguing the tar archive. * /*from w w w. ja v a 2s.c o m*/ * @return enumeration of all files in the archive */ public Enumeration entries() { return new Enumeration() { public boolean hasMoreElements() { return (curEntry != null); } public Object nextElement() { TarEntry oldEntry = curEntry; try { curEntry = entryEnumerationStream.getNextEntry(); } catch (TarException e) { curEntry = null; } catch (IOException e) { curEntry = null; } return oldEntry; } }; }
From source file:com.liyo.html.HTMLParser.java
/** * Returns an iterator (enumeration) to the html nodes. Each node can be a tag/endtag/ * string/link/image//from w w w . ja v a 2 s .c om */ public Enumeration elements() { return new Enumeration() { public boolean hasMoreElements() { if (reader == null) return false; try { node = reader.readElement(); readFlag = true; if (node == null) { return false; } else { return true; } } catch (IOException e) { System.err.println("I/O Exception occured while reading " + resourceUrl); return false; } } public Object nextElement() { try { if (!readFlag) node = reader.readElement(); return node; } catch (IOException e) { System.err.println("I/O Exception occured while reading " + resourceUrl); return null; } } }; }
From source file:org.pentaho.hadoop.shim.HadoopConfigurationClassLoader.java
@Override public Enumeration<URL> getResources(String name) throws IOException { final Enumeration<URL> myResources = findResources(name); final Enumeration<URL> parentResources = getParent().getResources(name); return new Enumeration<URL>() { @Override// ww w .j av a2s . c om public boolean hasMoreElements() { return myResources.hasMoreElements() || parentResources.hasMoreElements(); } @Override public URL nextElement() { if (myResources.hasMoreElements()) { return myResources.nextElement(); } return parentResources.nextElement(); } }; }
From source file:org.wings.session.MultipartRequest.java
/** * Returns the names of all the parameters as an Enumeration of * Strings. It returns an empty Enumeration if there are no parameters. * * @return the names of all the parameters as an Enumeration of Strings *//*from w ww .ja v a 2 s. co m*/ public Enumeration getParameterNames() { if (urlencodedRequest) return super.getParameterNames(); final Iterator iter = parameters.keySet().iterator(); return new Enumeration() { public boolean hasMoreElements() { return iter.hasNext(); } public Object nextElement() { return iter.next(); } }; }