List of usage examples for java.util Collections enumeration
public static <T> Enumeration<T> enumeration(final Collection<T> c)
From source file:org.opennms.netmgt.poller.remote.metadata.LinkedProperties.java
@Override public Enumeration<Object> keys() { final Set<Object> allKeys = new LinkedHashSet<>(); if (m_linkedDefaults != null) { allKeys.addAll(m_linkedDefaults.m_linkedKeys); }//from w ww.java 2 s.com allKeys.addAll(m_linkedKeys); return Collections.enumeration(allKeys); }
From source file:XMLResourceBundleControl.java
public Enumeration<String> getKeys() { Set<String> handleKeys = props.stringPropertyNames(); return Collections.enumeration(handleKeys); }
From source file:org.sipfoundry.sipxconfig.phone.yealink.YealinkDirectoryConfiguration.java
void transformPhoneBook(Collection<PhonebookEntry> phonebookEntries, Collection<YealinkPhonebookEntry> yealinkEntries) { for (PhonebookEntry entry : phonebookEntries) { yealinkEntries.add(new YealinkPhonebookEntry(entry)); }/*from www. j a v a 2 s . c om*/ List<YealinkPhonebookEntry> tmp = Collections.list(Collections.enumeration(yealinkEntries)); Collections.sort(tmp); yealinkEntries.clear(); for (YealinkPhonebookEntry entry : tmp) { yealinkEntries.add(entry); } }
From source file:de.micromata.genome.gwiki.page.impl.i18n.GWikiI18NCombinedResourceBundle.java
@Override public Enumeration<String> getKeys() { for (String module : modules) { GWikiElement el = GWikiWeb.get().findElement(module); if (el == null) { GWikiLog.warn("I18N Module not found: " + module); continue; }// w w w . ja v a 2 s . c o m if ((el instanceof GWikiI18nElement) == false) { GWikiLog.warn("Element is not a I18N Module: " + module); continue; } GWikiI18nElement i18nel = (GWikiI18nElement) el; return Collections.enumeration(i18nel.getKeys(locale.getLanguage())); } return null; }
From source file:opa.DatabaseResourceBundle.java
@Override public Enumeration<String> getKeys() { String sql = "SELECT phrase FROM phrases WHERE lang_id = " + langId; ArrayList<String> values = new ArrayList<String>(); try {/*ww w . j a va2 s . c o m*/ ResultSet rs = getConnection().createStatement().executeQuery(sql); if (rs.next()) values.add("phrase"); rs.close(); } catch (Exception e) { log.error(e, e); } return Collections.enumeration(values); }
From source file:com.github.benmanes.caffeine.cache.simulator.parser.TextTraceReader.java
private InputStream readFiles() throws IOException { List<InputStream> inputs = new ArrayList<>(filePaths.size()); for (String filePath : filePaths) { inputs.add(readFile(filePath));//from w w w .j a va 2s.c o m } return new SequenceInputStream(Collections.enumeration(inputs)); }
From source file:net.solarnetwork.web.support.ReloadableResourceBundleMessagesSource.java
@Override @SuppressWarnings({ "rawtypes", "unchecked" }) public Enumeration<String> getKeys(Locale locale) { PropertiesHolder propHolder = super.getMergedProperties(locale); return Collections.enumeration((Set) propHolder.getProperties().keySet()); }
From source file:org.kohsuke.stapler.RequestImplTest.java
@Test public void test_mutipart_formdata() throws IOException, ServletException { final Stapler stapler = new Stapler(); final byte[] buf = generateMultipartData(); final ByteArrayInputStream is = new ByteArrayInputStream(buf); final MockRequest mockRequest = new MockRequest() { @Override//ww w . ja va 2s . co m public String getContentType() { return "multipart/form-data; boundary=mpboundary"; } @Override public String getCharacterEncoding() { return "UTF-8"; } @Override public int getContentLength() { return buf.length; } @Override public Enumeration getParameterNames() { return Collections.enumeration(Arrays.asList("p1")); } @Override public ServletInputStream getInputStream() throws IOException { return new ServletInputStream() { @Override public int read() throws IOException { return is.read(); } @Override public int read(byte[] b) throws IOException { return is.read(b); } @Override public int read(byte[] b, int off, int len) throws IOException { return is.read(b, off, len); } }; } }; RequestImpl request = new RequestImpl(stapler, mockRequest, Collections.<AncestorImpl>emptyList(), null); // Check that we can get the Form Fields. See https://github.com/stapler/stapler/issues/52 Assert.assertEquals("text1_val", request.getParameter("text1")); Assert.assertEquals("text2_val", request.getParameter("text2")); // Check that we can get the file FileItem fileItem = request.getFileItem("pomFile"); Assert.assertNotNull(fileItem); // Check getParameterValues Assert.assertEquals("text1_val", request.getParameterValues("text1")[0]); // Check getParameterNames Assert.assertTrue(Collections.list(request.getParameterNames()).contains("p1")); Assert.assertTrue(Collections.list(request.getParameterNames()).contains("text1")); // Check getParameterMap Assert.assertTrue(request.getParameterMap().containsKey("text1")); }
From source file:org.trustedanalytics.resourceserver.data.InputStreamProvider.java
/** * Gets an InputStream for a path on HDFS. * * If given path is a directory, it will read files inside that dir and create * a SequenceInputStream from them, which emulates reading from directory just like from * a regular file. Notice that this method is not meant to read huge datasets * (as well as the whole project)./*from w w w. ja v a 2 s . c o m*/ * @param path * @return * @throws IOException */ public InputStream getInputStream(Path path) throws IOException { Objects.requireNonNull(path); if (fs.isFile(path)) { return fs.open(path); } else if (fs.isDirectory(path)) { FileStatus[] files = fs.listStatus(path); List<InputStream> paths = Arrays.stream(files).map(f -> { try { return fs.open(f.getPath()); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Cannot read file " + f.getPath().toString(), e); return null; } }).filter(f -> f != null).collect(Collectors.toList()); return new SequenceInputStream(Collections.enumeration(paths)); } else { throw new IllegalArgumentException("Given path " + path.toString() + " is neither file nor directory"); } }
From source file:sample.SpringMultipartParser.java
public Enumeration<String> getFileParameterNames() { return Collections.enumeration(multipartMap.keySet()); }