List of usage examples for java.util Vector Vector
public Vector()
From source file:Main.java
/** * Get child elements by classname//w w w. j ava 2 s . c o m * * @param ele parent element * @param cname of elements to find */ public static List<Element> getElementsByClass(Element ele, String cname) { Vector<Element> list = new Vector(); NodeList nl = ele.getChildNodes(); for (int j = 0; j < nl.getLength(); j++) { if (nl.item(j).getNodeType() != Node.ELEMENT_NODE) continue; Element e = (Element) nl.item(j); if (e.getAttribute("class").equals(cname)) list.add(e); } return (list); }
From source file:MainClass.java
MainClass(String title) { super(title); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Vector v = new Vector(); v.add("A");/*from ww w . j a v a2 s. com*/ v.add("B"); v.add("C"); JComboBox jcb = new JComboBox(v); getContentPane().add(jcb); setSize(200, 50); setVisible(true); }
From source file:Main.java
/** * Given any of the known collection types, this method will return an instance of the collection. * @param collectionType the type of the collection * @return the collection instance/*from w ww .j a v a 2 s. co m*/ */ public static Collection<?> getCollection(Class<?> collectionType) { if (HashSet.class.equals(collectionType)) { return new HashSet<Object>(); } else if (TreeSet.class.equals(collectionType)) { return new TreeSet<Object>(); } else if (CopyOnWriteArraySet.class.equals(collectionType)) { return new CopyOnWriteArraySet<Object>(); } else if (LinkedHashSet.class.equals(collectionType)) { return new LinkedHashSet<Object>(); } else if (ArrayList.class.equals(collectionType)) { return new ArrayList<Object>(); } else if (LinkedList.class.equals(collectionType)) { return new LinkedList<Object>(); } else if (Vector.class.equals(collectionType)) { return new Vector<Object>(); } else if (Stack.class.equals(collectionType)) { return new Stack<Object>(); } else if (PriorityQueue.class.equals(collectionType)) { return new PriorityQueue<Object>(); } else if (PriorityBlockingQueue.class.equals(collectionType)) { return new PriorityBlockingQueue<Object>(); } else if (ArrayDeque.class.equals(collectionType)) { return new ArrayDeque<Object>(); } else if (ConcurrentLinkedQueue.class.equals(collectionType)) { return new ConcurrentLinkedQueue<Object>(); } else if (LinkedBlockingQueue.class.equals(collectionType)) { return new LinkedBlockingQueue<Object>(); } else if (LinkedBlockingDeque.class.equals(collectionType)) { return new LinkedBlockingDeque<Object>(); } else if (List.class.equals(collectionType)) { return new LinkedList<Object>(); } else if (Set.class.equals(collectionType)) { return new HashSet<Object>(); } else if (Queue.class.equals(collectionType)) { return new PriorityQueue<Object>(); } else if (Deque.class.equals(collectionType)) { return new ArrayDeque<Object>(); } else if (Collection.class.equals(collectionType)) { return new LinkedList<Object>(); } throw new IllegalArgumentException("Unsupported collection type: " + collectionType); }
From source file:Main.java
public static Vector<String> getSets(String setString) { StringTokenizer tokenizer = new StringTokenizer(setString, ";"); Vector<String> sets = new Vector<String>(); while (tokenizer.hasMoreTokens()) { sets.add(tokenizer.nextToken()); }//www . ja v a 2 s .co m if (sets.size() == 0) sets.add(""); return sets; }
From source file:Main.java
/** * Returns an array containing the element objects in the provided node list. * // ww w. j av a 2 s. com * @param nodeList The DOM node objects to extract elements from. * @return The array of DOM elements found in the node list. */ @SuppressWarnings("unchecked") public static Element[] getElementsOfNodeList(NodeList nodeList) { Element[] ret = null; @SuppressWarnings("rawtypes") Vector v = new Vector(); for (int n = 0; n < nodeList.getLength(); n++) { Node item = nodeList.item(n); if (item.getNodeType() == Node.ELEMENT_NODE) { v.addElement(item); } } ret = new Element[v.size()]; for (int n = 0; n < ret.length; n++) { ret[n] = (Element) v.elementAt(n); } return ret; }
From source file:Main.java
public static Hashtable<Integer, Vector<Integer>> getNodeMembership(final Vector<Vector<Integer>> CmtyVV) { Hashtable<Integer, Vector<Integer>> NIDComVH = new Hashtable<Integer, Vector<Integer>>(); for (int CID = 0; CID < CmtyVV.size(); CID++) { for (Integer NID : CmtyVV.get(CID)) { if (!NIDComVH.contains(NID)) { Vector<Integer> v = new Vector<Integer>(); v.add(CID);//from www . j a v a 2 s . c o m NIDComVH.put(NID, v); } else { Vector<Integer> v = NIDComVH.get(NID); v.add(CID); NIDComVH.put(NID, v); } } } return NIDComVH; }
From source file:JavaSort.java
public JavaSort() { Vector list = new Vector(); list.add("\u00e4pple"); list.add("banan"); list.add("p\u00e4ron"); list.add("orange"); // Obtain a Swedish collator Collator collate = Collator.getInstance(new Locale("sv", "")); Collections.sort(list, collate); StringBuffer result = new StringBuffer(); for (int i = 0; i < list.size(); i++) { result.append(list.elementAt(i)); result.append(" "); }/* w ww. j a v a 2 s .co m*/ add(new JLabel(result.toString())); }
From source file:Main.java
/** Return a list of all the children of a given node *//*from ww w. ja v a 2s . c o m*/ static public Vector<Node> findAllChildren(Node node) { if (node == null) return null; Vector<Node> found_children = new Vector<Node>(); NodeList children = node.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) found_children.add(child); } return found_children; }
From source file:Main.java
/** * Searches parent node for matching child nodes and collects and returns * their matching attribute String values. * * @param node The parent node// w w w . j a va 2 s. c om * @param elemName The matching child node element name * @param attr The matching child node attribute name * @return List of attribute values */ public static Enumeration getChildrenAttributeValues(Node node, String elemName, String attr) { Vector vect = new Vector(); NodeList nl = node.getChildNodes(); int n = nl.getLength(); for (int i = 0; i < n; i++) { Node nd = nl.item(i); if (nd.getNodeName().equals(elemName)) { vect.add(getAttribute(nd, attr)); } } return vect.elements(); }
From source file:Main.java
/** * Retrieves the given DOM element's child elements with the specified name. * If name is null, all children are retrieved. *///from w ww . j ava 2s. c o m public static Element[] getChildren(final Element el, final String name) { final Vector v = new Vector(); final NodeList nodes = el.getChildNodes(); final int len = nodes.getLength(); for (int i = 0; i < len; i++) { final Node node = nodes.item(i); if (!(node instanceof Element)) continue; final Element e = (Element) node; if (name == null || e.getTagName().equals(name)) v.add(e); } final Element[] els = new Element[v.size()]; v.copyInto(els); return els; }