Java Code Examples for java.util.Enumeration

The following examples show how to use java.util.Enumeration. These examples are extracted from open source projects. 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 Project: armeria   Source File: DnsUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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 2
public String toString() {
    // Heuristic: 8 characters per field
    StringBuilder buffer = new StringBuilder(parameters.size() * 16);

    Enumeration<String> keys = parameters.keys();
    while(keys.hasMoreElements())
    {
        buffer.append("; ");

        String key = keys.nextElement();
        buffer.append(key);
        buffer.append('=');
           buffer.append(quote(parameters.get(key)));
    }

    return buffer.toString();
}
 
Example 3
Source Project: gemfirexd-oss   Source File: GFECompatibilityTest.java    License: Apache License 2.0 6 votes vote down vote up
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 4
Source Project: java-technology-stack   Source File: PropertyDescriptorUtils.java    License: MIT License 6 votes vote down vote up
/**
 * 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 5
Source Project: olat   Source File: OlatTestCase.java    License: Apache License 2.0 6 votes vote down vote up
@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 6
/**
 *
 **/
// 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 7
Source Project: openjdk-8   Source File: VersionHelper12.java    License: GNU General Public License v2.0 6 votes vote down vote up
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 8
Source Project: micro-integrator   Source File: PublisherUtil.java    License: Apache License 2.0 6 votes vote down vote up
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 9
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 10
Source Project: openjdk-jdk8u   Source File: IDLGenerator.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 11
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 12
Source Project: letv   Source File: FabricKitsFinder.java    License: Apache License 2.0 6 votes vote down vote up
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 13
Source Project: tsml   Source File: Stopwords.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 Project: gemfirexd-oss   Source File: ClassInvestigator.java    License: Apache License 2.0 6 votes vote down vote up
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 15
/**
 * 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 16
Source Project: jdk8u-jdk   Source File: HTMLWriter.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 17
Source Project: athenz   Source File: KeyStoreTest.java    License: Apache License 2.0 6 votes vote down vote up
@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 18
Source Project: brooklyn-server   Source File: ArchiveUtils.java    License: Apache License 2.0 6 votes vote down vote up
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 19
Source Project: qpid-jms   Source File: MulticastDiscoveryAgent.java    License: Apache License 2.0 6 votes vote down vote up
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 20
Source Project: ripple-lib-java   Source File: SignedData.java    License: ISC License 5 votes vote down vote up
private boolean checkForVersion3(ASN1Set signerInfs)
{
    for (Enumeration e = signerInfs.getObjects(); e.hasMoreElements();)
    {
        SignerInfo s = SignerInfo.getInstance(e.nextElement());

        if (s.getVersion().getValue().intValue() == 3)
        {
            return true;
        }
    }

    return false;
}
 
Example 21
Source Project: tomcatsrc   Source File: TestParameters.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testAddParameters() {
    Parameters p = new Parameters();

    // Empty at this point
    Enumeration<String> names = p.getParameterNames();
    assertFalse(names.hasMoreElements());
    String[] values = p.getParameterValues("foo");
    assertNull(values);

    // Add a parameter with two values
    p.addParameter("foo", "value1");
    p.addParameter("foo", "value2");

    names = p.getParameterNames();
    assertTrue(names.hasMoreElements());
    assertEquals("foo", names.nextElement());
    assertFalse(names.hasMoreElements());

    values = p.getParameterValues("foo");
    assertEquals(2, values.length);
    assertEquals("value1", values[0]);
    assertEquals("value2", values[1]);

    // Add two more values
    p.addParameter("foo", "value3");
    p.addParameter("foo", "value4");

    names = p.getParameterNames();
    assertTrue(names.hasMoreElements());
    assertEquals("foo", names.nextElement());
    assertFalse(names.hasMoreElements());

    values = p.getParameterValues("foo");
    assertEquals(4, values.length);
    assertEquals("value1", values[0]);
    assertEquals("value2", values[1]);
    assertEquals("value3", values[2]);
    assertEquals("value4", values[3]);
}
 
Example 22
protected boolean installExtension(ExtensionInfo reqInfo,
                                   ExtensionInfo instInfo)
    throws ExtensionInstallationException
{
    Vector<ExtensionInstallationProvider> currentProviders;
    synchronized(providers) {
        @SuppressWarnings("unchecked")
        Vector<ExtensionInstallationProvider> tmp =
            (Vector<ExtensionInstallationProvider>) providers.clone();
        currentProviders = tmp;
    }
    for (Enumeration<ExtensionInstallationProvider> e = currentProviders.elements();
            e.hasMoreElements();) {
        ExtensionInstallationProvider eip = e.nextElement();

        if (eip!=null) {
            // delegate the installation to the provider
            if (eip.installExtension(reqInfo, instInfo)) {
                debug(reqInfo.name + " installation successful");
                Launcher.ExtClassLoader cl = (Launcher.ExtClassLoader)
                    Launcher.getLauncher().getClassLoader().getParent();
                addNewExtensionsToClassLoader(cl);
                return true;
            }
        }
    }
    // We have tried all of our providers, noone could install this
    // extension, we just return failure at this point
    debug(reqInfo.name + " installation failed");
    return false;
}
 
Example 23
Source Project: qpid-jms   Source File: QueueBrowserIntegrationTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test(timeout=30000)
public void testCreateQueueBrowserAndEnumerationZeroPrefetch() throws IOException, Exception {
    try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
        Connection connection = testFixture.establishConnecton(testPeer, "?jms.prefetchPolicy.all=0");
        connection.start();

        testPeer.expectBegin();

        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Queue queue = session.createQueue("myQueue");

        // Expected the browser to create a consumer and NOT send credit.
        testPeer.expectQueueBrowserAttach();
        testPeer.expectDetach(true, true, true);

        QueueBrowser browser = session.createBrowser(queue);
        Enumeration<?> queueView = browser.getEnumeration();
        assertNotNull(queueView);

        browser.close();

        testPeer.expectClose();
        connection.close();

        testPeer.waitForAllHandlersToComplete(3000);
    }
}
 
Example 24
Source Project: The-5zig-Mod   Source File: NotifiableJarCopier.java    License: MIT License 5 votes vote down vote up
private NotifiableJarCopier(File[] jarFiles, File destinationJar, Callback<Float> callback) throws IOException {
	this.jarFiles = jarFiles;
	this.destinationJar = destinationJar;
	this.callback = callback;
	for (File jarFile : jarFiles) {
		JarFile file = new JarFile(jarFile);
		Enumeration entries = file.entries();
		while (entries.hasMoreElements()) {
			length += ((JarEntry) entries.nextElement()).getSize();
		}
	}
	run();
}
 
Example 25
Source Project: carbon-commons   Source File: JavaUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * creates the subscription object from the subscription resource
 *
 * @param subscriptionResource
 * @return
 */
