List of usage examples for java.util Vector addElement
public synchronized void addElement(E obj)
From source file:com.maverick.http.MultiStatusResponse.java
public static MultiStatusResponse[] createResponse(HttpResponse response) throws IOException { if (response.getStatus() != 207) { throw new IOException(Messages.getString("MultiStatusResponse.not207")); //$NON-NLS-1$ }/*w w w. j av a 2 s. c o m*/ ByteArrayOutputStream out = new ByteArrayOutputStream(); int read; byte[] buf = new byte[4096]; while ((read = response.getInputStream().read(buf)) > -1) { out.write(buf, 0, read); } // #ifdef DEBUG if (log.isDebugEnabled()) log.debug(new String(out.toByteArray())); // #endif try { IXMLParser parser = XMLParserFactory.createDefaultXMLParser(); IXMLReader reader = StdXMLReader.stringReader(new String(out.toByteArray(), "UTF8")); //$NON-NLS-1$ parser.setReader(reader); IXMLElement rootElement = (IXMLElement) parser.parse(); if (!rootElement.getName().equalsIgnoreCase("multistatus")) //$NON-NLS-1$ throw new IOException( Messages.getString("MultiStatusResponse.invalidDavRootElement") + rootElement.getName()); //$NON-NLS-1$ // Now process the responses Vector children = rootElement.getChildrenNamed("response", rootElement.getNamespace()); //$NON-NLS-1$ Vector responses = new Vector(); for (Enumeration e = children.elements(); e.hasMoreElements();) { responses.addElement(new MultiStatusResponse((IXMLElement) e.nextElement())); } MultiStatusResponse[] array = new MultiStatusResponse[responses.size()]; responses.copyInto(array); return array; } catch (Exception ex) { // #ifdef DEBUG log.error(Messages.getString("MultiStatusResponse.failedToProcessMultistatusResponse"), ex); //$NON-NLS-1$ // #endif throw new IOException(ex.getMessage()); } }
From source file:GroupRadio.java
public static Enumeration getSelectedElements(Container container) { Vector selections = new Vector(); Component components[] = container.getComponents(); for (int i = 0, n = components.length; i < n; i++) { if (components[i] instanceof AbstractButton) { AbstractButton button = (AbstractButton) components[i]; if (button.isSelected()) { selections.addElement(button.getText()); }//from w ww . j ava 2s . c om } } return selections.elements(); }
From source file:SplitPaneDemo2.java
protected static Vector parseList(String theStringList) { Vector v = new Vector(10); StringTokenizer tokenizer = new StringTokenizer(theStringList, " "); while (tokenizer.hasMoreTokens()) { String image = tokenizer.nextToken(); v.addElement(image); }/* w ww . j av a 2s . com*/ return v; }
From source file:StringUtils.java
public static String[] split(String string, char[] separatorChars) { if (string == null || string.equals("")) return new String[] { string }; int len = string.length(); Vector separators = new Vector(separatorChars.length); for (int s = 0; s < separatorChars.length; s++) separators.addElement(new Character(separatorChars[s])); Vector list = new Vector(); int i = 0;/*from w w w . j a v a 2 s.com*/ int start = 0; boolean match = false; while (i < len) { if (separators.contains(new Character(string.charAt(i)))) { if (match) { list.addElement(string.substring(start, i)); match = false; } start = ++i; continue; } match = true; i++; } if (match) { list.addElement(string.substring(start, i)); } String[] arr = new String[list.size()]; list.copyInto(arr); return arr; }
From source file:esg.node.core.Resource.java
@SuppressWarnings("unchecked") private static String[] split(String str, String delim) { // Use a Vector to hold the split strings. Vector v = new Vector(); // Use a StringTokenizer to do the splitting. StringTokenizer tokenizer = new StringTokenizer(str, delim); while (tokenizer.hasMoreTokens()) { v.addElement(tokenizer.nextToken()); }//from w ww . j a v a 2 s. co m String[] ret = new String[v.size()]; v.copyInto(ret); return ret; }
From source file:com.legstar.codegen.tasks.SourceToXsdCobolTask.java
/** * Converts a URI into a package name. We assume a hierarchical, * server-based URI with the following syntax: * [scheme:][//host[:port]][path][?query][#fragment] * The package name is derived from host, path and fragment. * //from w w w . j a va 2 s .com * @param namespaceURI the input namespace URI * @return the result package name */ public static String packageFromURI(final URI namespaceURI) { StringBuilder result = new StringBuilder(); URI nURI = namespaceURI.normalize(); boolean firstToken = true; /* * First part of package name is built from host with tokens in * reverse order. */ if (nURI.getHost() != null && nURI.getHost().length() != 0) { Vector<String> v = new Vector<String>(); StringTokenizer t = new StringTokenizer(nURI.getHost(), "."); while (t.hasMoreTokens()) { v.addElement(t.nextToken()); } for (int i = v.size(); i > 0; i--) { if (!firstToken) { result.append('.'); } else { firstToken = false; } result.append(v.get(i - 1)); } } /* Next part of package is built from the path tokens */ if (nURI.getPath() != null && nURI.getPath().length() != 0) { Vector<String> v = new Vector<String>(); StringTokenizer t = new StringTokenizer(nURI.getPath(), "/"); while (t.hasMoreTokens()) { v.addElement(t.nextToken()); } for (int i = 0; i < v.size(); i++) { String token = v.get(i); /* ignore situations such as /./../ */ if (token.equals(".") || token.equals("..")) { continue; } if (!firstToken) { result.append('.'); } else { firstToken = false; } result.append(v.get(i)); } } /* Finally append any fragment */ if (nURI.getFragment() != null && nURI.getFragment().length() != 0) { if (!firstToken) { result.append('.'); } else { firstToken = false; } result.append(nURI.getFragment()); } /* * By convention, namespaces are lowercase and should not contain * invalid Java identifiers */ String s = result.toString().toLowerCase(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length(); i++) { Character c = s.charAt(i); if (Character.isJavaIdentifierPart(c) || c.equals('.')) { sb.append(c); } else { sb.append("_"); } } return sb.toString(); }
From source file:Main.java
public static Vector<String> getPropertiesFromXML(Node propNode) { Vector<String> properties; properties = new Vector<String>(); NodeList childList = propNode.getChildNodes(); for (int i = 0; i < childList.getLength(); i++) { Node currentNode = childList.item(i); if (currentNode.getNodeType() == Node.ELEMENT_NODE) { String nodeName = currentNode.getLocalName(); String namespace = currentNode.getNamespaceURI(); // href is a live property which is handled differently properties.addElement(namespace + ":" + nodeName); }/*from w ww. ja va 2 s. c om*/ } return properties; }
From source file:gdt.data.grain.Support.java
/** * Add a string into the vector.//from w ww . j a v a2 s . com * @param name$ the string * @param vec vector of strings. * @return 0 if success,-1 otherwise. */ public static int addItem(String name$, Vector<String> vec) { if (name$ == null) return -1; if (vec == null) return -1; if (Support.itemExists(name$, vec)) return 0; vec.addElement(name$); return 0; }
From source file:presentation.webgui.vitroappservlet.StyleCreator.java
public static JFreeChart createDatasetAndChart(Model3dStylesEntry givStyleEntry) { Vector<String> tmpCategLabels = new Vector<String>(); Vector<String> tmpCategColors = new Vector<String>(); tmpCategLabels.addElement("Default"); tmpCategColors.addElement(givStyleEntry.getGlobalColor()); for (int i = 0; i < givStyleEntry.getSpecialCasesVec().size(); i++) { String tmpLabel = givStyleEntry.getSpecialCasesVec().elementAt(i).getSpecialValue(); tmpCategLabels.addElement(tmpLabel); if (givStyleEntry.getSpecialCasesVec().elementAt(i).getColor1() .equals(Model3dStyleSpecialCase.UNDEFINEDCOLOR1)) { tmpCategColors.addElement(givStyleEntry.getGlobalColor()); // get the global default set } else/* w ww.j a v a 2 s. c o m*/ tmpCategColors.addElement(givStyleEntry.getSpecialCasesVec().elementAt(i).getColor1()); } for (int i = 0; i < givStyleEntry.getNumericCasesVec().size(); i++) { String tmpLabel = ""; if (givStyleEntry.getNumericCasesVec().elementAt(i).getFromValue().equals("")) { tmpLabel = "(-inf, "; } else tmpLabel = "[" + givStyleEntry.getNumericCasesVec().elementAt(i).getFromValue() + ", "; if (givStyleEntry.getNumericCasesVec().elementAt(i).getToValue().equals("")) { tmpLabel += "+inf)"; } else tmpLabel += givStyleEntry.getNumericCasesVec().elementAt(i).getToValue() + ")"; tmpCategLabels.addElement(tmpLabel); if (givStyleEntry.getNumericCasesVec().elementAt(i).getColor1() .equals(Model3dStyleNumericCase.UNDEFINEDCOLOR1)) { tmpCategColors.addElement(givStyleEntry.getGlobalColor()); // get the global default set } else tmpCategColors.addElement(givStyleEntry.getNumericCasesVec().elementAt(i).getColor1()); } int sizeOfDataColumn = 15; //indicates the "length" of the bars in a per cent scale. double[][] data = { { sizeOfDataColumn } }; String[] myCategories = { "error" }; if (tmpCategLabels.size() > 0) { data = new double[1][tmpCategLabels.size()]; myCategories = new String[tmpCategLabels.size()]; for (int i = 0; i < tmpCategLabels.size(); i++) { data[0][i] = sizeOfDataColumn; myCategories[i] = tmpCategLabels.elementAt(i); } } final String[] mySeries = { "" }; CategoryDataset dataset = DatasetUtilities.createCategoryDataset(mySeries, myCategories, data); JFreeChart chart = createChart(dataset, tmpCategColors, givStyleEntry); return chart; }
From source file:FileUtil.java
public static Vector removeDuplicates(Vector a, Vector b) { int i = 0;// w w w . j a va 2 s. c o m int j = 0; boolean present = true; Vector v = new Vector(); for (i = 0; i < a.size(); i++) { present = false; for (j = 0; j < b.size(); j++) { if (a.elementAt(i).toString().equalsIgnoreCase(b.elementAt(j).toString())) { present = true; } } if (!(present)) { v.addElement(a.elementAt(i)); } } return v; }