当前位置: 首页>>代码示例>>Java>>正文


Java Enumeration.hasMoreElements方法代码示例

本文整理汇总了Java中java.util.Enumeration.hasMoreElements方法的典型用法代码示例。如果您正苦于以下问题:Java Enumeration.hasMoreElements方法的具体用法?Java Enumeration.hasMoreElements怎么用?Java Enumeration.hasMoreElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Enumeration的用法示例。


在下文中一共展示了Enumeration.hasMoreElements方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBroadcastAddress

import java.util.Enumeration; //导入方法依赖的package包/类
static List<String> getBroadcastAddress() throws BrowsingException, SocketException {
  Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();

  List<String> broadcastAddresses = new ArrayList<>();

  while (interfaces.hasMoreElements()) {
    NetworkInterface networkInterface = interfaces.nextElement();
    if (networkInterface.isLoopback()) {
      continue;
    }

    for (InterfaceAddress interfaceAddress :
            networkInterface.getInterfaceAddresses()) {
      InetAddress broadcast = interfaceAddress.getBroadcast();

      if (broadcast != null) {
        broadcastAddresses.add(broadcast.toString().substring(1));
      }
    }
  }

  return broadcastAddresses;
}
 
开发者ID:google,项目名称:samba-documents-provider,代码行数:24,代码来源:BroadcastUtils.java

示例2: toString

import java.util.Enumeration; //导入方法依赖的package包/类
/**
 * Return a String rendering of this object.
 */
