List of usage examples for java.util Vector size
public synchronized int size()
From source file:Main.java
/** * @param el/*from www.j a va 2 s.c om*/ * @return the number of element and attribute nodes in an XML tree */ public static int nodeCount(Element el) { int count = 1 + el.getAttributes().getLength(); // this node and its attributes // contributions from child elements Vector<Element> childElements = childElements(el); for (int i = 0; i < childElements.size(); i++) count = count + nodeCount(childElements.get(i)); return count; }
From source file:Main.java
public static String getFieldName(Vector vtNameStack) { StringBuffer strFieldName = new StringBuffer(); for (int iIndex = 0; iIndex < vtNameStack.size(); iIndex++) { strFieldName.append('.'); strFieldName.append((String) vtNameStack.elementAt(iIndex)); }/* w ww . ja v a 2 s . c om*/ if (strFieldName.length() > 0) strFieldName.delete(0, 1); return strFieldName.toString(); }
From source file:Main.java
/** * /*from www . j ava2 s. c om*/ * @param el * @return depth of an XML node tree */ public static int getDepth(Element el) { int depth = 1; if (el.getAttributes().getLength() > 0) depth = 2; int max = 0; Vector<Element> childElements = childElements(el); for (int i = 0; i < childElements.size(); i++) { int childDepth = getDepth(childElements.get(i)); if (childDepth > max) max = childDepth; } return depth + max; }
From source file:Main.java
public static void copyIntoVector(Vector paramVector1, int paramInt, Vector paramVector2) { int i = paramInt; try {/*from ww w . j a va2s. c o m*/ while (i < paramVector1.size()) { paramVector2.insertElementAt(paramVector1.elementAt(i), i - paramInt); i++; } return; } finally { } }
From source file:Main.java
public static Vector appendInto(Vector v, Object[] array, int quantity) { v.ensureCapacity(v.size() + quantity); for (int i = 0; i < quantity; i++) { v.addElement(array[i]);/* w ww .ja v a 2 s.co m*/ } return v; }
From source file:Main.java
/** * @param el//from w ww . jav a2 s . co m * @return the number of element and attribute nodes in an XML tree */ public static int nodeValueCount(Element el) { int count = el.getAttributes().getLength(); // attributes of this node // text value of this node String text = getText(el); if ((text != null) && (!text.equals(""))) count++; // contributions from child elements Vector<Element> childElements = childElements(el); for (int i = 0; i < childElements.size(); i++) count = count + nodeValueCount(childElements.get(i)); return count; }
From source file:Main.java
static public Element[] findAllDescendantElements(Node e, String qname) { Vector v = new Vector(); findAllDescendantElements(e, qname, v); Element array[] = new Element[v.size()]; for (int i = 0; i < array.length; ++i) { array[i] = (Element) v.elementAt(i); }/* www. j a v a2 s . c o m*/ return array; }
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()); }//from www . java 2 s. c om if (sets.size() == 0) sets.add(""); return sets; }
From source file:TreeViewBasedOnNode.java
private static void addNode(TreeItem parentItem, Node node) { TreeItem item = null;/*from ww w . j a v a2s. c om*/ if (parentItem == null) item = new TreeItem(tree, SWT.NONE); else item = new TreeItem(parentItem, SWT.NONE); item.setText(node.getName()); Vector subs = node.getSubCategories(); for (int i = 0; subs != null && i < subs.size(); i++) addNode(item, (Node) subs.elementAt(i)); }
From source file:Main.java
public static synchronized Node[] getChildNodes(Node node) { if (node == null) { return null; }/* w w w. j a v a 2 s . c om*/ Vector childs = new Vector(); for (Node n = node.getFirstChild(); n != null; n = n.getNextSibling()) { childs.add((Element) n); } Node[] childNodes = new Element[childs.size()]; childs.toArray(childNodes); return childNodes; }