Example usage for java.util Enumeration nextElement

List of usage examples for java.util Enumeration nextElement

Introduction

In this page you can find the example usage for java.util Enumeration nextElement.

Prototype

E nextElement();

Source Link

Document

Returns the next element of this enumeration if this enumeration object has at least one more element to provide.

Usage

From source file:mojo.view.util.DebugUtils.java

@SuppressWarnings("rawtypes")
public static void logRequestHeaders(HttpServletRequest req) {
    logger.debug("REQUEST HEADERS");
    logger.debug("---------------");

    Enumeration enums = req.getHeaderNames();

    while (enums.hasMoreElements()) {
        String headerName = (String) enums.nextElement();
        String headerValue = req.getHeader(headerName);
        logger.debug(headerName + ": " + headerValue);
    }//from  w  w  w  .ja va  2 s  .com

    logger.debug("");
}

From source file:com.common.utils.NetworkUtils.java

public static String getLocalHostIp() {
    String ips = "";//getString(R.string.ipaddr);
    try {/*  w  ww  . j a  v  a2s.co  m*/
        Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces();

        while (en.hasMoreElements()) {
            NetworkInterface nif = en.nextElement();
            Enumeration<InetAddress> inet = nif.getInetAddresses();

            while (inet.hasMoreElements()) {
                InetAddress ip = inet.nextElement();
                if (!ip.isLoopbackAddress() && InetAddressUtils.isIPv4Address(ip.getHostAddress())) {

                    ips = ips + nif.getName() + ":" + ip.getHostAddress() + "  ";

                }
            }

        }
    } catch (SocketException e) {
        e.printStackTrace();
    }
    return ips;

}

From source file:py.una.pol.karaku.test.test.ValidationMessagesTest.java

@BeforeClass
public static void before() {

    Locale locale = new Locale("es", "PY");
    ResourceBundle toAdd = ResourceBundle.getBundle("language.validation.karaku", locale);
    Enumeration<String> en = toAdd.getKeys();
    keys = new HashSet<String>();
    while (en.hasMoreElements()) {

        keys.add("{" + en.nextElement() + "}");

    }/*from  ww w. jav a 2 s .c  o m*/

}

From source file:Main.java

public static void expandTree(JTree tree) {
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) tree.getModel().getRoot();
    @SuppressWarnings("unchecked")
    Enumeration<DefaultMutableTreeNode> e = root.breadthFirstEnumeration();
    while (e.hasMoreElements()) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement();
        if (node.isLeaf())
            continue;
        int row = tree.getRowForPath(new TreePath(node.getPath()));
        tree.expandRow(row);/*w  ww.j  a v a2s  .com*/
    }
}

From source file:LocalAddress.java

/**
 * Return an address of a non-loopback interface on the local host
 * /*from w  ww.j  a v a2s  . co m*/
 * @return address
 *         the InetAddress of the local host
 */
public static InetAddress getLocalAddress() {
    InetAddress addr = null;
    try {
        addr = InetAddress.getLocalHost();
        // OK - is this the loopback addr ?
        if (!addr.isLoopbackAddress()) {
            return addr;
        }
        // plan B - enumerate the network interfaces
        Enumeration ifaces = NetworkInterface.getNetworkInterfaces();
        while (ifaces.hasMoreElements()) {
            NetworkInterface netIf = (NetworkInterface) ifaces.nextElement();
            Enumeration addrs = netIf.getInetAddresses();
            while (addrs.hasMoreElements()) {
                addr = (InetAddress) addrs.nextElement();
                //System.out.println( "enum: " + addr.getHostAddress() );
                if (addr instanceof Inet6Address) {
                    // probably not what we want - keep looking
                    continue;
                }
                // chose (arbitrarily?) first non-loopback addr
                if (!addr.isLoopbackAddress()) {
                    return addr;
                }
            }
        }
        // nothing so far - last resort
        return getReflectedAddress();
    } catch (UnknownHostException uhE) {
        // deal with this
    } catch (SocketException sockE) {
        // can deal?
    }

    return null;
}

From source file:mojo.view.util.DebugUtils.java

@SuppressWarnings("rawtypes")
public static void logRequestAttributes(HttpServletRequest req) {
    logger.debug("REQUEST ATTRIBUTES");
    logger.debug("------------------");

    Enumeration enums = req.getAttributeNames();

    while (enums.hasMoreElements()) {
        String attrName = (String) enums.nextElement();
        Object attrValue = req.getAttribute(attrName);
        StringBuilder sb = new StringBuilder();
        sb.append(attrName + ": " + attrValue);
        logger.debug(sb.toString());//from   w  w  w .  j  av  a  2s  . c o m
    }

    logger.debug("");
}

From source file:mojo.view.util.DebugUtils.java

@SuppressWarnings("rawtypes")
public static void logRequestParameters(HttpServletRequest req) {
    logger.debug("REQUEST PARAMETERS");
    logger.debug("------------------");

    Enumeration enums = req.getParameterNames();

    while (enums.hasMoreElements()) {
        String paramName = (String) enums.nextElement();
        String[] paramValues = req.getParameterValues(paramName);
        StringBuilder sb = new StringBuilder();
        sb.append(paramName).append(": " + paramValues);
        logger.debug(sb.toString());/*from w  w  w .  j  a  v a  2 s .  com*/
    }

    logger.debug("");
}

From source file:com.nary.util.LogFileObject.java

public static void closeAll() {
    Enumeration E = logfiles.elements();
    while (E.hasMoreElements())
        ((LogFileObject) E.nextElement()).close();
}

From source file:com.juhuasuan.osprey.LoggerInit.java

@SuppressWarnings("unchecked")
static FileAppender searchFileAP(Enumeration<Appender> ppp) {
    FileAppender fp = null;//w w  w.j a  va 2  s  . co  m

    while (null == fp && ppp.hasMoreElements()) {
        Appender ap = ppp.nextElement();
        if (ap instanceof FileAppender) {
            fp = (FileAppender) ap;
        } else if (ap instanceof AsyncAppender) {
            ppp = ((AsyncAppender) ap).getAllAppenders();
            fp = searchFileAP(ppp);
        }
    }
    return fp;
}

From source file:com.skcraft.launcher.builder.BuilderUtils.java

public static ZipEntry getZipEntry(ZipFile jarFile, String path) {
    Enumeration<? extends ZipEntry> entries = jarFile.entries();
    String expected = normalizePath(path);

    while (entries.hasMoreElements()) {
        ZipEntry entry = entries.nextElement();
        String test = normalizePath(entry.getName());
        if (expected.equals(test)) {
            return entry;
        }//from   w  w  w  .j  ava2  s . c om
    }

    return null;
}