List of usage examples for java.util Vector size
public synchronized int size()
From source file:net.java.sen.tools.DictionaryMaker.java
private int getDicIdNoCache(String csv[]) { Vector result = new Vector(); getIdList(csv, result, 1);/*from www .j a v a2 s . c o m*/ if (result.size() == 0) { log.error("can't find morpheme type"); log.error("input string is here:"); log.error("ruleList size=" + ruleList.size()); StringBuffer buf = new StringBuffer(); for (int i = 0; i < csv.length; i++) { buf.append(csv[i]); buf.append(","); } log.error(buf); return -1; } int priority[] = new int[result.size()]; int max = 0; for (int i = 0; i < result.size(); i++) { String v[] = (String[]) ruleList.get(((Integer) result.get(i)).intValue()); for (int j = 0; j < v.length; j++) { if (v[j].charAt(0) != '*') priority[i]++; } if (priority[max] < priority[i]) max = i; log.debug("detect=="); log.debug(getById(((Integer) result.get(max)).intValue())); } return ((Integer) result.get(max)).intValue(); }
From source file:com.qframework.core.ServerkoParse.java
public static int parseFloatData(Vector<float[]> outdata, String data, int[] offsets) { float val = 0; int arrcount = 0; int offsetcount = 0; float[] array = null; int currsize = 0; StringTokenizer tok = new StringTokenizer(data, ","); while (tok.hasMoreTokens()) { if (arrcount == 0) { currsize = offsets[offsetcount++]; offsetcount = offsetcount % offsets.length; array = new float[currsize]; }// w ww .j av a2s.co m try { val = Float.parseFloat(tok.nextToken()); } catch (NumberFormatException e) { } array[arrcount++] = val; if (arrcount >= currsize) { outdata.add(array); arrcount = 0; } } return outdata.size(); }
From source file:net.sf.jabref.exporter.layout.Layout.java
public Layout(Vector<StringInt> parsedEntries, String classPrefix) { Vector<LayoutEntry> tmpEntries = new Vector<>(parsedEntries.size()); Vector<StringInt> blockEntries = null; LayoutEntry le;//from www .j a v a 2 s . c om String blockStart = null; for (StringInt parsedEntry : parsedEntries) { // TODO: Rewrite using switch if ((parsedEntry.i == LayoutHelper.IS_LAYOUT_TEXT) || (parsedEntry.i == LayoutHelper.IS_SIMPLE_FIELD)) { // Do nothing } else if (parsedEntry.i == LayoutHelper.IS_FIELD_START) { blockEntries = new Vector<>(); blockStart = parsedEntry.s; } else if (parsedEntry.i == LayoutHelper.IS_FIELD_END) { if ((blockStart != null) && (blockEntries != null)) { if (blockStart.equals(parsedEntry.s)) { blockEntries.add(parsedEntry); le = new LayoutEntry(blockEntries, classPrefix, LayoutHelper.IS_FIELD_START); tmpEntries.add(le); blockEntries = null; } else { LOGGER.debug(blockStart + '\n' + parsedEntry.s); LOGGER.warn("Nested field entries are not implemented!"); Thread.dumpStack(); } } } else if (parsedEntry.i == LayoutHelper.IS_GROUP_START) { blockEntries = new Vector<>(); blockStart = parsedEntry.s; } else if (parsedEntry.i == LayoutHelper.IS_GROUP_END) { if ((blockStart != null) && (blockEntries != null)) { if (blockStart.equals(parsedEntry.s)) { blockEntries.add(parsedEntry); le = new LayoutEntry(blockEntries, classPrefix, LayoutHelper.IS_GROUP_START); tmpEntries.add(le); blockEntries = null; } else { LOGGER.warn("Nested field entries are not implemented!"); Thread.dumpStack(); } } } else if (parsedEntry.i == LayoutHelper.IS_OPTION_FIELD) { // Do nothing } if (blockEntries == null) { tmpEntries.add(new LayoutEntry(parsedEntry, classPrefix)); } else { blockEntries.add(parsedEntry); } } layoutEntries = new LayoutEntry[tmpEntries.size()]; for (int i = 0; i < tmpEntries.size(); i++) { layoutEntries[i] = tmpEntries.get(i); // Note if one of the entries has an invalid formatter: if (layoutEntries[i].isInvalidFormatter()) { missingFormatters.addAll(layoutEntries[i].getInvalidFormatters()); } } }
From source file:com.greenpepper.server.rpc.xmlrpc.XmlRpcDataMarshaller.java
/** * Transforms the Vector of the Specification parameters into a Specification Object.<br> * Structure of the parameters:<br> * Vector[name, Vector[repository parameters], Vector[SUT parameters]] * </p>/*from w ww . j av a 2 s.co m*/ * * @param xmlRpcParameters a {@link java.util.Vector} object. * @return the Specification. */ @SuppressWarnings("unchecked") public static Specification toSpecification(Vector<Object> xmlRpcParameters) { Specification specification = null; if (!xmlRpcParameters.isEmpty()) { specification = Specification.newInstance((String) xmlRpcParameters.get(DOCUMENT_NAME_IDX)); specification .setRepository(toRepository((Vector<Object>) xmlRpcParameters.get(DOCUMENT_REPOSITORY_IDX))); specification.setTargetedSystemUnderTests( toSystemUnderTestList((Vector<Object>) xmlRpcParameters.get(SPECIFICATION_SUTS_IDX))); if (xmlRpcParameters.size() >= 4) { specification.setDialectClass((String) xmlRpcParameters.get(SPECIFICATION_DIALECT_IDX)); } } return specification; }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.clinicalData.SetUnitsListener.java
@Override public void handleEvent(Event event) { Vector<String> columns = this.setUnitsUI.getColumns(); Vector<String> units = this.setUnitsUI.getUnits(); if (columns.size() == 1) { if (columns.get(0).compareTo("") == 0 && columns.get(0).compareTo("") == 0) { columns = new Vector<String>(); units = new Vector<String>(); }/*w ww .ja v a2s. com*/ } for (int i = 0; i < columns.size(); i++) { if (columns.get(i).compareTo("") == 0 || units.get(i).compareTo("") == 0) { this.setUnitsUI.displayMessage("Some values are not set"); return; } String columnFileName = columns.get(i).split(" - ", 2)[0]; String unitFileName = units.get(i).split(" - ", 2)[0]; if (columnFileName.compareTo(unitFileName) != 0) { this.setUnitsUI.displayMessage("Columns for value and unit have to been from the same file"); } } if (((ClinicalData) this.dataType).getCMF() == null) { this.setUnitsUI.displayMessage("Error: no column mapping file"); return; } if (!this.checkValues(columns, units)) return; File file = new File(this.dataType.getPath().toString() + File.separator + this.dataType.getStudy().toString() + ".columns.tmp"); try { FileWriter fw = new FileWriter(file); BufferedWriter out = new BufferedWriter(fw); out.write( "Filename\tCategory Code\tColumn Number\tData Label\tData Label Source\tControlled Vocab Code\n"); try { BufferedReader br = new BufferedReader(new FileReader(((ClinicalData) this.dataType).getCMF())); String line = br.readLine(); while ((line = br.readLine()) != null) { if (line.split("\t", -1)[3].compareTo("UNITS") != 0) { out.write(line + "\n"); } } br.close(); } catch (Exception e) { this.setUnitsUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); out.close(); } for (int i = 0; i < columns.size(); i++) { String fileName = columns.get(i).split(" - ", 2)[0]; int columnColumnNumber = -1; for (File rawFile : ((ClinicalData) this.dataType).getRawFiles()) { if (rawFile.getName().compareTo(fileName) == 0) { columnColumnNumber = FileHandler.getHeaderNumber(rawFile, columns.get(i).split(" - ", 2)[1]); } } int unitColumnNumber = -1; for (File rawFile : ((ClinicalData) this.dataType).getRawFiles()) { if (rawFile.getName().compareTo(fileName) == 0) { unitColumnNumber = FileHandler.getHeaderNumber(rawFile, units.get(i).split(" - ", 2)[1]); } } if (columnColumnNumber != -1 && unitColumnNumber != -1) { out.write(fileName + "\t\t" + String.valueOf(unitColumnNumber) + "\tUNITS\t" + String.valueOf(columnColumnNumber) + "\t\t\n"); } } out.close(); String fileName = ((ClinicalData) this.dataType).getCMF().getName(); FileUtils.deleteQuietly(((ClinicalData) this.dataType).getCMF()); try { File fileDest = new File(this.dataType.getPath() + File.separator + fileName); FileUtils.moveFile(file, fileDest); ((ClinicalData) this.dataType).setCMF(fileDest); } catch (Exception ioe) { this.setUnitsUI.displayMessage("File error: " + ioe.getLocalizedMessage()); return; } } catch (Exception e) { this.setUnitsUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } this.setUnitsUI.displayMessage("Column mapping file updated"); WorkPart.updateSteps(); WorkPart.updateFiles(); }
From source file:eionet.gdem.services.db.dao.StylesheetDaoTest.java
@Test public void deleteStylesheet() throws SQLException { Stylesheet initialStylesheet = createStylesheetObject(); String[] schemaUrls = { "uniqueSchema1", "uniqueSchema2" }; initialStylesheet.setSchemaUrls(Arrays.asList(schemaUrls)); String id = stylesheetDao.addStylesheet(initialStylesheet); Stylesheet stylesheet = stylesheetDao.getStylesheet(id); assertStylesheet(initialStylesheet, stylesheet); assertStylesheetSchemas(initialStylesheet, stylesheet); List<Schema> schemas = stylesheet.getSchemas(); stylesheetDao.deleteStylesheet(id);//w ww . ja v a 2s . c om Stylesheet noStylesheet = stylesheetDao.getStylesheet(id); assertNull(noStylesheet); // check if relations are deleted for (Schema schema : schemas) { Vector<?> schemaStylesheets = schemaDao.getSchemaStylesheets(schema.getId()); assertEquals(schemaStylesheets.size(), 0); } }
From source file:rb.app.RBnSCMCSystem.java
private List<Integer> getSorted_CJ_Indices(Vector<Parameter> C_J) { int J = C_J.size(); LinkedHashMap<Double, Integer> dist_from_mu = new LinkedHashMap<Double, Integer>(J); for (int j = 0; j < J; j++) { double dist = param_dist(get_current_parameters(), C_J.get(j)); dist_from_mu.put(dist, j);/*from w w w.j a v a 2 s.c o m*/ } List<Map.Entry<Double, Integer>> list = new LinkedList<Map.Entry<Double, Integer>>(dist_from_mu.entrySet()); Collections.sort(list, new Comparator() { public int compare(Object o1, Object o2) { return ((Comparable) ((Map.Entry) (o1)).getKey()).compareTo(((Map.Entry) (o2)).getKey()); } }); // Create a sorted list of values to return List<Integer> result = new LinkedList<Integer>(); for (Iterator it = list.iterator(); it.hasNext();) { Map.Entry<Double, Integer> entry = (Map.Entry<Double, Integer>) it.next(); result.add(entry.getValue()); } return result; }
From source file:de.ipbhalle.metfrag.main.CommandLineTool.java
/** * TODO adding inchi and inchi key generation * //from w w w . j av a 2 s . c om * save the results of the metfrag run * * @param results * @throws CDKException */ public static void saveResults(List<MetFragResult> results) { if (results == null || results.size() == 0) { System.out.println("Error: No results."); return; } MoleculeSet setOfMolecules = new MoleculeSet(); SmilesGenerator sg = new SmilesGenerator(); //uncomment if inchi generation is avaiable on your system - jni-inchi /*org.openscience.cdk.inchi.InChIGeneratorFactory factory = null; try { factory = org.openscience.cdk.inchi.InChIGeneratorFactory.getInstance(); } catch (CDKException e3) { e3.printStackTrace(); }*/ for (MetFragResult result : results) { IAtomContainer tmp = result.getStructure(); tmp = AtomContainerManipulator.removeHydrogens(tmp); String smiles = sg.createSMILES(tmp); tmp.setProperty("DatabaseID", result.getCandidateID()); tmp.setProperty("NoPeaksExplained", result.getPeaksExplained()); tmp.setProperty("SMILES", smiles); //uncomment if inchi generation is avaiable on your system - jni-inchi /* IAtomContainer tmp_clone = null; try { tmp_clone = (IAtomContainer)tmp.clone(); } catch (CloneNotSupportedException e2) { e2.printStackTrace(); } if(factory != null && tmp_clone != null) { try { AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(tmp_clone); } catch (CDKException e1) { } org.openscience.cdk.tools.CDKHydrogenAdder hAdder = org.openscience.cdk.tools.CDKHydrogenAdder.getInstance(tmp_clone.getBuilder()); for(int i = 0; i < tmp_clone.getAtomCount(); i++) { try { hAdder.addImplicitHydrogens(tmp_clone, tmp_clone.getAtom(i)); } catch(Exception e) { continue; } } AtomContainerManipulator.convertImplicitToExplicitHydrogens(tmp_clone); try { org.openscience.cdk.inchi.InChIGenerator gen = factory.getInChIGenerator(tmp_clone); if(gen != null) { String inchi = gen.getInchi(); tmp.setProperty("InChI", inchi); } } catch (CDKException e) { } }*/ tmp.setProperty("PeakScore", result.getRawPeakMatchScore()); tmp.setProperty("BondEnergyScore", result.getRawBondEnergyScore()); tmp.setProperty("Score", result.getScore()); for (IBond bond : tmp.bonds()) { if (bond.getStereo() == null) bond.setStereo(Stereo.UP_OR_DOWN); } String matchedPeaksString = ""; Vector<PeakMolPair> pairs = result.getFragments(); for (int k = 0; k < pairs.size(); k++) { PeakMolPair fragment = pairs.get(k); if (k == result.getFragments().size()) matchedPeaksString += fragment.getPeak().getMass() + " " + fragment.getPeak().getRelIntensity(); else matchedPeaksString += fragment.getPeak().getMass() + " " + fragment.getPeak().getRelIntensity() + " "; } if (!matchedPeaksString.equals("")) tmp.setProperty("PeaksExplained", matchedPeaksString); setOfMolecules.addAtomContainer(tmp); } try { SDFWriter writer = new SDFWriter(new FileWriter(new File( resultspath + System.getProperty("file.separator") + "results_" + sampleName + ".sdf"))); try { writer.write(setOfMolecules); } catch (CDKException e) { System.out.println("Error: Could not write results file."); } writer.close(); } catch (IOException e) { System.out.println("Error: Could not write results file."); } if (verbose) System.out.println("wrote " + setOfMolecules.getAtomContainerCount() + " molecules to " + resultspath); }
From source file:com.duroty.controller.actions.GoogieSpellAction.java
protected ActionForward doExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionMessages errors = new ActionMessages(); PostMethod post = null;//from w ww . j av a2 s . c o m try { Enumeration enumeration = request.getParameterNames(); while (enumeration.hasMoreElements()) { String name = (String) enumeration.nextElement(); String value = (String) request.getParameter(name); DLog.log(DLog.WARN, this.getClass(), name + " >> " + value); } String text = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><spellrequest textalreadyclipped=\"0\" ignoredups=\"0\" ignoredigits=\"1\" ignoreallcaps=\"1\"><text>" + request.getParameter("check") + "</text></spellrequest>"; String lang = request.getParameter("lang"); String id = request.getParameter("id"); String cmd = request.getParameter("cmd"); String url = "https://" + googleUrl + "/tbproxy/spell?lang=" + lang + "&hl=" + lang; post = new PostMethod(url); post.setRequestBody(text); post.setRequestHeader("Content-type", "text/xml; charset=ISO-8859-1"); HttpClient client = new HttpClient(); int result = client.executeMethod(post); // Display status code System.out.println("Response status code: " + result); // Display response System.out.println("Response body: "); String resp = post.getResponseBodyAsString(); System.out.println(resp); String goodieSpell = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"; Vector matches = getMatches(resp); if (matches.size() <= 0) { goodieSpell = goodieSpell + "<res id=\"" + id + "\" cmd=\"" + cmd + "\" />"; } else { goodieSpell = goodieSpell + "<res id=\"" + id + "\" cmd=\"" + cmd + "\">"; StringBuffer buffer = new StringBuffer(); for (int i = 0; i < matches.size(); i++) { if (buffer.length() > 0) { buffer.append("+"); } String aux = (String) matches.get(i); aux = aux.substring(aux.indexOf(">") + 1, aux.length()); aux = aux.substring(0, aux.indexOf("<")); aux = aux.trim().replaceAll("\\s+", "\\+"); buffer.append(aux); } goodieSpell = goodieSpell + buffer.toString() + "</res>"; } request.setAttribute("googieSpell", goodieSpell); } catch (Exception ex) { String errorMessage = ExceptionUtilities.parseMessage(ex); if (errorMessage == null) { errorMessage = "NullPointerException"; } errors.add("general", new ActionMessage(ExceptionCode.ERROR_MESSAGES_PREFIX + "general", errorMessage)); request.setAttribute("exception", errorMessage); doTrace(request, DLog.ERROR, getClass(), errorMessage); } finally { try { post.releaseConnection(); } catch (Exception e) { } } if (errors.isEmpty()) { doTrace(request, DLog.INFO, getClass(), "OK"); return mapping.findForward(Constants.ACTION_SUCCESS_FORWARD); } else { saveErrors(request, errors); return mapping.findForward(Constants.ACTION_FAIL_FORWARD); } }
From source file:edu.ku.brc.specify.tasks.subpane.security.UserAgentVSQBldr.java
/** * @param dataMap/*from w w w. j a va 2 s.c o m*/ * @param fieldNames * @return */ @Override public String buildSQL(final Map<String, Object> dataMap, final List<String> fieldNames) { Vector<Object> disciplineIds = BasicSQLUtils .querySingleCol("SELECT DisciplineID FROM discipline ORDER BY Name"); if (disciplineIds.size() > 1) { Vector<Object> divisionNames = BasicSQLUtils .querySingleCol("SELECT Name FROM discipline ORDER BY Name"); ToggleButtonChooserDlg<Object> divDlg = new ToggleButtonChooserDlg<Object>((Dialog) null, UIRegistry.getResourceString("SEC_PK_SRCH"), divisionNames, ToggleButtonChooserPanel.Type.RadioButton); divDlg.setUseScrollPane(true); divDlg.createUI(); divDlg.getCancelBtn().setVisible(false); divDlg.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); UIHelper.centerAndShow(divDlg); int inx = divisionNames.indexOf(divDlg.getSelectedObject()); disciplineID = (Integer) disciplineIds.get(inx); } else { disciplineID = (Integer) disciplineIds.get(0); } String searchName = cbx.getSearchName(); if (searchName != null) { esTblInfo = ExpressSearchConfigCache.getTableInfoByName(searchName); if (esTblInfo != null) { String sqlStr = esTblInfo.getViewSql(); return buildSearchString(dataMap, fieldNames, StringUtils.replace(sqlStr, "DSPLNID", disciplineID.toString())); } } return null; }