public static Subscription getSubscription(Resource subscriptionResource) {

    Subscription subscription = new Subscription();
    subscription.setTenantId(CarbonContext.getThreadLocalCarbonContext().getTenantId());
    Properties properties = subscriptionResource.getProperties();
    if ((properties != null) && (!properties.isEmpty())) {
        for (Enumeration enumeration = properties.propertyNames(); enumeration.hasMoreElements();) {
            String propertyName = (String) enumeration.nextElement();
            if (EventBrokerConstants.EB_RES_SUBSCRIPTION_URL.equals(propertyName)) {
                subscription.setEventSinkURL(
                        subscriptionResource.getProperty(EventBrokerConstants.EB_RES_SUBSCRIPTION_URL));
            } else if (EventBrokerConstants.EB_RES_EVENT_DISPATCHER_NAME.equals(propertyName)) {
                subscription.setEventDispatcherName(
                        subscriptionResource.getProperty(EventBrokerConstants.EB_RES_EVENT_DISPATCHER_NAME));
            } else if (EventBrokerConstants.EB_RES_EXPIRS.equals(propertyName)) {
                subscription.setExpires(
                        ConverterUtil.convertToDateTime(
                                subscriptionResource.getProperty(EventBrokerConstants.EB_RES_EXPIRS)));
            } else if (EventBrokerConstants.EB_RES_OWNER.equals(propertyName)) {
                subscription.setOwner(subscriptionResource.getProperty(EventBrokerConstants.EB_RES_OWNER));
            } else if (EventBrokerConstants.EB_RES_TOPIC_NAME.equals(propertyName)) {
                subscription.setTopicName(subscriptionResource.getProperty(EventBrokerConstants.EB_RES_TOPIC_NAME));
            } else if (EventBrokerConstants.EB_RES_CREATED_TIME.equals(propertyName)) {
                subscription.setCreatedTime(new Date(Long.parseLong(subscriptionResource.getProperty(EventBrokerConstants.EB_RES_CREATED_TIME))));
            } else if (EventBrokerConstants.EB_RES_MODE.equals(propertyName)) {
                subscription.setMode(subscriptionResource.getProperty(EventBrokerConstants.EB_RES_MODE));
            } else {
                subscription.addProperty(propertyName, subscriptionResource.getProperty(propertyName));
            }
        }
    }
    return subscription;
}
 
