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:PrintDescendants.java

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

From source file:Main.java

public static void setUIFont(FontUIResource f) {
    ////from   w ww .ja  v a 2  s  . co  m
    // sets the default FONT for all Swing components.
    // ex.
    // setUIFont (new javax.swing.plaf.FontUIResource
    // ("Serif",Font.ITALIC,12));
    //
    Enumeration<Object> keys = UIManager.getDefaults().keys();
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        Object value = UIManager.get(key);
        if (value instanceof FontUIResource)
            UIManager.put(key, f);
    }
}

From source file:Main.java

public static <T> List<T> asList(Enumeration<T> e) {
    List<T> l = new LinkedList<T>();

    while (e.hasMoreElements()) {
        l.add(e.nextElement());
    }//  ww w. j  a  v  a2s.  c o  m

    return l;
}

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 {/*from  w  ww. ja  v  a 2 s .  co 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

public static void setUIFont(Font f) {
    ///* ww  w  . j  ava 2  s  .co  m*/
    // sets the default font for all Swing components.
    // ex. 
    //  setUIFont (new javax.swing.plaf.FontUIResource("Serif",Font.ITALIC,12));
    //
    FontUIResource fur = new FontUIResource(f);
    java.util.Enumeration keys = UIManager.getDefaults().keys();
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        Object value = UIManager.get(key);
        if (value instanceof javax.swing.plaf.FontUIResource)
            UIManager.put(key, fur);
    }
}

From source file:Main.java

public static void mergePropertiesIntoMap(Properties props, Map map) {
    if (map == null) {
        throw new IllegalArgumentException("Map must not be null");
    } else {//w  ww. j a va 2s.com
        if (props != null) {
            Enumeration en = props.propertyNames();

            while (en.hasMoreElements()) {
                String key = (String) en.nextElement();
                map.put(key, props.getProperty(key));
            }
        }

    }
}

From source file:Main.java

public static <T> List<T> read(Enumeration<T> e) {
    List<T> list = new ArrayList<>();
    while (e.hasMoreElements()) {
        list.add(e.nextElement());
    }//ww w  . j  a v  a  2s .  c om
    return list;
}

From source file:Main.java

/**
 * Iterates over the given Enumeration <code>e</code> and adds all elements to the given Collection <code>collInOut</code>.
 * @return the same collection that has been passed as collInOut
 *///  w w w  .ja  v a  2  s  . c om
public static <E, C extends Collection<E>> C addAll(C collInOut, Enumeration<? extends E> e) {
    while (e.hasMoreElements()) {
        collInOut.add(e.nextElement());
    }
    return collInOut;
}

From source file:Main.java

static Hashtable hashtableClone(Hashtable ht1, Hashtable ht2) {
    if (ht1 == null && ht2 == null)
        return null;

    Hashtable htresp = new Hashtable();

    if (ht1 != null) {
        Enumeration e = ht1.keys();
        while (e.hasMoreElements()) {
            Object element = e.nextElement();
            htresp.put(element, ht1.get(element));
        }//from  www.j a va2  s .  c o  m
    }
    if (ht2 != null) {
        Enumeration e = ht2.keys();
        while (e.hasMoreElements()) {
            Object element = e.nextElement();
            htresp.put(element, ht2.get(element));
        }
    }
    return htresp;
}

From source file:Main.java

public static void writeToWriter(Enumeration enumList, Writer out) throws IOException {
    while (enumList.hasMoreElements()) {
        out.write(enumList.nextElement().toString());
        out.write(newLine);//ww w. ja  v  a2s  .  c o  m
    }
    out.flush();
}