List of usage examples for java.util Vector size
public synchronized int size()
From source file:FileUtil.java
public static boolean areVectorsEqual(Vector a, Vector b) { if (a.size() != b.size()) { return false; }//from w w w . jav a2s .com int i = 0; int vectorSize = a.size(); boolean identical = true; for (i = 0; i < vectorSize; i++) { if (!(a.elementAt(i).toString().equalsIgnoreCase(b.elementAt(i).toString()))) { identical = false; } } return identical; }
From source file:Main.java
/** * Method getDropDownOptions./* w w w . j a va 2s. co m*/ * * @param vector Vector * @param valueGetter String * @param textGetter String * @param selectedValues Vector * @return String * @throws NoSuchMethodException * @throws IllegalAccessException * @throws InvocationTargetException */ public static String getDropDownOptions(Vector vector, String valueGetter, String textGetter, Vector selectedValues) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { Hashtable selectedValuesHashtable = new Hashtable(selectedValues.size()); for (int i = 0; i < selectedValues.size(); i++) { selectedValuesHashtable.put(selectedValues.elementAt(i).toString(), ""); } StringBuffer dropDownOptions = new StringBuffer(""); String optionValue = null; String optionText = null; Class[] clsParms = new Class[0]; Object[] objParms = new Object[0]; Method getterMethod = null; Object vectorElement = null; for (int i = 0; i < vector.size(); i++) { vectorElement = vector.elementAt(i); getterMethod = vectorElement.getClass().getMethod(valueGetter, clsParms); optionValue = getterMethod.invoke(vectorElement, objParms).toString(); getterMethod = vectorElement.getClass().getMethod(textGetter, clsParms); optionText = getterMethod.invoke(vectorElement, objParms).toString(); dropDownOptions.append("<option value=\"" + optionValue + "\""); if (selectedValuesHashtable.containsKey(optionValue)) { dropDownOptions.append(" selected"); } dropDownOptions.append(">" + optionText); } return dropDownOptions.toString(); }
From source file:Main.java
public static synchronized String[] getElementValues(Element element) { if (element == null) { return null; }//from w ww. j ava 2 s . c o m Vector childs = new Vector(); for (Node node = element.getFirstChild(); node != null; node = node.getNextSibling()) { if (node instanceof Text) { childs.add(node.getNodeValue()); } } String[] values = new String[childs.size()]; childs.toArray(values); return values; }
From source file:Main.java
/** * Method sortVector./*from w w w . ja v a 2 s . c o m*/ * @param vector Vector * @param getter String * @param sortDirection int * @param caseSensitiveSort boolean * @throws Exception */ public static void sortVector(Vector vector, String getter, int sortDirection, boolean caseSensitiveSort) throws Exception { if (vector.size() > 1) { sortVectorRecursive(vector, getter, 0, vector.size() - 1, sortDirection, caseSensitiveSort); } }
From source file:ManagerQuery.java
/*************************************************************************** * Format the Vector of Strings returned by the get*List() methods into a * single String. A simple formatting method. **************************************************************************/ public static String formatVectorStrings(Vector vec, String leading, int count, String separator) { String str = leading;//from w w w . ja va2 s. c o m for (int i = 0; i < vec.size(); i++) { str = str + (String) vec.elementAt(i); if ((i + 1) == vec.size()) str = str + "\n"; else if ((i + 1) % count == 0) str = str + "\n" + leading; else str = str + separator; } return str; }
From source file:Main.java
private static String[] filter(String[] p_array, boolean p_includeComments) { String[] result = p_array;//from w ww . j a v a 2s. co m if (!p_includeComments) { Vector v = new Vector(); for (int i = 0; i < p_array.length; i++) { String s = p_array[i]; if (s.indexOf("<!--") < 0) { v.addElement(s); } } result = new String[v.size()]; for (int i = 0; i < v.size(); i++) { result[i] = (String) v.elementAt(i); } } return result; }
From source file:org.objectweb.proactive.extensions.timitspmd.util.charts.HierarchicalBarChart.java
@SuppressWarnings("unchecked") private static Comparable[] toSeries(Vector<Counter> counter) { Comparable[] result = new Comparable[counter.size()]; for (int i = 0; i < counter.size(); i++) { result[i] = ((Counter) counter.get(i)).getName(); }//w w w . j a v a 2s. co m return result; }
From source file:lambertmrev.conversions.java
public static CartesianOrbit hyp2ele(double[] hyp, Vector<Tracklet> subSet, constraints set, TopocentricFrame staF, Frame inertialFrame, TimeScale utc) { int N = subSet.size(); AbsoluteDate year = new AbsoluteDate(Main.YEAR, utc); double tof = FastMath.abs(subSet.elementAt(0).getDOY() - subSet.elementAt(N - 1).getDOY()) * 24 * 3600; // System.out.println("RA\t:" + subSet.elementAt(0).getRA() + "\tDEC:\t" + subSet.elementAt(0).getDEC() + "\thyp:\t" + hyp[0]); Vector3D geoPos1 = conversions.radec2geo(subSet.elementAt(0), hyp[0], staF, inertialFrame, utc); Vector3D geoPos2 = conversions.radec2geo(subSet.elementAt(N - 1), hyp[1], staF, inertialFrame, utc); // System.out.println("x1:\t" + geoPos1.getX() + "\ty1:\t" + geoPos1.getY() + "\tz1:\t" + geoPos1.getZ()); // define epoch of first tracklet AbsoluteDate epoch0 = new AbsoluteDate(year, subSet.elementAt(0).getDOY() * 24 * 3600); // perform lambert solver Lambert solve = new Lambert(); solve.lambert_problem(geoPos1, geoPos2, tof, Constants.EIGEN5C_EARTH_MU, Boolean.FALSE, 1); RealMatrix v1 = solve.get_v1();//from ww w .j a v a 2 s. co m // get the orbital elements at epoch 0 Vector3D v1vec = new Vector3D(v1.getEntry(0, 0), v1.getEntry(0, 1), v1.getEntry(0, 2)); PVCoordinates PVgeo1 = new PVCoordinates(geoPos1, v1vec); CartesianOrbit orbit = new CartesianOrbit(PVgeo1, inertialFrame, epoch0, Constants.EIGEN5C_EARTH_MU); // System.out.println("a:\t" + orbit.getA() + "\ti:\t" + orbit.getI() + "\te:\t" + orbit.getE()); return orbit; }
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. java 2 s .c o m*/ } if (retlist.size() == 0) return null; return retlist; }
From source file:Main.java
public static synchronized Element[] getChildElements(Element element) { if (element == null) { return null; }//w w w . ja v a2 s . com Vector childs = new Vector(); for (Node node = element.getFirstChild(); node != null; node = node.getNextSibling()) { if (node instanceof Element) { childs.add((Element) node); } } Element[] elmt = new Element[childs.size()]; childs.toArray(elmt); return elmt; }