List of usage examples for java.util Enumeration Enumeration
Enumeration
From source file:hermes.store.jdbc.MessageResultSetHandler.java
public MessageResultSetHandler(Connection connection, PreparedStatement statement, MessageFactory messageFactory, MessageStore.HeaderPolicy headerPolicy) throws SQLException { this.connection = connection; this.messageFactory = messageFactory; this.headerPolicy = headerPolicy; this.statement = statement; this.resultSet = statement.executeQuery(); enumeration = new Enumeration() { public Object nextElement() { return getNextMessageQuietly(); }/*from w w w . j a va 2 s . c o m*/ public boolean hasMoreElements() { return hasNextMessage(); } }; }
From source file:MinAppletviewer.java
public Enumeration getApplets() { return new Enumeration() { public boolean hasMoreElements() { return false; }//from w ww . jav a 2s . com public Object nextElement() { return null; } }; }
From source file:org.impalaframework.extension.mvc.util.RequestModelHelperTest.java
public void testImplicitParams() throws Exception { HttpServletRequest request = createMock(HttpServletRequest.class); expect(request.getParameterNames()).andReturn(new Enumeration<String>() { private String[] list = { "one", "two" }; int index; public boolean hasMoreElements() { return (index < list.length); }/*from w ww .j av a 2 s .c o m*/ public String nextElement() { final String string = list[index]; index++; return string; } }); expect(request.getParameter("one")).andReturn("v1"); expect(request.getParameter("two")).andReturn("v2"); replay(request); final ModelMap modelMap = new ModelMap(); RequestModelHelper.setParameters(request, modelMap); assertEquals(2, modelMap.size()); verify(request); }
From source file:com.oltpbenchmark.util.TestCollectionUtil.java
/** * testIterableEnumeration/*ww w . j av a2 s .co m*/ */ public void testIterableEnumeration() { final int size = 10; Enumeration<Integer> e = new Enumeration<Integer>() { int ctr = 0; @Override public Integer nextElement() { return (ctr++); } @Override public boolean hasMoreElements() { return (ctr < size); } }; List<Integer> found = new ArrayList<Integer>(); for (Integer i : CollectionUtil.iterable(e)) found.add(i); assertEquals(size, found.size()); }
From source file:ArrayMap.java
@Override public Enumeration<Object> elements() { return new Enumeration<Object>() { int i;/* ww w.j a va2 s . c om*/ { i = 0; findNext(); } void findNext() { while (i < data.length && data[i] == null) { i++; } } public boolean hasMoreElements() { return i < data.length; } public Object nextElement() { Object o = data[i++]; findNext(); return o; } }; }
From source file:net.sourceforge.vulcan.web.ParameterParsingHttpServletRequestWrapperTest.java
protected Enumeration<String> toEnumeration(final String... items) { final int[] i = new int[1]; return new Enumeration<String>() { @Override/*from www .j a v a 2 s. c o m*/ public boolean hasMoreElements() { return items != null && i[0] < items.length; } @Override public String nextElement() { return items[i[0]++]; } }; }
From source file:net.ymate.platform.webmvc.support.MultipartRequestWrapper.java
public Enumeration<String> getParameterNames() { return new Enumeration<String>() { private Iterator<String> it = getParameterMap().keySet().iterator(); public boolean hasMoreElements() { return it.hasNext(); }//w ww. ja v a 2 s. co m public String nextElement() { return it.next(); } }; }
From source file:org.apache.xml.security.utils.ClassLoaderUtils.java
/** * Load a given resources. <p/> This method will try to load the resources * using the following methods (in order): * <ul>//from w w w . j a va2 s. co m * <li>From Thread.currentThread().getContextClassLoader() * <li>From ClassLoaderUtil.class.getClassLoader() * <li>callingClass.getClassLoader() * </ul> * * @param resourceName The name of the resource to load * @param callingClass The Class object of the calling object */ public static List<URL> getResources(String resourceName, Class<?> callingClass) { List<URL> ret = new ArrayList<URL>(); Enumeration<URL> urls = new Enumeration<URL>() { public boolean hasMoreElements() { return false; } public URL nextElement() { return null; } }; try { urls = Thread.currentThread().getContextClassLoader().getResources(resourceName); } catch (IOException e) { if (log.isDebugEnabled()) { log.debug(e); } //ignore } if (!urls.hasMoreElements() && resourceName.startsWith("/")) { //certain classloaders need it without the leading / try { urls = Thread.currentThread().getContextClassLoader().getResources(resourceName.substring(1)); } catch (IOException e) { if (log.isDebugEnabled()) { log.debug(e); } // ignore } } ClassLoader cluClassloader = ClassLoaderUtils.class.getClassLoader(); if (cluClassloader == null) { cluClassloader = ClassLoader.getSystemClassLoader(); } if (!urls.hasMoreElements()) { try { urls = cluClassloader.getResources(resourceName); } catch (IOException e) { if (log.isDebugEnabled()) { log.debug(e); } // ignore } } if (!urls.hasMoreElements() && resourceName.startsWith("/")) { //certain classloaders need it without the leading / try { urls = cluClassloader.getResources(resourceName.substring(1)); } catch (IOException e) { if (log.isDebugEnabled()) { log.debug(e); } // ignore } } if (!urls.hasMoreElements()) { ClassLoader cl = callingClass.getClassLoader(); if (cl != null) { try { urls = cl.getResources(resourceName); } catch (IOException e) { if (log.isDebugEnabled()) { log.debug(e); } // ignore } } } if (!urls.hasMoreElements()) { URL url = callingClass.getResource(resourceName); if (url != null) { ret.add(url); } } while (urls.hasMoreElements()) { ret.add(urls.nextElement()); } if (ret.isEmpty() && (resourceName != null) && (resourceName.charAt(0) != '/')) { return getResources('/' + resourceName, callingClass); } return ret; }
From source file:de.codesourcery.eve.skills.ui.model.DefaultTreeNode.java
@Override public Enumeration<ITreeNode> children() { final Iterator<ITreeNode> it = children.iterator(); return new Enumeration<ITreeNode>() { @Override//from w w w. ja v a 2 s. co m public boolean hasMoreElements() { return it.hasNext(); } @Override public ITreeNode nextElement() { return it.next(); } }; }
From source file:org.eclipse.tracecompass.internal.tmf.ui.project.wizards.importtrace.TarFile.java
/** * Returns an enumeration cataloguing the tar archive. * * @return enumeration of all files in the archive *///from w ww . java2 s. c o m public Enumeration<TarArchiveEntry> entries() { return new Enumeration<TarArchiveEntry>() { @Override public boolean hasMoreElements() { return (curEntry != null); } @Override public TarArchiveEntry nextElement() { TarArchiveEntry oldEntry = curEntry; try { curEntry = (TarArchiveEntry) entryEnumerationStream.getNextEntry(); } catch (IOException e) { curEntry = null; } return oldEntry; } }; }