List of usage examples for java.util Enumeration nextElement
E nextElement();
From source file:Main.java
public static <T> List<T> list(Enumeration<? extends T> enumeration) { List<T> list = new ArrayList<T>(); while (enumeration.hasMoreElements()) { list.add(enumeration.nextElement()); }/*from ww w .j a v a2 s. c o m*/ return list; }
From source file:Main.java
public static <A, E extends A> A[] toArray(Enumeration<E> enumeration, A[] array) { ArrayList<A> elements = new ArrayList<A>(); while (enumeration.hasMoreElements()) elements.add(enumeration.nextElement()); return elements.toArray(array); }
From source file:Main.java
/** Fully expands the given JTree from the specified node. */ public static void expandTree(final JTree tree, final DefaultMutableTreeNode node) { if (node.isLeaf()) return;// ww w. j a v a 2 s . c om tree.expandPath(new TreePath(node.getPath())); final Enumeration e = node.children(); while (e.hasMoreElements()) { expandTree(tree, (DefaultMutableTreeNode) e.nextElement()); } }
From source file:Main.java
/** * Adds all elements in the enumeration to the given collection. * @deprecated Replaced by {@link Collection#addAll(java.util.Collection<? extends E>)} * * @param collection the collection to add to * @param enumeration the enumeration of elements to add, may not be null * @throws NullPointerException if the collection or enumeration is null */// ww w. j a v a2 s . c o m public static <E> void addAll(Collection<E> collection, Enumeration<? extends E> enumeration) { while (enumeration.hasMoreElements()) { collection.add(enumeration.nextElement()); } }
From source file:Main.java
/** * Returns string keys in a hashtable as delimited string * * @param ht//w w w . ja v a2 s . c o m * , Hashtable * @param delimiter * , String * @param exclude * , exclude channel if present as substring * @return , string array with hash keys string */ public static synchronized String hashTableKeysToDelimitedString(Hashtable ht, String delimiter, String exclude) { StringBuffer sb = new StringBuffer(); boolean first = true; Enumeration e = ht.keys(); while (e.hasMoreElements()) { String s = (String) e.nextElement(); if (exclude != null) { if (s.indexOf(exclude) != -1) { continue; } } if (first) { sb.append(s); first = false; } else { sb.append(delimiter).append(s); } } return sb.toString(); }
From source file:Main.java
public static <A, E extends A> A[] toArray(Enumeration<E> enumeration, A[] array) { ArrayList elements = new ArrayList(); while (enumeration.hasMoreElements()) { elements.add(enumeration.nextElement()); }/*w ww . jav a 2s .c o m*/ return (A[]) elements.toArray(array); }
From source file:com.redhat.victims.util.VictimsConfig.java
/** * return all victim configuration properties * * @return property map/*from www. ja v a 2 s . c o m*/ */ public static Map<String, String> getProperties() { Map<String, String> propMap = new HashMap<String, String>(); Enumeration<String> keys = props.getKeys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); propMap.put(key, props.getString(key)); } return propMap; }
From source file:Main.java
/** * Converts the elements found in the given Enumeration into a list. *//* w ww .ja va2 s . c o m*/ public static <T> List<T> asList(Enumeration<T> enu) { List<T> list = new ArrayList<T>(); while (enu != null && enu.hasMoreElements()) { list.add(enu.nextElement()); } return list; }
From source file:Main.java
public static Collection toCollection(Enumeration _enum, Collection c) { if (c == null) c = new ArrayList(); while (_enum.hasMoreElements()) c.add(_enum.nextElement()); return c;//from ww w .jav a 2 s . c om }
From source file:BoxSample.java
private static void tweak(Vector buttons) { // calc max preferred width JButton button;//from w ww . j a v a 2 s. co m Dimension dim; int maxWidth = 0; Enumeration e = buttons.elements(); while (e.hasMoreElements()) { button = (JButton) e.nextElement(); dim = button.getPreferredSize(); if (dim.width > maxWidth) maxWidth = dim.width; } // set max preferred width e = buttons.elements(); while (e.hasMoreElements()) { button = (JButton) e.nextElement(); dim = button.getPreferredSize(); dim.width = maxWidth; button.setPreferredSize(dim); } }