List of usage examples for java.util Vector Vector
public Vector()
From source file:Main.java
public Enumeration keys() { Enumeration keysEnum = super.keys(); Vector<String> keyList = new Vector<String>(); while (keysEnum.hasMoreElements()) { keyList.add((String) keysEnum.nextElement()); }/* w w w . j a v a2 s. c o m*/ Collections.sort(keyList); return keyList.elements(); }
From source file:com.robonobo.common.media.PlaylistItem.java
public static List getPlaylist(String uri) throws IOException, PlaylistFormatException { Log log = LogFactory.getLog(PlaylistItem.class); Vector list = new Vector(); HttpClient client = new HttpClient(); GetMethod get = new GetMethod(uri); int status = client.executeMethod(get); switch (status) { case 200:/* w w w . ja v a 2s .co m*/ BufferedReader reader = new BufferedReader(new InputStreamReader(get.getResponseBodyAsStream())); String line = reader.readLine(); if (!line.equals("[playlist]")) throw new PlaylistFormatException("The provided URL does not describe a playlist"); String[] kvp; int currentEntryNumber = 1; int version = 2; int supposedNumberOfEntries = 1; PlaylistItem currentEntry = new PlaylistItem(); while ((line = reader.readLine()) != null) { kvp = line.split("="); if (kvp[0].equals("NumberOfEntries")) { supposedNumberOfEntries = Integer.parseInt(kvp[1]); } else if (kvp[0].equals("Version")) { version = Integer.parseInt(kvp[1]); if (version != 2) throw new PlaylistFormatException( "This parser currently only supports version 2 .pls files"); } else { if (!kvp[0].endsWith(String.valueOf(currentEntryNumber))) { list.add(currentEntry); currentEntryNumber++; currentEntry = new PlaylistItem(); } if (kvp[0].startsWith("File")) { currentEntry.setFile(kvp[1]); } else if (kvp[0].startsWith("Title")) { currentEntry.setTitle(kvp[1]); } else if (kvp[0].startsWith("Length")) { currentEntry.setLength(Integer.parseInt(kvp[1])); } } } if (currentEntry != null) list.add(currentEntry); if (supposedNumberOfEntries != list.size()) throw new PlaylistFormatException("The server said there were " + supposedNumberOfEntries + " but we actually got " + list.size()); return list; default: throw new IOException( "The remote server responded with a status " + status + " and not 200 as expected"); } }
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); }/*w ww . j a v a 2s.c o m*/ return array; }
From source file:Main.java
/** * Get child elements by name, ignoring namespace declarations * * @param ele parent element//from ww w . j av a 2s.c o m * @param name name of elements to find */ public static List<Element> getElementsByName(Element ele, String name) { 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); String n = e.getNodeName(); if (matches(n, name)) list.add(e); } return (list); }
From source file:com.instantme.model.UserEntryModel.java
public UserEntryModel() { data = new Vector(); }
From source file:com.gc.iotools.fmt.base.TestUtils.java
public static String[] listFilesExcludingExtension(final String[] forbidden) throws IOException { final URL fileURL = TestUtils.class.getResource("/testFiles"); String filePath = URLDecoder.decode(fileURL.getPath(), "UTF-8"); final File dir = new File(filePath); final String[] files = dir.list(); final Collection<String> goodFiles = new Vector<String>(); if (!filePath.endsWith(File.separator)) { filePath = filePath + File.separator; }/* w w w . ja v a 2 s. co m*/ for (final String file : files) { boolean insert = true; for (final String extForbidden : forbidden) { insert &= !(file.endsWith(extForbidden)); } if (insert) { goodFiles.add(filePath + file); } } return goodFiles.toArray(new String[goodFiles.size()]); }
From source file:MyTextHandler.java
public MyTextHandler(PrintWriter out) { this.out = out; personVec = new Vector(); }
From source file:Main.java
/** * used to parse out elements of a list such as this: * <node>//from ww w . jav a 2s . c o m * <element>value1</element> * <element>value2</element> * <element>value3</element> * </node> * * for this example, called with Node pointing to <node> element and "element" * in listElementName. * @param listNode pointer to list's "root" node * @param listElementName name of list element * @return Vector of list elements */ public static Vector getListElements(Node listNode, String listElementName) { String tmp = ""; Vector ret = null; NodeList children = listNode.getChildNodes(); if (children != null) { ret = new Vector(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child.getNodeName().equalsIgnoreCase(listElementName)) { /* value is in element node's only (text) child */ String value = child.getChildNodes().item(0).getNodeValue(); if ((value != null) && !value.equals("")) { ret.add(value); } } } } return ret; }
From source file:mujava.cli.Util.java
public static void setUpVectors() { //all mutants in a class mutants = new Vector(); //killed mutants in a class killed_mutants = new Vector(); //live mutants in a class live_mutants = new Vector(); //eq mutants in a class eq_mutants = new Vector(); }
From source file:GeometryUtilities.java
public static Vector<Point2D> getCrossings(Arc2D arc0, Point2D arc0Center, Arc2D arc1, Point2D arc1Center) { Vector<Point2D> ret = new Vector<Point2D>(); double distance = arc0Center.distance(arc1Center); double radius0Squared = arc0Center.distanceSq(arc0.getStartPoint()); double radius0 = sqrt(radius0Squared); double radius1Squared = arc1Center.distanceSq(arc1.getStartPoint()); double radius1 = sqrt(radius1Squared); if (distance > radius0 + radius1) { // There are no solutions because the circles are separate. } else if (distance < abs(radius0 - radius1)) { // There are no solutions because one circle is contained within the // other. } else if (distance == 0 && radius0 == radius1) { // There are an infinite number of solutions because the circles are // coincident. } else {//from w ww . j a v a2s . co m // Calculate the first intersection double x0 = arc0Center.getX(), y0 = arc0Center.getY(); double x1 = arc1Center.getX(), y1 = arc1Center.getY(); double a = (radius0Squared - radius1Squared + distance * distance) / (2 * distance); double h = sqrt(radius0Squared - a * a); double x2 = x0 + a * (x1 - x0) / distance; double y2 = y0 + a * (y1 - y0) / distance; Point2D.Double intersection = new Point2D.Double(x2 + h * (y1 - y0) / distance, y2 - h * (x1 - x0) / distance); double angle0ToIntersection = toDegrees(atan2(-(intersection.y - y0), intersection.x - x0)); double angle1ToIntersection = toDegrees(atan2(-(intersection.y - y1), intersection.x - x1)); if (arc0.containsAngle(angle0ToIntersection) && arc1.containsAngle(angle1ToIntersection)) ret.add(intersection); // If the circles aren't tangential, calculate the second // intersection if (distance != radius0 + radius1) { intersection = new Point2D.Double(x2 - h * (y1 - y0) / distance, y2 + h * (x1 - x0) / distance); angle0ToIntersection = toDegrees(atan2(-(intersection.y - y0), intersection.x - x0)); angle1ToIntersection = toDegrees(atan2(-(intersection.y - y1), intersection.x - x1)); if (arc0.containsAngle(angle0ToIntersection) && arc1.containsAngle(angle1ToIntersection)) ret.add(intersection); } } return ret; }