public String toString() {

    StringBuffer sb = new StringBuffer("ServiceRef[");
    sb.append("className=");
    sb.append(getClassName());
    sb.append(",factoryClassLocation=");
    sb.append(getFactoryClassLocation());
    sb.append(",factoryClassName=");
    sb.append(getFactoryClassName());
    Enumeration refAddrs = getAll();
    while (refAddrs.hasMoreElements()) {
        RefAddr refAddr = (RefAddr) refAddrs.nextElement();
        sb.append(",{type=");
        sb.append(refAddr.getType());
        sb.append(",content=");
        sb.append(refAddr.getContent());
        sb.append("}");
    }
    sb.append("]");
    return (sb.toString());

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:ServiceRef.java

示例3: implies

import java.util.Enumeration; //导入方法依赖的package包/类
/**
 * Check and see if this CryptoPermission object implies
 * the given Permission object.
 *
 * @param permission the Permission object to compare
 *
 * @return true if the given permission  is implied by this
 * CryptoPermissionCollection, false if not.
 */
public boolean implies(Permission permission) {
    if (!(permission instanceof CryptoPermission))
        return false;

    CryptoPermission cp = (CryptoPermission)permission;

    Enumeration<Permission> e = permissions.elements();

    while (e.hasMoreElements()) {
        CryptoPermission x = (CryptoPermission) e.nextElement();
        if (x.implies(cp)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:CryptoPermission.java

示例4: ExtendedKeyUsage

import java.util.Enumeration; //导入方法依赖的package包/类
public ExtendedKeyUsage(
    ASN1Sequence  seq)
{
    this.seq = seq;

    Enumeration e = seq.getObjects();

    while (e.hasMoreElements())
    {
        Object  o = e.nextElement();
        if (!(o instanceof DERObjectIdentifier))
        {
            throw new IllegalArgumentException("Only DERObjectIdentifiers allowed in ExtendedKeyUsage.");
        }
        this.usageTable.put(o, o);
    }
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:18,代码来源:ExtendedKeyUsage.java

示例5: getIp

import java.util.Enumeration; //导入方法依赖的package包/类
public String getIp() {
    String id = "-1";
    try {
        Enumeration<NetworkInterface> allNetInterfaces = NetworkInterface.getNetworkInterfaces();
        InetAddress ip = null;
        while (allNetInterfaces.hasMoreElements()) {
            NetworkInterface netInterface = (NetworkInterface) allNetInterfaces.nextElement();
            if (netInterface.isLoopback() || netInterface.isVirtual() || !netInterface.isUp()) {
                continue;
            } else {
                Enumeration<InetAddress> addresses = netInterface.getInetAddresses();
                while (addresses.hasMoreElements()) {
                    ip = addresses.nextElement();
                    if (ip != null && ip instanceof Inet4Address) {
                        id = ip.getHostAddress();
                    }
                }
            }
        }
    } catch (Exception e) {
        logger.error("Cannot get Id, something wrong with getting Ipv4 address");
    }
    return id;
}
 
开发者ID:xiongbeer,项目名称:Cobweb,代码行数:25,代码来源:IdProvider.java

示例6: loadEngines

import java.util.Enumeration; //导入方法依赖的package包/类
/**
 * This method is used internally to load markup engines. Markup engines are found using descriptor files on classpath, so
 * adding an engine is as easy as adding a jar on classpath with the descriptor file included.
 */
private static void loadEngines() {
    try {
        ClassLoader cl = Engines.class.getClassLoader();
        Enumeration<URL> resources = cl.getResources("META-INF/org.jbake.parser.MarkupEngines.properties");
        while (resources.hasMoreElements()) {
            URL url = resources.nextElement();
            Properties props = new Properties();
            props.load(url.openStream());
            for (Map.Entry<Object, Object> entry : props.entrySet()) {
                String className = (String) entry.getKey();
                String[] extensions = ((String)entry.getValue()).split(",");
                registerEngine(className, extensions);
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:23,代码来源:Engines.java

示例7: initialize

import java.util.Enumeration; //导入方法依赖的package包/类
public static void initialize() {
    synchronized (ProviderRegistry.class) {
        if (initialized)
            return;
        IPAuthenticationProvider ipp = new IPAuthenticationProvider();
        DigestAuthenticationProvider digp = new DigestAuthenticationProvider();
        authenticationProviders.put(ipp.getScheme(), ipp);
        authenticationProviders.put(digp.getScheme(), digp);
        Enumeration<Object> en = System.getProperties().keys();
        while (en.hasMoreElements()) {
            String k = (String) en.nextElement();
            if (k.startsWith("zookeeper.authProvider.")) {
                String className = System.getProperty(k);
                try {
                    Class<?> c = ZooKeeperServer.class.getClassLoader()
                            .loadClass(className);
                    AuthenticationProvider ap = (AuthenticationProvider) c
                            .newInstance();
                    authenticationProviders.put(ap.getScheme(), ap);
                } catch (Exception e) {
                    LOG.warn("Problems loading " + className,e);
                }
            }
        }
        initialized = true;
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:28,代码来源:ProviderRegistry.java

示例8: resolveX509SKI

import java.util.Enumeration; //导入方法依赖的package包/类
private PrivateKey resolveX509SKI(XMLX509SKI x509SKI) throws XMLSecurityException, KeyStoreException {
    log.log(java.util.logging.Level.FINE, "Can I resolve X509SKI?");

    Enumeration<String> aliases = keyStore.aliases();
    while (aliases.hasMoreElements()) {
        String alias = aliases.nextElement();
        if (keyStore.isKeyEntry(alias)) {

            Certificate cert = keyStore.getCertificate(alias);
            if (cert instanceof X509Certificate) {
                XMLX509SKI certSKI = new XMLX509SKI(x509SKI.getDocument(), (X509Certificate) cert);

                if (certSKI.equals(x509SKI)) {
                    log.log(java.util.logging.Level.FINE, "match !!! ");

                    try {
                        Key key = keyStore.getKey(alias, password);
                        if (key instanceof PrivateKey) {
                            return (PrivateKey) key;
                        }
                    } catch (Exception e) {
                        log.log(java.util.logging.Level.FINE, "Cannot recover the key", e);
                        // Keep searching
                    }
                }
            }
        }
    }

    return null;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:32,代码来源:PrivateKeyResolver.java

示例9: selectActionByName

import java.util.Enumeration; //导入方法依赖的package包/类
private void selectActionByName(String action) {
    AbstractXMPPAction actionObj = actions.get(action);
    Enumeration<AbstractButton> buttons = actionsGroup.getElements();
    if (actionObj != null) {
        while (buttons.hasMoreElements()) {
            AbstractButton button = buttons.nextElement();
            if (button.getText().equals(actionObj.getLabel())) {
                button.doClick();
                return;
            }
        }
    }
    log.warn("Did not find control to select for action: " + action);
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:15,代码来源:JMeterXMPPSamplerGui.java

示例10: clearJdbcDriverRegistrations

import java.util.Enumeration; //导入方法依赖的package包/类
public List<String> clearJdbcDriverRegistrations() throws SQLException {
    List<String> driverNames = new ArrayList<String>();

    /*
     * DriverManager.getDrivers() has a nasty side-effect of registering
     * drivers that are visible to this class loader but haven't yet been
     * loaded. Therefore, the first call to this method a) gets the list
     * of originally loaded drivers and b) triggers the unwanted
     * side-effect. The second call gets the complete list of drivers
     * ensuring that both original drivers and any loaded as a result of the
     * side-effects are all de-registered.
     */
    HashSet<Driver> originalDrivers = new HashSet<Driver>();
    Enumeration<Driver> drivers = DriverManager.getDrivers();
    while (drivers.hasMoreElements()) {
        originalDrivers.add(drivers.nextElement());
    }
    drivers = DriverManager.getDrivers();
    while (drivers.hasMoreElements()) {
        Driver driver = drivers.nextElement();
        // Only unload the drivers this web app loaded
        if (driver.getClass().getClassLoader() !=
            this.getClass().getClassLoader()) {
            continue;
        }
        // Only report drivers that were originally registered. Skip any
        // that were registered as a side-effect of this code.
        if (originalDrivers.contains(driver)) {
            driverNames.add(driver.getClass().getCanonicalName());
        }
        DriverManager.deregisterDriver(driver);
    }
    return driverNames;
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:35,代码来源:JdbcLeakPrevention.java

示例11: findJarFileSystemInRepository

import java.util.Enumeration; //导入方法依赖的package包/类
private static JarFileSystem findJarFileSystemInRepository(File jarFile) {
    @SuppressWarnings("deprecation") // for compat only
    Enumeration<? extends FileSystem> en = Repository.getDefault().getFileSystems();
    while (en.hasMoreElements()) {
        FileSystem fs = en.nextElement();
        if (fs instanceof JarFileSystem) {
            JarFileSystem jfs = (JarFileSystem)fs;
            if (jarFile.equals(jfs.getJarFile())) {
                return jfs;
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:ArchiveURLMapper.java

示例12: getCurrentTestCaseState

import java.util.Enumeration; //导入方法依赖的package包/类
/**
 * This event can not go through the regular way of sending log4j events in the case with Passive DB appenders. 
 * The reason is that we have to evaluate the result after the work of each passive appender and stop
 * calling these appenders when the first one(the only one serving this caller) has processed the event. 
 */
@SuppressWarnings( "unchecked")
public TestCaseState getCurrentTestCaseState() {

    GetCurrentTestCaseEvent event = new GetCurrentTestCaseEvent(ATS_DB_LOGGER_CLASS_NAME, logger);

    Enumeration<Appender> appenders = Logger.getRootLogger().getAllAppenders();
    while (appenders.hasMoreElements()) {
        Appender appender = appenders.nextElement();

        if (appender instanceof ActiveDbAppender) {
            // Comes here on Test Executor side. There is just 1 Active appender
            return ((ActiveDbAppender) appender).getCurrentTestCaseState(event).getTestCaseState();
        } else if (appender instanceof PassiveDbAppender) {
            // Comes here on Agent side. There will be 1 Passive appender per caller

            // Pass the event to any existing appender.
            // The correct one will return result, wrong appenders will return null.
            GetCurrentTestCaseEvent resultEvent = ((PassiveDbAppender) appender).getCurrentTestCaseState(event);
            if (resultEvent != null) {
                // we found the right Passive appender
                return resultEvent.getTestCaseState();
            }
        }
    }

    // no appropriate appender found
    return null;
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:34,代码来源:AtsDbLogger.java

示例13: sessionFromSerializedData

import java.util.Enumeration; //导入方法依赖的package包/类
public DeserializedSessionContainer sessionFromSerializedData(String id, byte[] data) throws IOException {
  log.trace("Deserializing session " + id + " from Redis");

  if (Arrays.equals(NULL_SESSION, data)) {
    log.error("Encountered serialized session " + id + " with data equal to NULL_SESSION. This is a bug.");
    throw new IOException("Serialized session data was equal to NULL_SESSION");
  }

  RedisSession session = null;
  SessionSerializationMetadata metadata = new SessionSerializationMetadata();

  try {
    session = (RedisSession)createEmptySession();

    serializer.deserializeInto(data, session, metadata);

    session.setId(id);
    session.setNew(false);
    session.setMaxInactiveInterval(getMaxInactiveInterval());
    session.access();
    session.setValid(true);
    session.resetDirtyTracking();

    if (log.isTraceEnabled()) {
      log.trace("Session Contents [" + id + "]:");
      Enumeration en = session.getAttributeNames();
      while(en.hasMoreElements()) {
        log.trace("  " + en.nextElement());
      }
    }
  } catch (ClassNotFoundException ex) {
    log.fatal("Unable to deserialize into session", ex);
    throw new IOException("Unable to deserialize into session", ex);
  }

  return new DeserializedSessionContainer(session, metadata);
}
 
开发者ID:ctchengt,项目名称:tomcat8-redis-session-manager,代码行数:38,代码来源:RedisSessionManager.java

示例14: toString

import java.util.Enumeration; //导入方法依赖的package包/类
/** Print out the grammar without actions */
public String toString() {
    StringBuffer buf = new StringBuffer(20000);
    Enumeration ids = rules.elements();
    while (ids.hasMoreElements()) {
        RuleSymbol rs = (RuleSymbol)ids.nextElement();
        if (!rs.id.equals("mnextToken")) {
            buf.append(rs.getBlock().toString());
            buf.append("\n\n");
        }
    }
    return buf.toString();
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:14,代码来源:Grammar.java

示例15: assertContains

import java.util.Enumeration; //导入方法依赖的package包/类
private void assertContains( String comment, String string, Enumeration headerNames ) {
    while (headerNames != null && headerNames.hasMoreElements()) {
        String name = (String) headerNames.nextElement();
        if (name.equalsIgnoreCase( string )) return;
    }
    fail( comment + " does not contain " + string );
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:8,代码来源:HttpServletRequestTest.java


注:本文中的java.util.Enumeration.hasMoreElements方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。