List of usage examples for java.util Enumeration hasMoreElements
boolean hasMoreElements();
From source file:NwFontChooserS.java
static public void setDefaultFont(Font f) { FontUIResource fui = new FontUIResource(f); Enumeration<Object> keys = UIManager.getDefaults().keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); Object value = UIManager.get(key); if (value instanceof FontUIResource) UIManager.put(key, fui); }/*from www . j a v a 2 s . c o m*/ }
From source file:de.mylifesucks.oss.ncsimulator.protocol.SerialComm.java
public static HashMap<String, CommPortIdentifier> getPorts() { if (portMap == null) { portMap = new HashMap<String, CommPortIdentifier>(); Enumeration portList = CommPortIdentifier.getPortIdentifiers(); while (portList.hasMoreElements()) { portId = (CommPortIdentifier) portList.nextElement(); if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { portMap.put(portId.getName(), portId); }/* w w w. ja v a 2s.com*/ } } return portMap; }
From source file:io.card.development.recording.Recording.java
private static Hashtable<String, byte[]> findManifestFiles(Hashtable<String, byte[]> recordingFiles) { Hashtable<String, byte[]> manifestFiles = new Hashtable<String, byte[]>(); Enumeration<String> fileNames = recordingFiles.keys(); while (fileNames.hasMoreElements()) { String fileName = fileNames.nextElement(); if (fileName.endsWith("manifest.json")) { manifestFiles.put(fileName, recordingFiles.get(fileName)); }/*from www . ja v a2 s. com*/ } return manifestFiles; }
From source file:com.modeln.build.ctrl.charts.CMnPatchCountChart.java
/** * Create a chart representing the number of patches per customer. * The data is passed in as a hashtable where the key is the customer * information and the value is the number of patch requests. * * @param data Hashtable containing accounts and the corresponding counts * @param label Count label/*from www. ja v a 2s . c om*/ * * @return Bar chart repesenting the customer and count information */ public static final JFreeChart getPatchesByCustomerChart(Hashtable<CMnAccount, Integer> data, String label) { Hashtable<String, Integer> hash = new Hashtable<String, Integer>(); Enumeration accountList = data.keys(); while (accountList.hasMoreElements()) { CMnAccount account = (CMnAccount) accountList.nextElement(); Integer value = data.get(account); hash.put(account.getName(), value); } return getBarChart(hash, label + " by Customer", "Customer", label); }
From source file:org.ambraproject.wombat.util.HttpMessageUtil.java
/** * Return a list of headers from a request, using an optional whitelist * * @param request a request/*from w w w . j a v a 2 s . c o m*/ * @return its headers */ public static Collection<Header> getRequestHeaders(HttpServletRequest request, ImmutableSet<String> headerWhitelist) { Enumeration headerNames = request.getHeaderNames(); List<Header> headers = Lists.newArrayList(); while (headerNames.hasMoreElements()) { String headerName = (String) headerNames.nextElement(); if (headerWhitelist.contains(headerName)) { String headerValue = request.getHeader(headerName); headers.add(new BasicHeader(headerName, headerValue)); } } return headers; }
From source file:NetworkUtil.java
/** * @return the current environment's IP address, taking into account the Internet connection to any of the available * machine's Network interfaces. Examples of the outputs can be in octats or in IPV6 format. * <pre>/* ww w . j a v a 2 s . com*/ * ==> wlan0 * * fec0:0:0:9:213:e8ff:fef1:b717%4 * siteLocal: true * isLoopback: false isIPV6: true * 130.212.150.216 <<<<<<<<<<<------------- This is the one we want to grab so that we can. * siteLocal: false address the DSP on the network. * isLoopback: false * isIPV6: false * * ==> lo * 0:0:0:0:0:0:0:1%1 * siteLocal: false * isLoopback: true * isIPV6: true * 127.0.0.1 * siteLocal: false * isLoopback: true * isIPV6: false * </pre> */ public static String getCurrentEnvironmentNetworkIp() { if (currentHostIpAddress == null) { Enumeration<NetworkInterface> netInterfaces = null; try { netInterfaces = NetworkInterface.getNetworkInterfaces(); while (netInterfaces.hasMoreElements()) { NetworkInterface ni = netInterfaces.nextElement(); Enumeration<InetAddress> address = ni.getInetAddresses(); while (address.hasMoreElements()) { InetAddress addr = address.nextElement(); // log.debug("Inetaddress:" + addr.getHostAddress() + " loop? " + addr.isLoopbackAddress() + " local? " // + addr.isSiteLocalAddress()); if (!addr.isLoopbackAddress() && addr.isSiteLocalAddress() && !(addr.getHostAddress().indexOf(":") > -1)) { currentHostIpAddress = addr.getHostAddress(); } } } if (currentHostIpAddress == null) { currentHostIpAddress = "127.0.0.1"; } } catch (SocketException e) { // log.error("Somehow we have a socket error acquiring the host IP... Using loopback instead..."); currentHostIpAddress = "127.0.0.1"; } } return currentHostIpAddress; }
From source file:com.glaf.core.config.ViewProperties.java
public static void reload() { if (!loading.get()) { InputStream inputStream = null; try {/*from w w w . j av a 2 s .co m*/ loading.set(true); String config = SystemProperties.getConfigRootPath() + "/conf/props/views"; File directory = new File(config); if (directory.exists() && directory.isDirectory()) { String[] filelist = directory.list(); if (filelist != null) { for (int i = 0, len = filelist.length; i < len; i++) { String filename = config + "/" + filelist[i]; File file = new File(filename); if (file.isFile() && file.getName().endsWith(".properties")) { inputStream = new FileInputStream(file); Properties p = PropertiesUtils.loadProperties(inputStream); if (p != null) { Enumeration<?> e = p.keys(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); String value = p.getProperty(key); properties.setProperty(key, value); properties.setProperty(key.toLowerCase(), value); properties.setProperty(key.toUpperCase(), value); } } IOUtils.closeStream(inputStream); } } } } } catch (Exception ex) { throw new RuntimeException(ex); } finally { loading.set(false); IOUtils.closeStream(inputStream); } } }
From source file:eu.leads.processor.planner.ClassUtil.java
private static void findClasses(Set<Class> matchedClassSet, File root, File file, boolean includeJars, Class type, String packageFilter) { if (file.isDirectory()) { for (File child : file.listFiles()) { findClasses(matchedClassSet, root, child, includeJars, type, packageFilter); }/*from w w w .ja v a 2 s . com*/ } else { if (file.getName().toLowerCase().endsWith(".jar") && includeJars) { JarFile jar = null; try { jar = new JarFile(file); } catch (Exception ex) { LOG.error(ex.getMessage(), ex); return; } Enumeration<JarEntry> entries = jar.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); String name = entry.getName(); int extIndex = name.lastIndexOf(".class"); if (extIndex > 0) { String qualifiedClassName = name.substring(0, extIndex).replace("/", "."); if (qualifiedClassName.indexOf(packageFilter) >= 0 && !isTestClass(qualifiedClassName)) { try { Class clazz = Class.forName(qualifiedClassName); if (!clazz.isInterface() && isMatch(type, clazz)) { matchedClassSet.add(clazz); } } catch (ClassNotFoundException e) { LOG.error(e.getMessage(), e); } } } } } else if (file.getName().toLowerCase().endsWith(".class")) { String qualifiedClassName = createClassName(root, file); // if (qualifiedClassName.indexOf(packageFilter) >= 0 && !isTestClass(qualifiedClassName)) { try { Class clazz = Class.forName(qualifiedClassName); if (!clazz.isInterface() && isMatch(type, clazz)) { matchedClassSet.add(clazz); } } catch (ClassNotFoundException e) { LOG.error(e.getMessage(), e); } // } } } }
From source file:spring.osgi.utils.OsgiResourceUtils.java
public static Resource[] convertURLEnumerationToResourceArray(Enumeration enm) { Set<Resource> resources = new LinkedHashSet<>(4); while (enm != null && enm.hasMoreElements()) { resources.add(new UrlResource((URL) enm.nextElement())); }// ww w. ja va2 s . c o m return resources.toArray(new Resource[resources.size()]); }
From source file:de.hypoport.ep2.support.configuration.properties.PropertiesLoader.java
static void replacePropertyPlaceHolder(Properties properties) { Enumeration<?> keyEnum = properties.propertyNames(); while (keyEnum.hasMoreElements()) { String key = (String) keyEnum.nextElement(); Object value = properties.get(key); if (value != null && value instanceof String) { String valueString = (String) value; valueString = replacePropertyPlaceHolder(valueString, properties); properties.put(key, valueString); }//from w w w. j a v a 2 s . co m } }