List of usage examples for com.google.common.collect Iterators forEnumeration
public static <T> UnmodifiableIterator<T> forEnumeration(final Enumeration<T> enumeration)
From source file:org.glowroot.agent.config.PluginCache.java
private static ImmutableList<URL> getResources(String resourceName) throws IOException { ClassLoader loader = PluginCache.class.getClassLoader(); if (loader == null) { return ImmutableList.copyOf(Iterators.forEnumeration(ClassLoader.getSystemResources(resourceName))); } else {/*from w w w . j a va 2 s .co m*/ return ImmutableList.copyOf(Iterators.forEnumeration(loader.getResources(resourceName))); } }
From source file:net.sourceforge.ganttproject.ResourceTreeTableModel.java
public MutableTreeTableNode getNodeForAssigment(ResourceAssignment assignement) { for (MutableTreeTableNode an : ImmutableList .copyOf(Iterators.forEnumeration(getNodeForResource(assignement.getResource()).children()))) { if (assignement.equals(an.getUserObject())) { return an; }/*from w ww . ja v a 2 s. c o m*/ } return null; }
From source file:com.google.gdt.eclipse.designer.hosted.classloader.GWTSharedClassLoader.java
@Override public Enumeration<URL> findResources(String name) throws IOException { final Enumeration<URL> superResources = super.findResources(name); final Enumeration<URL> moduleResources = stateTL.get().activeLoader.getResources(name); Iterator<URL> allResources = Iterators.concat(Iterators.forEnumeration(superResources), Iterators.forEnumeration(moduleResources)); return Iterators.asEnumeration(allResources); }
From source file:org.apache.cassandra.hadoop.cql3.LimitedLocalNodeFirstLocalBalancingPolicy.java
private static Set<InetAddress> getLocalInetAddresses() { try {/*from w w w . j a v a 2 s . c o m*/ return Sets.newHashSet(Iterators .concat(Iterators.transform(Iterators.forEnumeration(NetworkInterface.getNetworkInterfaces()), new Function<NetworkInterface, Iterator<InetAddress>>() { @Override public Iterator<InetAddress> apply(NetworkInterface netIface) { return Iterators.forEnumeration(netIface.getInetAddresses()); } }))); } catch (SocketException e) { logger.warn("Could not retrieve local network interfaces.", e); return Collections.emptySet(); } }
From source file:org.nuxeo.ecm.core.opencmis.impl.server.NuxeoContentStream.java
public static boolean hasWantDigestRequestHeader(HttpServletRequest request, String digestAlgorithm) { if (request == null || digestAlgorithm == null) { return false; }/*ww w . j a v a2s . c o m*/ Enumeration<String> values = request.getHeaders(WANT_DIGEST_HEADER_NAME); if (values == null) { return false; } Iterator<String> it = Iterators.forEnumeration(values); while (it.hasNext()) { String value = it.next(); int semicolon = value.indexOf(';'); if (semicolon >= 0) { value = value.substring(0, semicolon); } if (value.equalsIgnoreCase(digestAlgorithm)) { return true; } } return false; }
From source file:org.graylog2.plugin.inputs.transports.util.KeyUtil.java
private static String join(Enumeration<String> aliases) { return JOINER.join(Iterators.forEnumeration(aliases)); }
From source file:org.opencms.i18n.CmsVfsResourceBundle.java
/** * @see java.util.ResourceBundle#getKeys() *///from w w w .j a v a2 s. c o m @Override public Enumeration<String> getKeys() { Iterator<String> myKeyIter = handleKeySet().iterator(); Iterator<String> result = myKeyIter; if (parent != null) { Iterator<String> parentKeyIter = Iterators.forEnumeration(parent.getKeys()); result = Iterators.concat(myKeyIter, parentKeyIter); } return Iterators.asEnumeration(result); }
From source file:com.github.tomakehurst.wiremock.common.ClasspathFileSource.java
private static <T> Iterable<T> toIterable(final Enumeration<T> e) { return new Iterable<T>() { @Override/* www.ja v a2 s . c o m*/ public Iterator<T> iterator() { return Iterators.forEnumeration(e); } }; }
From source file:com.facebook.presto.server.PluginClassLoader.java
@Override public Enumeration<URL> getResources(String name) throws IOException { List<Iterator<URL>> resources = new ArrayList<>(); // If this is not a parent first resource, add resources from local urls first if (!isParentFirstResource(name)) { Iterator<URL> myResources = Iterators.forEnumeration(findResources(name)); resources.add(myResources);/*from w w w . j av a 2 s . co m*/ } // Add parent resources if (!isHiddenResource(name)) { Iterator<URL> parentResources = Iterators.forEnumeration(getParent().getResources(name)); resources.add(parentResources); } // If this is a parent first resource, now add resources from local urls if (isParentFirstResource(name)) { Iterator<URL> myResources = Iterators.forEnumeration(findResources(name)); resources.add(myResources); } return Iterators.asEnumeration(Iterators.concat(resources.iterator())); }
From source file:com.bouncestorage.swiftproxy.v1.ObjectResource.java
private List<Pair<Long, Long>> parseRange(String range) { range = range.replaceAll(" ", "").toLowerCase(); String bytesUnit = "bytes="; int idx = range.indexOf(bytesUnit); if (idx == 0) { String byteRangeSet = range.substring(bytesUnit.length()); Iterator<Object> iter = Iterators.forEnumeration(new StringTokenizer(byteRangeSet, ",")); return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iter, Spliterator.ORDERED), false) .map(rangeSpec -> (String) rangeSpec).map(rangeSpec -> { int dash = rangeSpec.indexOf("-"); if (dash == -1) { throw new BadRequestException("Range"); }//from www . ja v a 2s. co m String firstBytePos = rangeSpec.substring(0, dash); String lastBytePos = rangeSpec.substring(dash + 1); Long firstByte = firstBytePos.isEmpty() ? null : Long.parseLong(firstBytePos); Long lastByte = lastBytePos.isEmpty() ? null : Long.parseLong(lastBytePos); return new Pair<>(firstByte, lastByte); }).peek(r -> logger.debug("parsed range {} {}", r.getFirst(), r.getSecond())) .collect(Collectors.toList()); } else { return null; } }