List of usage examples for java.util Vector size
public synchronized int size()
From source file:eionet.meta.exports.ods.Ods.java
/** * Prepares for table.//from ww w . j a va 2 s . c o m * * @param tbl * table * @throws java.lang.Exception * when operation fails */ protected void prepareTbl(DsTable tbl) throws Exception { Table tableTag = new Table(); tableTag.setTableName(tbl.getIdentifier()); tableTag.setSchemaURLTrailer("TBL" + tbl.getID()); Vector elms = searchEngine.getDataElements(null, null, null, null, tbl.getID()); for (int i = 0; elms != null && i < elms.size(); i++) { DataElement elm = (DataElement) elms.get(i); String defaultCellStyleName = getDefaultCellStyleName(elm); tableTag.addTableColumn(defaultCellStyleName); tableTag.addColumnHeader(elm.getIdentifier()); } addTable(tableTag); }
From source file:edu.umn.cs.spatialHadoop.CommandLineArguments.java
public Point[] getPoints() { Vector<Point> points = new Vector<Point>(); for (String arg : args) { if (arg.startsWith("point:")) { Point point = new Point(); point.fromText(new Text(arg.substring(arg.indexOf(':') + 1))); points.add(point);/*ww w.java 2 s . c o m*/ } } return points.toArray(new Point[points.size()]); }
From source file:com.globalsight.util.file.XliffFileUtil.java
/** * Process the files if the source file is with XLZ file format * //from w w w.j a v a 2s . c om * @param p_workflow * * @author Vincent Yan, 2011/01/27 * @version 1.1 * @since 8.1 */ public static void processXLZFiles(Workflow p_workflow) { if (p_workflow == null || p_workflow.getAllTargetPages().size() == 0) return; TargetPage tp = null; String externalId = ""; String tmp = "", exportDir = ""; String sourceFilename = ""; String sourceDir = "", targetDir = ""; File sourceFile = null; File sourcePath = null, targetPath = null; ArrayList<String> xlzFiles = new ArrayList<String>(); try { Vector<TargetPage> targetPages = p_workflow.getAllTargetPages(); String baseCxeDocDir = AmbFileStoragePathUtils.getCxeDocDirPath().concat(File.separator); Job job = p_workflow.getJob(); String companyId = String.valueOf(job.getCompanyId()); String companyName = CompanyWrapper.getCompanyNameById(companyId); if (CompanyWrapper.SUPER_COMPANY_ID.equals(CompanyWrapper.getCurrentCompanyId()) && !CompanyWrapper.SUPER_COMPANY_ID.equals(companyId)) { baseCxeDocDir += companyName + File.separator; } int index = -1; ArrayList<String> processed = new ArrayList<String>(); for (int i = 0; i < targetPages.size(); i++) { tp = (TargetPage) targetPages.get(i); externalId = FileUtil.commonSeparator(tp.getSourcePage().getExternalPageId()); index = externalId.lastIndexOf(SEPARATE_FLAG + File.separator); if (index != -1) { tmp = externalId.substring(0, index); sourceFilename = baseCxeDocDir + tmp; sourceFile = new File(sourceFilename); if (sourceFile.exists() && sourceFile.isFile()) { // Current file is a separated file from big Xliff file // with // multiple <File> tags externalId = tmp; } } if (processed.contains(externalId)) continue; else processed.add(externalId); if (isXliffFile(externalId)) { tmp = externalId.substring(0, externalId.lastIndexOf(File.separator)); sourceFilename = baseCxeDocDir + tmp + XliffFileUtil.XLZ_EXTENSION; sourceFile = new File(sourceFilename); if (sourceFile.exists() && sourceFile.isFile()) { // source file is with xlz file format exportDir = tp.getExportSubDir(); if (exportDir.startsWith("\\") || exportDir.startsWith("/")) exportDir = exportDir.substring(1); targetDir = baseCxeDocDir + exportDir + tmp.substring(tmp.indexOf(File.separator)); if (!xlzFiles.contains(targetDir)) xlzFiles.add(targetDir); // Get exported target path targetPath = new File(targetDir); // Get source path sourceDir = baseCxeDocDir + tmp; sourcePath = new File(sourceDir); // Copy all files extracted from XLZ file from source // path to exported target path // Because Xliff files can be exported by GS // automatically, then ignore them and // just copy the others file to target path File[] files = sourcePath.listFiles(); for (File f : files) { if (f.isDirectory()) continue; if (isXliffFile(f.getAbsolutePath())) continue; org.apache.commons.io.FileUtils.copyFileToDirectory(f, targetPath); } } } } // Generate exported XLZ file and remove temporary folders for (int i = 0; i < xlzFiles.size(); i++) { targetDir = xlzFiles.get(i); targetPath = new File(targetDir); File xlzFile = new File(targetDir + XLZ_EXTENSION); if (!targetPath.exists() || xlzFile.exists()) { continue; } ZipIt.addEntriesToZipFile(xlzFile, targetPath.listFiles(), true, ""); } } catch (Exception e) { logger.error("Error in WorkflowManagerLocal.processXLZFiles. "); logger.error(e.getMessage(), e); } }
From source file:edu.caltechUcla.sselCassel.projects.jMarkets.server.control.MonitorServ.java
/** Log the given message onto the MonitorTransmitters of all sessions */ public void logMessage(String logStr, int level, String className) { Enumeration sessionIds = sessionMonitors.keys(); while (sessionIds.hasMoreElements()) { Integer key = (Integer) sessionIds.nextElement(); Vector monitors = (Vector) sessionMonitors.get(key); for (int i = 0; i < monitors.size(); i++) { MonitorTransmitter ui = (MonitorTransmitter) monitors.get(i); try { ui.addLogMessage(logStr, level, className); } catch (MonitorDisconnectedException e) { disconnectMonitor(key.intValue(), ui); log.error(// ww w . j a v a2s . co m "Failed to establish connection with MonitorTransmitter -- disconnecting from failed monitor"); } } } }
From source file:imapi.IMAPIClass.java
void printSourceInfo(SourceDataHolder sourceInfo) { int counter = 0; Vector<String> fileInstances = new Vector<String>(sourceInfo.keySet()); Collections.sort(fileInstances); //System.out.println("Found " + fileInstances.size() + " instances in all \"\"SOURCE\"\" input files."); for (int i = 0; i < fileInstances.size(); i++) { String filename = fileInstances.get(i); Vector<String> uris = new Vector<String>(sourceInfo.get(filename).keySet()); Collections.sort(uris);// w ww. j av a2 s . c o m for (int j = 0; j < uris.size(); j++) { counter++; String uri = uris.get(j); SequencesVector allSeqData = sourceInfo.get(filename).get(uri); System.out.println("\r\n" + counter + ". " + uri + "\t\tin source: " + filename); for (int k = 0; k < allSeqData.size(); k++) { SequenceData currentSeq = allSeqData.get(k); System.out .println("\tData found on sequence: " + (currentSeq.getSchemaInfo().getPositionID() + 1) + " mnemonic: " + currentSeq.getSchemaInfo().getMnemonic() + " with weight: " + currentSeq.getSchemaInfo().getWeight()); Hashtable<String, String> parameterTypes = currentSeq.getSchemaInfo() .getAllQueryStepParameters(); String[] parameterNames = currentSeq.getSchemaInfo().getSortedParameterNamesCopy(); for (int paramStep = 0; paramStep < parameterNames.length; paramStep++) { String paramName = parameterNames[paramStep]; String paramType = parameterTypes.get(paramName); //System.out.println(paramName); //String type //String stepName = currentSeq.getSchemaInfo().getQuerySteps().get(step).getParameterName(); //String type = currentSeq.getSchemaInfo().getQuerySteps().get(step).getParameterType(); Vector<DataRecord> vals = currentSeq.getValuesOfKey(paramName); for (int valIndex = 0; valIndex < vals.size(); valIndex++) { DataRecord rec = vals.get(valIndex); String printStr = "\t\t" + paramName + ": " + paramType + " -->\t" + rec.toString(); System.out.println(printStr); } } } } } }
From source file:mypackage.FeedlyAPI.java
public void markOneOrMultipleArticlesAsRead(Vector entryIds) throws Exception { // Mark one or multiple articles as read // POST /v3/markers if (entryIds.size() == 0) { throw new Exception("FeedlyAPI::markOneOrMultipleArticlesAsRead()0"); }/*from ww w . j av a2s .c o m*/ // JSONObject body = new JSONObject(); try { body.put("action", "markAsRead"); body.put("type", "entries"); body.put("entryIds", entryIds); } catch (JSONException e) { throw new Exception("FeedlyAPI::markOneOrMultipleArticlesAsRead()1"); } // O???Aw???s?B for (int i = 0; i < NUM_OF_TRIALS; i++) { try { doPost(getEndpoint("/v3/markers"), body); return; } catch (IOException e) { continue; } catch (Exception e) { continue; } } throw new Exception("FeedlyAPI::markOneOrMultipleArticlesAsRead()2"); }
From source file:edu.cornell.med.icb.geo.tools.Affy2InsightfulMiner.java
private void readInputList(final String inputListFilename) throws IOException { final Vector<String> names = new Vector<String>(); final Vector<String> ids = new Vector<String>(); String line;/* ww w. jav a 2 s . c o m*/ final BufferedReader br = new BufferedReader(new FileReader(inputListFilename)); while ((line = br.readLine()) != null) { final String[] tokens = line.split("\t"); names.add(tokens[0]); ids.add(tokens[1]); } if (names.size() != ids.size()) { System.err.println("Error reading input file list (" + inputListFilename + "): the number of identifiers does not match the number of filenames."); System.exit(1); } final int datasetSize = ids.size(); filenames = new String[datasetSize]; sampleIdentifiers = new String[ids.size()]; for (int i = 0; i < filenames.length; i++) { filenames[i] = names.get(i); sampleIdentifiers[i] = ids.get(i); } }
From source file:com.duroty.application.bookmark.actions.BookmarkExtractorAction.java
protected ActionForward doExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionMessages errors = new ActionMessages(); try {// www. ja va2 s. c om boolean isMultipart = FileUpload.isMultipartContent(request); if (isMultipart) { Vector links = null; //Parse the request List items = diskFileUpload.parseRequest(request); //Process the uploaded items Iterator iter = items.iterator(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); if (!item.isFormField()) { String contents = IOUtils.toString(item.getInputStream()); links = Extractor.getLinks(contents, null); } } if ((links != null) && (links.size() > 0)) { Bookmark bookmarkInstance = getBookmarkInstance(request); bookmarkInstance.addBookmarks(links); } } else { errors.add("general", new ActionMessage(ExceptionCode.ERROR_MESSAGES_PREFIX + "general", "The form is null")); request.setAttribute("exception", "The form is null"); doTrace(request, DLog.ERROR, getClass(), "The form is null"); ; } } 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); } 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:com.ricemap.spateDB.util.CommandLineArguments.java
public Point3d[] getPoints() { Vector<Point3d> points = new Vector<Point3d>(); for (String arg : args) { if (arg.startsWith("point:")) { Point3d point = new Point3d(); point.fromText(new Text(arg.substring(arg.indexOf(':') + 1))); points.add(point);/*from www. j a v a2 s.c o m*/ } } return points.toArray(new Point3d[points.size()]); }
From source file:kenh.xscript.impl.BaseElement.java
private int invokeChildren(int i) throws UnsupportedScriptException { Vector<Element> children = this.getChildren(); int r = NONE; for (; i < children.size(); i++) { Element child = children.get(i); r = child.invoke();//from w w w . j ava 2s .c om if (r != NONE) break; } // If EXCEPTION is return, find Catch element to handle. if (r == EXCEPTION) { for (; i < children.size(); i++) { Element child = children.get(i); if (child instanceof kenh.xscript.elements.Catch) { r = ((kenh.xscript.elements.Catch) child).processException(); break; } } if (r != NONE) return r; else { // If Catch element return NONE, go on with children after Catch element. invokeChildren(i); } } return r; }