Example usage for java.util Enumeration hasMoreElements

List of usage examples for java.util Enumeration hasMoreElements

Introduction

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

Prototype

boolean hasMoreElements();

Source Link

Document

Tests if this enumeration contains more elements.

Usage

From source file:Main.java

/**
 * For testing only - prevent the tests to exit until all thread finished
 *//*  w ww.  jav a2 s  .co  m*/
public static void waitForBackgroundThreads() {
    Enumeration e = threads.elements();
    while (e.hasMoreElements()) {
        Thread thread = (Thread) e.nextElement();
        if (thread.isAlive()) {
            try {
                thread.join();
            } catch (InterruptedException ignore) {
                ignore.printStackTrace();
            }
        }
    }
}

From source file:Main.java

public static <T> void addAll(Collection<T> c, Enumeration<T> enumeration) {
    while (enumeration.hasMoreElements()) {
        c.add(enumeration.nextElement());
    }//from w  ww . ja  v  a  2s .co m
}

From source file:PrintDescendants.java

public static void printDescendants(TreeNode root) {
    System.out.println(root);/*from   w w  w. j av  a2  s  .  c om*/
    Enumeration children = root.children();
    if (children != null) {
        while (children.hasMoreElements()) {
            printDescendants((TreeNode) children.nextElement());
        }
    }
}

From source file:Main.java

public static Vector tail(Vector v) {
    Vector result = new Vector();
    Enumeration e = v.elements();
    e.nextElement();//from   www.ja  va  2 s.com
    while (e.hasMoreElements())
        result.addElement(e.nextElement());

    return result;
}

From source file:Main.java

/**
 * Returns string keys in a hashtable as array of string
 *
 * @param ht/*from  ww w. j a  v  a 2s  .  c  om*/
 *            , Hashtable
 * @return , string array with hash keys string
 */
public static synchronized String[] hashtableKeysToArray(Hashtable ht) {
    Vector v = new Vector();
    String[] sa = null;
    int count = 0;

    Enumeration e = ht.keys();
    while (e.hasMoreElements()) {
        String s = (String) e.nextElement();
        v.addElement(s);
        count++;
    }

    sa = new String[count];
    v.copyInto(sa);
    return sa;

}

From source file:Main.java

public static void setLookAndFeel(int fontSize) throws Exception {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    UIDefaults defaults = UIManager.getDefaults();
    Enumeration<Object> keys = defaults.keys();
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();

        if ((key instanceof String) && (((String) key).endsWith(".font"))) {
            FontUIResource font = (FontUIResource) UIManager.get(key);
            defaults.put(key, new FontUIResource(font.getFontName(), font.getStyle(), fontSize));
        }// w  ww . jav  a2  s  .co  m
    }
}

From source file:Main.java

public static Properties convertResourceBundleToProperties(ResourceBundle resource) {
    Properties properties = new Properties();

    Enumeration<String> keys = resource.getKeys();
    while (keys.hasMoreElements()) {
        String key = keys.nextElement();
        properties.put(key, resource.getString(key));
        //System.out.println("key: '" + key + "' value: '" + properties.get(key) + "'");
    }//www  .  j av  a 2 s. c o m

    return properties;
}

From source file:com.espertech.esperio.regression.adapter.SupportJMSReceiver.java

public static void print(Message msg) throws JMSException {
    log.info(".print received message: " + msg.getJMSMessageID());
    if (msg instanceof ObjectMessage) {
        ObjectMessage objMsg = (ObjectMessage) msg;
        log.info(".print object: " + objMsg.getObject().toString());
    } else {//  ww w .  j a va2  s  .  c  o  m
        MapMessage mapMsg = (MapMessage) msg;
        HashMap map = new HashMap();
        Enumeration en = mapMsg.getMapNames();
        while (en.hasMoreElements()) {
            String property = (String) en.nextElement();
            Object mapObject = mapMsg.getObject(property);
            map.put(property, mapObject);
        }
        log.info(".print map: " + map);
    }
}

From source file:Main.java

/**
 * Code from http://stackoverflow.com/questions/1236231/managing-swing-ui-default-font-sizes-without-quaqua
 * @param fontSize/*w w  w  .j  a v a  2  s.c om*/
 */
public static void changeDefaultFontSize(int fontSize) {
    UIDefaults defaults = UIManager.getDefaults();
    // UIDefaults defaults = UIManager.getLookAndFeelDefaults();
    Enumeration<Object> keys = defaults.keys();
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        if ((key instanceof String) && (((String) key).endsWith(".font"))) {
            FontUIResource font = (FontUIResource) UIManager.get(key);
            defaults.put(key, new FontUIResource(font.getFontName(), font.getStyle(), fontSize));
        }
    }
}

From source file:Main.java

public static final List<String> getListFromBundle(ResourceBundle rb, String prefix) {
    String name = null;/* www .j  ava  2 s .  c o m*/
    List<String> ret = new LinkedList<String>();
    Enumeration<String> names = rb.getKeys();
    while (names.hasMoreElements()) {
        name = names.nextElement();
        if (name != null && name.startsWith(prefix) && isInteger(name.substring(name.length() - 1))) {
            ret.add(rb.getString(name));
        }
    }
    Collections.sort(ret);
    return ret;
}