java.util.Enumeration Java Examples
The following examples show how to use
java.util.Enumeration.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VersionHelper12.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
NamingEnumeration<InputStream> getResources(final ClassLoader cl, final String name) throws IOException { Enumeration<URL> urls; try { urls = AccessController.doPrivileged( new PrivilegedExceptionAction<Enumeration<URL>>() { public Enumeration<URL> run() throws IOException { return (cl == null) ? ClassLoader.getSystemResources(name) : cl.getResources(name); } } ); } catch (PrivilegedActionException e) { throw (IOException)e.getException(); } return new InputStreamEnumeration(urls); }
Example #2
Source File: OlatTestCase.java From olat with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private void printOlatLocalProperties() { final Resource overwritePropertiesRes = new ClassPathResource("olat.local.properties"); try { final Properties overwriteProperties = new Properties(); overwriteProperties.load(overwritePropertiesRes.getInputStream()); final Enumeration<String> propNames = (Enumeration<String>) overwriteProperties.propertyNames(); System.out.println("### olat.local.properties : ###"); while (propNames.hasMoreElements()) { final String propName = propNames.nextElement(); System.out.println("++" + propName + "='" + overwriteProperties.getProperty(propName) + "'"); } } catch (final IOException e) { System.err.println("Could not load properties files from classpath! Exception=" + e); } }
Example #3
Source File: PropertyDescriptorUtils.java From java-technology-stack with MIT License | 6 votes |
/** * See {@link java.beans.FeatureDescriptor}. */ public static void copyNonMethodProperties(PropertyDescriptor source, PropertyDescriptor target) { target.setExpert(source.isExpert()); target.setHidden(source.isHidden()); target.setPreferred(source.isPreferred()); target.setName(source.getName()); target.setShortDescription(source.getShortDescription()); target.setDisplayName(source.getDisplayName()); // Copy all attributes (emulating behavior of private FeatureDescriptor#addTable) Enumeration<String> keys = source.attributeNames(); while (keys.hasMoreElements()) { String key = keys.nextElement(); target.setValue(key, source.getValue(key)); } // See java.beans.PropertyDescriptor#PropertyDescriptor(PropertyDescriptor) target.setPropertyEditorClass(source.getPropertyEditorClass()); target.setBound(source.isBound()); target.setConstrained(source.isConstrained()); }
Example #4
Source File: MulticastDiscoveryAgent.java From qpid-jms with Apache License 2.0 | 6 votes |
private static List<NetworkInterface> findNetworkInterfaces() throws SocketException { Enumeration<NetworkInterface> ifcs = NetworkInterface.getNetworkInterfaces(); List<NetworkInterface> interfaces = new ArrayList<NetworkInterface>(); while (ifcs.hasMoreElements()) { NetworkInterface ni = ifcs.nextElement(); LOG.trace("findNetworkInterfaces checking interface: {}", ni); if (ni.supportsMulticast() && ni.isUp()) { for (InterfaceAddress ia : ni.getInterfaceAddresses()) { if (ia.getAddress() instanceof java.net.Inet4Address && !ia.getAddress().isLoopbackAddress() && !DEFAULT_EXCLUSIONS.contains(ni.getName())) { // Add at the start, make usage order consistent with the // existing ActiveMQ releases discovery will be used with. interfaces.add(0, ni); break; } } } } LOG.trace("findNetworkInterfaces returning: {}", interfaces); return interfaces; }
Example #5
Source File: GFECompatibilityTest.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
private List<Class> getRegionEntryClassesFromJar(String jarFile, String pkg) throws Exception { List<Class> regionEntryClasses = new ArrayList<Class>(); JarFile gfJar = new JarFile(jarFile, true); Enumeration<JarEntry> enm = gfJar.entries(); while (enm.hasMoreElements()) { JarEntry je = enm.nextElement(); String name = je.getName().replace('/', '.'); if (name.startsWith(pkg) && name.endsWith(".class")) { Class jeClass = Class.forName(name.replaceAll(".class", "")); if (!jeClass.isInterface() && RegionEntry.class.isAssignableFrom(jeClass) && !isInExclusionList(jeClass)) { int modifiers = jeClass.getModifiers(); if ((modifiers & Modifier.ABSTRACT) == 0) { regionEntryClasses.add(jeClass); } } } } return regionEntryClasses; }
Example #6
Source File: ClassInvestigator.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public Enumeration getStrings() { HashSet strings = new HashSet(30, 0.8f); int size = cptEntries.size(); for (int i = 1; i < size; i++) { ConstantPoolEntry cpe = getEntry(i); if ((cpe == null) || (cpe.getTag() != VMDescriptor.CONSTANT_String)) continue; CONSTANT_Index_info cii = (CONSTANT_Index_info) cpe; strings.add(nameIndexToString(cii.getI1())); } return java.util.Collections.enumeration(strings); }
Example #7
Source File: DSequence.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Returns the named variable in the given row of the sequence. * * @param row the row number to retrieve. * @param name the name of the variable. * @return the named variable. * @throws NoSuchVariableException if the named variable does not * exist in this container. */ public BaseType getVariable(int row, String name) throws NoSuchVariableException { int dotIndex = name.indexOf('.'); if (dotIndex != -1) { // name contains "." String aggregate = name.substring(0, dotIndex); String field = name.substring(dotIndex + 1); BaseType aggRef = getVariable(aggregate); if (aggRef instanceof DConstructor) return ((DConstructor) aggRef).getVariable(field); // recurse else ; // fall through to throw statement } else { Vector selectedRow = (Vector) allValues.elementAt(row); for (Enumeration e = selectedRow.elements(); e.hasMoreElements();) { BaseType v = (BaseType) e.nextElement(); if (v.getEncodedName().equals(name)) return v; } } throw new NoSuchVariableException("DSequence: getVariable()"); }
Example #8
Source File: Arguments.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * **/ // XXX Either generalize this facility or remove it completely. protected void packageFromProps (Properties props) throws InvalidArgument { Enumeration propsEnum = props.propertyNames (); while (propsEnum.hasMoreElements ()) { String prop = (String)propsEnum.nextElement (); if (prop.startsWith ("PkgPrefix.")) { String type = prop.substring (10); String pkg = props.getProperty (prop); checkPackageNameValid( pkg ) ; checkPackageNameValid( type ) ; packages.put (type, pkg); } } }
Example #9
Source File: PublisherUtil.java From micro-integrator with Apache License 2.0 | 6 votes |
private static InetAddress getLocalAddress() { Enumeration<NetworkInterface> ifaces = null; try { ifaces = NetworkInterface.getNetworkInterfaces(); } catch (SocketException e) { log.error("Failed to get host address", e); } if (ifaces != null) { while (ifaces.hasMoreElements()) { NetworkInterface iface = ifaces.nextElement(); Enumeration<InetAddress> addresses = iface.getInetAddresses(); while (addresses.hasMoreElements()) { InetAddress addr = addresses.nextElement(); if (addr instanceof Inet4Address && !addr.isLoopbackAddress()) { return addr; } } } } return null; }
Example #10
Source File: ArchiveUtils.java From brooklyn-server with Apache License 2.0 | 6 votes |
public static void extractZip(final ZipFile zip, final String targetFolder) { new File(targetFolder).mkdir(); Enumeration<? extends ZipEntry> zipFileEntries = zip.entries(); while (zipFileEntries.hasMoreElements()) { ZipEntry entry = (ZipEntry) zipFileEntries.nextElement(); File destFile = new File(targetFolder, entry.getName()); destFile.getParentFile().mkdirs(); if (!entry.isDirectory()) { try (InputStream in=zip.getInputStream(entry); OutputStream out=new FileOutputStream(destFile)) { Streams.copy(in, out); } catch (IOException e) { throw Exceptions.propagate(e); } } } }
Example #11
Source File: DnsUtil.java From armeria with Apache License 2.0 | 6 votes |
/** * Returns {@code true} if any {@link NetworkInterface} supports {@code IPv6}, {@code false} otherwise. */ public static boolean anyInterfaceSupportsIpV6() { try { final Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); while (interfaces.hasMoreElements()) { final NetworkInterface iface = interfaces.nextElement(); final Enumeration<InetAddress> addresses = iface.getInetAddresses(); while (addresses.hasMoreElements()) { final InetAddress inetAddress = addresses.nextElement(); if (inetAddress instanceof Inet6Address && !inetAddress.isAnyLocalAddress() && !inetAddress.isLoopbackAddress() && !inetAddress.isLinkLocalAddress()) { return true; } } } } catch (SocketException e) { logger.debug("Unable to detect if any interface supports IPv6, assuming IPv4-only", e); } return false; }
Example #12
Source File: I18N.java From document-management-software with GNU Lesser General Public License v3.0 | 6 votes |
public static Map<String, String> getMessages(Locale locale) { Map<String, String> map = new HashMap<String, String>(); for (String b : bundles) { try { ResourceBundle bundle = ResourceBundle.getBundle(b, locale); Enumeration<String> keys = bundle.getKeys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); if (!bundle.containsKey(key)) continue; String val = bundle.getString(key); if (val != null && !val.isEmpty()) map.put(key, bundle.getString(key)); } } catch (Throwable t) { } } return map; }
Example #13
Source File: Stopwords.java From tsml with GNU General Public License v3.0 | 6 votes |
/** * Writes the current stopwords to the given writer. The writer is closed * automatically. * * @param writer the writer to get the stopwords from * @throws Exception if writing fails */ public void write(BufferedWriter writer) throws Exception { Enumeration enm; // header writer.write("# generated " + new Date()); writer.newLine(); enm = elements(); while (enm.hasMoreElements()) { writer.write(enm.nextElement().toString()); writer.newLine(); } writer.flush(); writer.close(); }
Example #14
Source File: IDLGenerator.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Write forward references for referenced interfaces and valuetypes * ...but not if the reference is to a boxed IDLEntity, * @param refHash Hashtable loaded with referenced types * @param p The output stream. */ protected void writeForwardReferences( Hashtable refHash, IndentingWriter p ) throws IOException { Enumeration refEnum = refHash.elements(); nextReference: while ( refEnum.hasMoreElements() ) { Type t = (Type)refEnum.nextElement(); if ( t.isCompound() ) { CompoundType ct = (CompoundType)t; if ( ct.isIDLEntity() ) continue nextReference; //ignore IDLEntity reference } writeForwardReference( t,p ); } }
Example #15
Source File: FabricKitsFinder.java From letv with Apache License 2.0 | 6 votes |
public Map<String, KitInfo> call() throws Exception { Map<String, KitInfo> kitInfos = new HashMap(); long startScan = SystemClock.elapsedRealtime(); int count = 0; ZipFile apkFile = loadApkFile(); Enumeration<? extends ZipEntry> entries = apkFile.entries(); while (entries.hasMoreElements()) { count++; ZipEntry entry = (ZipEntry) entries.nextElement(); if (entry.getName().startsWith(FABRIC_DIR) && entry.getName().length() > FABRIC_DIR.length()) { KitInfo kitInfo = loadKitInfo(entry, apkFile); if (kitInfo != null) { kitInfos.put(kitInfo.getIdentifier(), kitInfo); Fabric.getLogger().v(Fabric.TAG, String.format("Found kit:[%s] version:[%s]", new Object[]{kitInfo.getIdentifier(), kitInfo.getVersion()})); } } } if (apkFile != null) { try { apkFile.close(); } catch (IOException e) { } } Fabric.getLogger().v(Fabric.TAG, "finish scanning in " + (SystemClock.elapsedRealtime() - startScan) + " reading:" + count); return kitInfos; }
Example #16
Source File: KeyStoreTest.java From athenz with Apache License 2.0 | 6 votes |
@Test public void testCreateKeyStoreFromPems() throws Exception { String athenzPublicCertPem = Resources.toString( Resources.getResource("rsa_public_x510_w_intermediate.cert"), StandardCharsets.UTF_8); String athenzPrivateKeyPem = Resources.toString( Resources.getResource("unit_test_rsa_private.key"), StandardCharsets.UTF_8); KeyStore keyStore = Utils.createKeyStoreFromPems(athenzPublicCertPem, athenzPrivateKeyPem); assertNotNull(keyStore); String alias = null; for (Enumeration<?> e = keyStore.aliases(); e.hasMoreElements(); ) { alias = (String) e.nextElement(); assertEquals(ALIAS_NAME, alias); } X509Certificate[] chain = (X509Certificate[]) keyStore.getCertificateChain(alias); assertNotNull(chain); assertTrue(chain.length == 2); }
Example #17
Source File: TetheringStateManager.java From bitmask_android with GNU General Public License v3.0 | 6 votes |
private static NetworkInterface getNetworkInterface(String[] interfaceNames) { try { for(Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) { NetworkInterface networkInterface = en.nextElement(); if(!networkInterface.isLoopback()){ for (String interfaceName : interfaceNames) { if (networkInterface.getName().contains(interfaceName)) { return networkInterface; } } } } } catch(Exception e){ e.printStackTrace(); } return null; }
Example #18
Source File: HTMLWriter.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Searches for embedded tags in the AttributeSet * and writes them out. It also stores these tags in a vector * so that when appropriate the corresponding end tags can be * written out. * * @exception IOException on any I/O error */ protected void writeEmbeddedTags(AttributeSet attr) throws IOException { // translate css attributes to html attr = convertToHTML(attr, oConvAttr); Enumeration names = attr.getAttributeNames(); while (names.hasMoreElements()) { Object name = names.nextElement(); if (name instanceof HTML.Tag) { HTML.Tag tag = (HTML.Tag)name; if (tag == HTML.Tag.FORM || tags.contains(tag)) { continue; } write('<'); write(tag.toString()); Object o = attr.getAttribute(tag); if (o != null && o instanceof AttributeSet) { writeAttributes((AttributeSet)o); } write('>'); tags.addElement(tag); tagValues.addElement(o); } } }
Example #19
Source File: VariableHeightLayoutCache.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns the children of the receiver. * If the receiver is not currently expanded, this will return an * empty enumeration. */ public Enumeration children() { if (!this.isExpanded()) { return DefaultMutableTreeNode.EMPTY_ENUMERATION; } else { return super.children(); } }
Example #20
Source File: PackageDetector.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 5 votes |
protected static Map<String, Set<String>> detectPackagesInZip(final ZipFile file, final PackageCollector visitor) throws IOException { final Enumeration<? extends ZipEntry> entries = file.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); String name = entry.getName(); // TODO: accept wars, ears? if (name.endsWith(".jar")) { final File jarFile = File.createTempFile("swarmPackageDetector", ".jar"); jarFile.deleteOnExit(); try (InputStream in = file.getInputStream(entry); FileOutputStream out = new FileOutputStream(jarFile)) { IOUtils.copy(in, out); } detectPackagesInZip(new ZipFile(jarFile), visitor); } else if (name.endsWith(".class")) { try (InputStream in = file.getInputStream(entry)) { new ClassReader(in).accept(visitor, 0); } } } return visitor.packageSources(); }
Example #21
Source File: SourceGroupSupport.java From netbeans with Apache License 2.0 | 5 votes |
public static FileObject findJavaSourceFile(Project project, String name) { for (SourceGroup group : getJavaSourceGroups(project)) { Enumeration<? extends FileObject> files = group.getRootFolder().getChildren(true); while (files.hasMoreElements()) { FileObject fo = files.nextElement(); if ("java".equals(fo.getExt())) { //NOI18N if (name.equals(fo.getName())) { return fo; } } } } return null; }
Example #22
Source File: lalr_state.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** Helper routine for debugging -- produces a dump of the given state * onto System.out. */ protected static void dump_state(lalr_state st) throws internal_error { lalr_item_set itms; lalr_item itm; production_part part; if (st == null) { System.out.println("NULL lalr_state"); return; } System.out.println("lalr_state [" + st.index() + "] {"); itms = st.items(); for (Enumeration e = itms.all(); e.hasMoreElements(); ) { itm = (lalr_item)e.nextElement(); System.out.print(" ["); System.out.print(itm.the_production().lhs().the_symbol().name()); System.out.print(" ::= "); for (int i = 0; i<itm.the_production().rhs_length(); i++) { if (i == itm.dot_pos()) System.out.print("(*) "); part = itm.the_production().rhs(i); if (part.is_action()) System.out.print("{action} "); else System.out.print(((symbol_part)part).the_symbol().name() + " "); } if (itm.dot_at_end()) System.out.print("(*) "); System.out.println("]"); } System.out.println("}"); }
Example #23
Source File: NotificationMgtConfigBuilder.java From carbon-identity-framework with Apache License 2.0 | 5 votes |
/** * Build and store per module configuration objects */ private void build() { Properties moduleNames = NotificationManagementUtils.getSubProperties(NotificationMgtConstants.Configs. MODULE_NAME, notificationMgtConfigProperties); Enumeration propertyNames = moduleNames.propertyNames(); // Iterate through events and build event objects while (propertyNames.hasMoreElements()) { String key = (String) propertyNames.nextElement(); String moduleName = (String) moduleNames.remove(key); moduleConfiguration.put(moduleName, buildModuleConfigurations(moduleName)); } }
Example #24
Source File: ColoringStorage.java From netbeans with Apache License 2.0 | 5 votes |
private static void mergeAttributeSets(SimpleAttributeSet original, AttributeSet toMerge) { for(Enumeration names = toMerge.getAttributeNames(); names.hasMoreElements(); ) { Object key = names.nextElement(); Object value = toMerge.getAttribute(key); original.addAttribute(key, value); } }
Example #25
Source File: PrometheusTextFormat.java From pulsar with Apache License 2.0 | 5 votes |
/** * Write out the text version 0.0.4 of the given MetricFamilySamples. */ public static void write004(Writer writer, Enumeration<Collector.MetricFamilySamples> mfs) throws IOException { /* * See http://prometheus.io/docs/instrumenting/exposition_formats/ for the output format specification. */ while (mfs.hasMoreElements()) { Collector.MetricFamilySamples metricFamilySamples = mfs.nextElement(); for (Collector.MetricFamilySamples.Sample sample : metricFamilySamples.samples) { writer.write(sample.name); if (sample.labelNames.size() > 0) { writer.write('{'); for (int i = 0; i < sample.labelNames.size(); ++i) { writer.write(sample.labelNames.get(i)); writer.write("=\""); writeEscapedLabelValue(writer, sample.labelValues.get(i)); writer.write("\","); } writer.write('}'); } writer.write(' '); writer.write(Collector.doubleToGoString(sample.value)); if (sample.timestampMs != null) { writer.write(' '); writer.write(sample.timestampMs.toString()); } writer.write('\n'); } } }
Example #26
Source File: OSPLog.java From osp with GNU General Public License v3.0 | 5 votes |
/** * Sets the logger level. * * @param level the Level */ public static void setLevel(Level level) { if(OSPRuntime.appletMode||(OSPRuntime.applet!=null)) { org.opensourcephysics.controls.MessageFrame.setLevel(level); } else { try { getOSPLog().getLogger().setLevel(level); } catch(Exception ex) { // throws security exception if the caller does not have LoggingPermission("control"). // keep the current level } // refresh the level menus if the menubar exists if((getOSPLog()==null)||(getOSPLog().menubarGroup==null)) { return; } for(int i = 0; i<2; i++) { Enumeration<AbstractButton> e = getOSPLog().menubarGroup.getElements(); if(i==1) { e = getOSPLog().popupGroup.getElements(); } while(e.hasMoreElements()) { JMenuItem item = (JMenuItem) e.nextElement(); if(getOSPLog().getLogger().getLevel().toString().equals(item.getActionCommand())) { item.setSelected(true); break; } } } } }
Example #27
Source File: XmlUtil.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Gets a default EntityResolver for catalog at META-INF/jaxws-catalog.xml */ public static EntityResolver createDefaultCatalogResolver() { // set up a manager CatalogManager manager = new CatalogManager(); manager.setIgnoreMissingProperties(true); // Using static catalog may result in to sharing of the catalog by multiple apps running in a container manager.setUseStaticCatalog(false); // parse the catalog ClassLoader cl = Thread.currentThread().getContextClassLoader(); Enumeration<URL> catalogEnum; Catalog catalog = manager.getCatalog(); try { if (cl == null) { catalogEnum = ClassLoader.getSystemResources("META-INF/jax-ws-catalog.xml"); } else { catalogEnum = cl.getResources("META-INF/jax-ws-catalog.xml"); } while(catalogEnum.hasMoreElements()) { URL url = catalogEnum.nextElement(); catalog.parseCatalog(url); } } catch (IOException e) { throw new WebServiceException(e); } return workaroundCatalogResolver(catalog); }
Example #28
Source File: IfStatementExpressionAnalyzer.java From JDeodorant with MIT License | 5 votes |
public int getNumberOfConditionalOperatorNodes() { int counter = 0; Enumeration<DefaultMutableTreeNode> enumeration = root.breadthFirstEnumeration(); while(enumeration.hasMoreElements()) { DefaultMutableTreeNode node = enumeration.nextElement(); if(!node.isLeaf()) { counter++; } } return counter; }
Example #29
Source File: ZipUtils.java From zuihou-admin-boot with Apache License 2.0 | 5 votes |
public static void unZipFiles(File zipFile, String descDir) throws IOException { if (!descDir.endsWith(SLASH)) { descDir += SLASH; } File pathFile = new File(descDir); if (!pathFile.exists()) { pathFile.mkdirs(); } try (ZipFile zip = new ZipFile(zipFile)) { for (Enumeration entries = zip.entries(); entries.hasMoreElements(); ) { ZipEntry entry = (ZipEntry) entries.nextElement(); String zipEntryName = entry.getName(); String outPath = (descDir + zipEntryName).replaceAll("\\*", SLASH); //判断路径是否存在,不存在则创建文件路径 File file = new File(outPath.substring(0, outPath.lastIndexOf('/'))); if (!file.exists()) { file.mkdirs(); } //判断文件全路径是否为文件夹,如果是上面已经上传,不需要解压 if (new File(outPath).isDirectory()) { continue; } try (InputStream in = zip.getInputStream(entry); OutputStream out = new FileOutputStream(outPath)) { byte[] buf1 = new byte[1024]; int len; while ((len = in.read(buf1)) > 0) { out.write(buf1, 0, len); } } } } catch (ZipException e) { throw e; } }
Example #30
Source File: Area.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Tests whether this <code>Area</code> consists entirely of * straight edged polygonal geometry. * @return <code>true</code> if the geometry of this * <code>Area</code> consists entirely of line segments; * <code>false</code> otherwise. * @since 1.2 */ public boolean isPolygonal() { Enumeration enum_ = curves.elements(); while (enum_.hasMoreElements()) { if (((Curve) enum_.nextElement()).getOrder() > 1) { return false; } } return true; }