List of usage examples for java.util Vector Vector
public Vector()
From source file:Main.java
public static String[] kommaList2Arr(String s, char sep) { if (s == null) { return null; }/* www . j a v a2 s . com*/ Vector v; if (s.length() > 0) { v = split(s, sep); } else { v = new Vector(); } String[] aa = new String[v.size()]; for (int ii = 0; ii < v.size(); ii++) { aa[ii] = (String) v.get(ii); } return aa; }
From source file:Main.java
public static int[] kommaList2IntArr(String s, char sep) { if (s == null) { return null; }//from w w w. j av a 2 s. c om Vector v; if (s.length() > 0) { v = split(s, sep); } else { v = new Vector(); } int[] aa = new int[v.size()]; for (int ii = 0; ii < v.size(); ii++) { aa[ii] = string2int((String) v.get(ii), 0); } return aa; }
From source file:Main.java
public static Object[] toArray(Iterator anIterator, Class eachElementType) { Vector vector = new Vector(); while (anIterator.hasNext()) vector.add(anIterator.next());/*w w w .ja v a2 s .co m*/ return toArray(vector, eachElementType); }
From source file:Main.java
/** * Takes a single line command as a string and breaks it up in tokens * acceptable for the java.lang.ProcessBuilder.ProcessBuilder * @param command Complete command as a single string * @return Array of strings that are acceptable tokens for ProcessBuilder * @throws Exception //from www . ja v a 2 s. com */ static public List<String> breakUpCommand(String command) throws Exception { try { List<String> commandTokens = new Vector<String>(); StringBuilder currentToken = null; boolean isTokenQuoted = false; StringReader sr = new StringReader(command); int b = sr.read(); while (b >= 0) { char c = (char) b; if (null == currentToken) { // At token is not in progress // Skipping spaces if (' ' == c || '\t' == c) { } else if ('"' == c) { // Starting a quoted token currentToken = new StringBuilder(); //currentToken.append(c); isTokenQuoted = true; } else { // Starting a non-quoted token currentToken = new StringBuilder(); currentToken.append(c); isTokenQuoted = false; } } else if (isTokenQuoted) { // A quoted token is in progress. It ends with a quote if ('"' == c) { //currentToken.append(c); String token = currentToken.toString(); currentToken = null; commandTokens.add(token); } else { // Continuation currentToken.append(c); } } else { // A non-quoted token is in progress. It ends with a space if (' ' == c || '\t' == c) { String token = currentToken.toString(); currentToken = null; commandTokens.add(token); } else { // Continuation currentToken.append(c); } } b = sr.read(); } if (null != currentToken) { String token = currentToken.toString(); commandTokens.add(token); } return commandTokens; } catch (IOException e) { throw new Exception("Error while breaking up command into tokens: " + command, e); } }
From source file:Main.java
public static <E> Vector<E> newVector() { return new Vector<E>(); }
From source file:Main.java
public static String[] fecthAllTimeZoneIds() { Vector<String> v = new Vector<String>(); String[] ids = TimeZone.getAvailableIDs(); for (int i = 0; i < ids.length; i++) { v.add(ids[i]);// w w w .ja v a 2 s . c o m } java.util.Collections.sort(v, String.CASE_INSENSITIVE_ORDER); v.copyInto(ids); v = null; return ids; }
From source file:Main.java
protected static void expandTree(JTree tree, TreePath path, Hashtable lookedAt) { Object node = path.getLastPathComponent(); if (lookedAt.containsKey(node)) return;//from w ww . ja va 2s. c o m lookedAt.put(node, node); Vector paths = new Vector(); tree.makeVisible(path); int childCount = tree.getModel().getChildCount(node); for (int i = 0; i < childCount; i++) { Object child = tree.getModel().getChild(node, i); TreePath p = path.pathByAddingChild(child); expandTree(tree, p, lookedAt); } }
From source file:Main.java
/** Returns all child <code>Node</code>s with the given name stored in a * <code>Vector</code>.//from ww w.j a v a 2 s .co m * * @param node The parent node to be searched for * @param name The element name to search for * @return <code>Vector</code> of found </code>Node</code>s */ public static Vector getSubnodesByName(Node node, String name) { Vector retVal = null; NodeList nl = node.getChildNodes(); if (nl != null && nl.getLength() != 0) { for (int i = 0; i < nl.getLength(); i++) { if (nl.item(i).getNodeName().equals(name)) { if (retVal == null) retVal = new Vector(); retVal.addElement(nl.item(i)); } } } return retVal; }
From source file:Main.java
/** * Converts an iterable into a list by iterating through the * iterable /*from www .j av a2 s .c o m*/ * * @param values * @return */ public static <T> List<T> toList(Iterable<T> values) { List<T> res = new Vector<>(); for (T item : values) { res.add(item); } return res; }
From source file:Main.java
public static void initializeMap(InputStream is, boolean isPositive) { try {//from www.j a v a 2s . co m BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); String line = null; while ((line = reader.readLine()) != null) { StringTokenizer tokenizer = new StringTokenizer(line, "\t\n", false); String key = null; Vector<String> tokens = new Vector<String>(); if (tokenizer.hasMoreTokens()) key = tokenizer.nextToken(); while (tokenizer.hasMoreTokens()) { tokens.add(tokenizer.nextToken()); } if (key != null) { if (isPositive) posMap.put(key, tokens); else negMap.put(key, tokens); } } } catch (Exception e) { } }