List of usage examples for java.util Vector add
public synchronized boolean add(E e)
From source file:eionet.gdem.conversion.ConvertDDXMLMethod.java
/** * Converts conversion result object into Hashtable that is used in XML-RPC method result. * * @param dto Result transfer object/*from w ww . j a va 2s.c o m*/ * @return Hash table with result * @throws GDEMException If an error occurs */ public static final Hashtable<String, Object> convertExcelResult(ConversionResultDto dto) throws GDEMException { Hashtable<String, Object> result = new Hashtable<String, Object>(); result.put("resultCode", dto.getStatusCode()); result.put("resultDescription", dto.getStatusDescription()); result.put("conversionLog", dto.getConversionLogAsHtml()); Vector<Hashtable<String, Object>> convertedFiles = new Vector<Hashtable<String, Object>>(); if (dto.getConvertedFiles() != null) { for (ConvertedFileDto convertedFileDto : dto.getConvertedFiles()) { Hashtable<String, Object> convertedFile = new Hashtable<String, Object>(); convertedFile.put("fileName", convertedFileDto.getFileName()); convertedFile.put("content", convertedFileDto.getFileContentAsByteArray()); convertedFiles.add(convertedFile); } } result.put("convertedFiles", convertedFiles); return result; }
From source file:net.rim.ejde.internal.model.BlackBerryPropertiesFactory.java
/** * Gets the icons.//from w w w . jav a2 s . c o m * * @param project * the project * @param iProject * the i project * * @return the icons */ protected static Icon[] getIcons(final Project project, final IProject iProject) { IJavaProject javaProject = JavaCore.create(iProject); final Vector<Icon> newIcons = new Vector<Icon>(); Icon icon = null, rooloverIcon; Vector<File> iconFiles = project.getIcons(); // we only get the first icon if ((iconFiles != null) && (iconFiles.size() > 0)) { final File iconFile = iconFiles.get(0); if (iconFile.exists()) { icon = new Icon(getTargetRelFilePath(iconFile, project, javaProject)); newIcons.add(icon); } } iconFiles = project.getRolloverIcons(); // we only get the first rollover icon if ((iconFiles != null) && (iconFiles.size() > 0)) { final File iconFile = iconFiles.get(0); if (iconFile.exists()) { // If there is only 1 icon it cannot be a focus icon, so set focus status based on existence of first icon rooloverIcon = new Icon(getTargetRelFilePath(iconFile, project, javaProject), Boolean.valueOf(icon != null)); newIcons.add(rooloverIcon); } } return newIcons.toArray(new Icon[newIcons.size()]); }
From source file:Main.java
/** * Extract included filenames in the XML document, assuming that filenames are * provided with the attribute "href".//from w ww . java2 s . co m * * @param xmlDocument the XML document * @return the filenames to include */ private static Vector<String> extractIncludedFiles(Document xmlDocument) { Vector<String> includedFiles = new Vector<String>(); NodeList top = xmlDocument.getChildNodes(); for (int i = 0; i < top.getLength(); i++) { Node topNode = top.item(i); NodeList firstElements = topNode.getChildNodes(); for (int j = 0; j < firstElements.getLength(); j++) { Node midNode = firstElements.item(j); for (int k = 0; k < midNode.getChildNodes().getLength(); k++) { Node node = midNode.getChildNodes().item(k); if (node.hasAttributes() && node.getAttributes().getNamedItem("href") != null) { String fileName = node.getAttributes().getNamedItem("href").getNodeValue(); includedFiles.add(fileName); } } } } return includedFiles; }
From source file:Main.java
public static void U7ListFiles(String mask, Vector<String> filelist) { mask = getSystemPath(mask);//w w w . j av a 2 s. c o m char sep = '/'; int split = mask.lastIndexOf(sep); String dir, nameMask; if (split == -1) { dir = "."; nameMask = mask; } else { dir = mask.substring(0, split); nameMask = mask.substring(split + 1); } File folder = new File(dir); File[] listOfFiles = folder.listFiles(); Pattern pattern = Pattern.compile(nameMask); for (int i = 0; i < listOfFiles.length; i++) { if (listOfFiles[i].isFile()) { String fname = listOfFiles[i].getName(); if (pattern.matcher(fname).matches()) filelist.add(dir + sep + fname); } } }
From source file:com.vmware.qe.framework.datadriven.utils.XMLUtil.java
public static Vector<String> getValueOnTag(Document doc, String elementName) { Vector<String> elementNames = new Vector<String>(); NodeList list = doc.getElementsByTagName(elementName); log.info("XML Elements: "); for (int i = 0; i < list.getLength(); i++) { Element element = (Element) list.item(i); elementNames.add(element.getAttribute("name")); log.info("Element Name : " + element.getLocalName() + " Value :" + element.getAttribute("name")); }// w w w . jav a 2s . c om return elementNames; }
From source file:com.greenpepper.server.rpc.xmlrpc.XmlRpcDataMarshaller.java
/** * Wraps the error message id into a Vector of Vector of String.<br> * Structure of the error:<br>//from w w w .j a va2 s. c o m * Vector[Vector[TAG_ERROR errorId]] * </p> * * @param msgId a {@link java.lang.String} object. * @return the error message id as a Vector. */ public static Vector<Object> errorAsVector(String msgId) { Vector<Object> err = new Vector<Object>(); err.add(errorAsString(msgId)); return err; }
From source file:gov.nih.nci.evs.browser.utils.ViewInHierarchyUtils.java
public static Vector<String> parseData(String line, String tab) { if (line == null) return null; Vector data_vec = new Vector(); StringTokenizer st = new StringTokenizer(line, tab); while (st.hasMoreTokens()) { String value = st.nextToken(); if (value.compareTo("null") == 0) value = " "; data_vec.add(value); }/*from w w w . j a va 2 s . com*/ return data_vec; }
From source file:eu.crowdrec.contest.sender.RequestSenderORP.java
/** * read logFile then sends line by line to server. * //from w w w. j a v a2 s . co m * @param inLogFileName * path to log file. That can be a zip file or text file. * @param outLogFile * path to outLog file. The outLog file should be analyzed by the evaluator. * if the filename is null; no output will be generated * @param serverURL * URL of the server */ public static void sender(final String inLogFileName, final String outLogFile, final String serverURL) { // handle the log file // check type of file // try to read the defined logFile BufferedReader br = null; BufferedWriter bw = null; try { // if outLogFile name is not null, create an output file if (outLogFile != null && outLogFile.length() > 0) { bw = new BufferedWriter(new FileWriter(new File(outLogFile), false)); } // support a list of files in a directory File inLogFile = new File(inLogFileName); InputStream is; if (inLogFile.isFile()) { is = new FileInputStream(inLogFileName); // support gZip files if (inLogFile.getName().toLowerCase().endsWith(".gz")) { is = new GZIPInputStream(is); } } else { // if the input is a directory, consider all files based on a pattern File[] childs = inLogFile.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { final String fileName = name.toLowerCase(); return fileName.startsWith("contest.log"); } }); if (childs == null || childs.length == 0) { throw new IOException("invalid inLogFileName or empty directory"); } Arrays.sort(childs, new Comparator<File>() { @Override public int compare(File o1, File o2) { return o1.getName().compareTo(o2.getName()); } }); Vector<InputStream> isChilds = new Vector<InputStream>(); for (int i = 0; i < childs.length; i++) { InputStream tmpIS = new FileInputStream(childs[i]); // support gZip files if (childs[i].getName().toLowerCase().endsWith(".gz")) { tmpIS = new GZIPInputStream(tmpIS); } isChilds.add(tmpIS); } is = new SequenceInputStream(isChilds.elements()); } // read the log file line by line br = new BufferedReader(new InputStreamReader(is)); try { for (String line = br.readLine(); line != null; line = br.readLine()) { // ignore invalid lines and header if (line.startsWith("null") || line.startsWith("#")) { continue; } String[] token = parseLogLine(line); if (token == null) { System.err.println( "HHHHHHHHHHHHHHHHHHHHHHHHHHEEEEEEEEEEEEEEEEEEELLLLLLLLLLLLLLLLPPPPPPPPPPPPPPP"); System.err.println( "HHHHHHHHHHHHHHHHHHHHHHHHHHEEEEEEEEEEEEEEEEEEELLLLLLLLLLLLLLLLPPPPPPPPPPPPPPP"); System.err.println( "HHHHHHHHHHHHHHHHHHHHHHHHHHEEEEEEEEEEEEEEEEEEELLLLLLLLLLLLLLLLPPPPPPPPPPPPPPP"); System.err.println( "HHHHHHHHHHHHHHHHHHHHHHHHHHEEEEEEEEEEEEEEEEEEELLLLLLLLLLLLLLLLPPPPPPPPPPPPPPP"); System.err.println(line); System.err.println( "HHHHHHHHHHHHHHHHHHHHHHHHHHEEEEEEEEEEEEEEEEEEELLLLLLLLLLLLLLLLPPPPPPPPPPPPPPP"); System.err.println( "HHHHHHHHHHHHHHHHHHHHHHHHHHEEEEEEEEEEEEEEEEEEELLLLLLLLLLLLLLLLPPPPPPPPPPPPPPP"); System.err.println( "HHHHHHHHHHHHHHHHHHHHHHHHHHEEEEEEEEEEEEEEEEEEELLLLLLLLLLLLLLLLPPPPPPPPPPPPPPP"); continue; } // use a threadPool RequestSenderThread t = new RequestSenderThread(token[0], token[1], token[2], serverURL, bw); try { // try to limit the speed of sending requests if (Thread.activeCount() > 1000) { if (logger.isDebugEnabled()) { logger.debug("Thread.activeCount() = " + Thread.activeCount()); } Thread.sleep(200); } } catch (Exception e) { logger.info(e.toString()); } t.start(); } } catch (IOException e) { logger.warn(e.toString(), e); } } catch (FileNotFoundException e) { logger.error("logFile not found e:" + e.toString()); } catch (IOException e) { logger.error("reading the logFile failed e:" + e.toString()); } finally { if (br != null) { try { br.close(); } catch (IOException e) { logger.debug("close read-log file failed"); } } if (bw != null) { try { // wait for ensuring that all request are finished // this simplifies the management of thread and worked fine for all test machines Thread.sleep(5000); bw.flush(); } catch (Exception e) { logger.debug("close write-log file failed"); } } } }
From source file:Main.java
public static void cosineSimilarityCW() { Iterator<Integer> ids = CommentWordCount.keySet().iterator(); while (ids.hasNext()) { int com_id = ids.next(); Set<String> words1; words1 = CommentWordCount.get(com_id).keySet(); Iterator<Integer> com_iter = CommentWordCount.keySet().iterator(); while (com_iter.hasNext()) { int id = com_iter.next(); if (com_id < id) { Set<String> words2; words2 = CommentWordCount.get(id).keySet(); Vector<Integer> vecA = new Vector<Integer>(); Vector<Integer> vecB = new Vector<Integer>(); Iterator<String> w1 = words1.iterator(); Iterator<String> w2 = words2.iterator(); HashSet<String> imp = new HashSet<String>(); while (w1.hasNext()) { String s = w1.next(); imp.add(s);//from w w w .ja v a 2 s . com } while (w2.hasNext()) { String s = w2.next(); imp.add(s); } for (String s : imp) { if (CommentWordCount.get(com_id).containsKey(s)) { vecA.add(CommentWordCount.get(com_id).get(s)); } else vecA.add(0); if (CommentWordCount.get(id).containsKey(s)) { vecB.add(CommentWordCount.get(id).get(s)); } else vecB.add(0); } //System.out.println("Size : A"+vecA.size()+" Size: B"+vecB.size()+"maxLen:"+maxlength); double similarity; int product = 0; double sumA = 0; double sumB = 0; for (int i = 0; i < vecA.size(); i++) { product += vecA.elementAt(i) * vecB.elementAt(i); sumA += vecA.elementAt(i) * vecA.elementAt(i); sumB += vecB.elementAt(i) * vecB.elementAt(i); } sumA = Math.sqrt(sumA); sumB = Math.sqrt(sumB); similarity = product / (sumA * sumB); similarity = Math.acos(similarity) * 180 / Math.PI; //System.out.println("Result "+com_id+" "+id+" :"+similarity); if (similarity < 75) { //System.out.println("Result "+com_id+" "+id); if (Topic.containsKey(com_id)) { int val = Topic.get(com_id); val++; Topic.put(com_id, val); } else Topic.put(com_id, 1); if (Topic.containsKey(id)) { int val = Topic.get(id); val++; Topic.put(id, val); } else Topic.put(id, 1); } } } } }
From source file:com.greenpepper.server.rpc.xmlrpc.XmlRpcDataMarshaller.java
/** * Transforms the Collection of runners into a Vector of runners parameters. * </p>//w ww .j a v a 2 s .co m * * @param runners a {@link java.util.Collection} object. * @return the Collection of runners into a Vector of runners parameters */ public static Vector<Object> toXmlRpcRunnersParameters(Collection<Runner> runners) { Vector<Object> runnersParams = new Vector<Object>(); for (Runner runner : runners) { runnersParams.add(runner.marshallize()); } return runnersParams; }