Example 26
Source Project: hottub   Source File: ArrayTable.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the keys of the table, or <code>null</code> if there
 * are currently no bindings.
 * @param keys  array of keys
 * @return an array of bindings
 */
public Object[] getKeys(Object[] keys) {
    if (table == null) {
        return null;
    }
    if (isArray()) {
        Object[] array = (Object[])table;
        if (keys == null) {
            keys = new Object[array.length / 2];
        }
        for (int i = 0, index = 0 ;i < array.length-1 ; i+=2,
                 index++) {
            keys[index] = array[i];
        }
    } else {
        Hashtable<?,?> tmp = (Hashtable)table;
        Enumeration<?> enum_ = tmp.keys();
        int counter = tmp.size();
        if (keys == null) {
            keys = new Object[counter];
        }
        while (counter > 0) {
            keys[--counter] = enum_.nextElement();
        }
    }
    return keys;
}
 
Example 27
Source Project: juddi   Source File: Release.java    License: Apache License 2.0 5 votes vote down vote up
public static String getVersionFromManifest(String jarName) {
	Enumeration<URL> resEnum;
       try {
           resEnum = Thread.currentThread().getContextClassLoader().getResources(JarFile.MANIFEST_NAME);
           while (resEnum.hasMoreElements()) {
               try {
                   URL url = (URL) resEnum.nextElement();
                   if (url.toString().toLowerCase().contains(jarName)) {
                       InputStream is = url.openStream();
                       if (is != null) {
                           Manifest manifest = new Manifest(is);
                           Attributes mainAttribs = manifest.getMainAttributes();
                           String version = mainAttribs.getValue("Bundle-Version");
                           if (version != null) {
                               return (version);
                           }
                       }
                   }
               } catch (Exception e) {
                   // Silently ignore wrong manifests on classpath?
               }
           }
        } catch (IOException e1) {
           // Silently ignore wrong manifests on classpath?
        }
        return UNKNOWN;
}
 
Example 28
Source Project: tsml   Source File: LED24.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns an enumeration describing the available options.
 *
 * @return an enumeration of all the available options
 */
public Enumeration listOptions() {
  Vector result = enumToVector(super.listOptions());

  result.add(new Option(
            "\tThe noise percentage. (default " 
            + defaultNoisePercent() + ")",
            "N", 1, "-N <num>"));

  return result.elements();
}
 
Example 29
Source Project: lastaflute   Source File: SimpleRequestManager.java    License: Apache License 2.0 5 votes vote down vote up
protected List<String> getAttributeNameList() {
    final Enumeration<String> attributeNames = getRequest().getAttributeNames();
    final List<String> nameList = new ArrayList<String>();
    while (attributeNames.hasMoreElements()) {
        nameList.add((String) attributeNames.nextElement());
    }
    return Collections.unmodifiableList(nameList);
}
 
Example 30
Source Project: JDKSourceCode1.8   Source File: Area.java    License: MIT License 5 votes vote down vote up
/**
 * 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;
}