List of usage examples for java.util Vector addElement
public synchronized void addElement(E obj)
From source file:Main.java
/** * Returns string keys in a hashtable as array of string * * @param ht//from w ww.j av a 2 s . c o m * , 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 String[] getElementPath(Node node) { Vector vector = new Vector(); for (; node != null; node = node.getParentNode()) if (node.getNodeType() == 1) if (!hasSameNamedSibling(node)) vector.addElement(node.getNodeName()); else/*from w w w. ja va 2 s . c o m*/ vector.addElement(node.getNodeName() + "[" + (getElementIndex(node) + 1) + "]"); int i = vector.size(); String as[] = new String[i]; int j = i - 1; for (int k = 0; k < i;) { as[k] = (String) vector.elementAt(j); k++; j--; } return as; }
From source file:Main.java
static public Element[] findChildElements(Node first, Node last, String name) { Vector v = new Vector(); while (first != last) { if (first.getNodeType() == Node.ELEMENT_NODE) { if (first.getNodeName().equals(name)) v.addElement(first); }/*from ww w. j a v a2 s . c o m*/ first = first.getNextSibling(); } Element array[] = new Element[v.size()]; for (int i = 0; i < array.length; ++i) { array[i] = (Element) v.elementAt(i); } return array; }
From source file:Main.java
public static Vector<Element> getChildList(Element elem, String elementName) { if (elem == null) return null; NodeList nl = elem.getChildNodes(); if (nl == null) return null; Vector<Element> retlist = new Vector<Element>(100); for (int n = 0; n < nl.getLength(); n++) { Element element = (Element) nl.item(n); if (elementName.equals(element.getTagName())) { retlist.addElement(element); }/*from w w w.j a v a 2s . c o m*/ } if (retlist.size() == 0) return null; return retlist; }
From source file:Main.java
/** * @param context/*from w w w.j a v a 2 s . c o m*/ * this method is used for retrieving email accounts of device * @return */ public static String[] getAccount(Context context) { final AccountManager accountManager = AccountManager.get(context); final Account[] accounts = accountManager.getAccounts(); final Vector<String> accountVector = new Vector<String>(); for (int i = 0; i < accounts.length; i++) { if (!accountVector.contains(accounts[i].name) && isValidEmail(accounts[i].name)) { accountVector.addElement(accounts[i].name); } } final String accountArray[] = new String[accountVector.size()]; return accountVector.toArray(accountArray); }
From source file:Main.java
/** * return the Vector of child Elements with given local name * @param el//w w w. j a v a 2 s. c om * @param name * @return */ public static Vector<Element> namedChildElements(Element el, String lName) { Vector<Element> nc = new Vector<Element>(); for (Iterator<Element> it = childElements(el).iterator(); it.hasNext();) { Element en = it.next(); if (getLocalName(en).equals(lName)) nc.addElement(en); } return nc; }
From source file:Main.java
/** * Returns an array containing the element objects in the provided node list. * //from w w w . ja v a 2 s . co m * @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 Collection and(Collection collection1, Collection collection2) { Vector completeList = new Vector(); if (collection2 == null) return completeList; Iterator i = collection2.iterator(); while (i.hasNext()) { Object addlItem = i.next(); if (collection1.contains(addlItem) == true) { completeList.addElement(addlItem); }/*w w w. jav a2s . c om*/ } return completeList; }
From source file:Main.java
/** * * @param vtData Vector/*from www . j ava2 s .co m*/ * @param iComboIndex int * @param iVectorIndex int * @param cbo JComboBox * @param vt Vector * @param bClear boolean * @param bHaveNull boolean * @throws Exception */ public static void fillValue(Vector vtData, int iComboIndex, int iVectorIndex, JComboBox cbo, Vector vt, boolean bClear, boolean bHaveNull) throws Exception { // Clear if (bClear) { vt.clear(); cbo.removeAllItems(); } // Add null value if (bHaveNull) { vt.addElement(""); cbo.addItem(""); } // Fill value for (int iRowIndex = 0; iRowIndex < vtData.size(); iRowIndex++) { Vector vtResultRow = (Vector) vtData.elementAt(iRowIndex); vt.addElement(vtResultRow.elementAt(iVectorIndex)); cbo.addItem(vtResultRow.elementAt(iComboIndex)); } }
From source file:Main.java
/** * Extracts attribute names from tag string. * /*from w w w . java2s. c om*/ * @param tag * whole tag name * @return A vector with all attribute names * @deprecated use TagClass.getAttrList() instead */ public static Vector getAttributeNames(String tag) { Vector names = new Vector(); int start = tag.indexOf(' '); /* avoid name of this tag */ int end; while (start != -1) { end = tag.indexOf('=', start + 1); if (end == -1) { break; } names.addElement(tag.substring(start + 1, end)); start = tag.indexOf('"', end + 1); if (start == -1) { break; } start = tag.indexOf('"', start + 1); if (start == -1) { break; } start = tag.indexOf(' ', start + 1); } return names; }