List of usage examples for java.util Vector size
public synchronized int size()
From source file:eionet.gdem.dcm.business.WorkqueueManager.java
/** * Adds new jobs into the workqueue by the given XML Schema * * @param user//from ww w. jav a 2 s.co m * Loggedin user name. * @param sourceUrl * Source URL of XML file. * @param schemaUrl * XML Schema URL. * @return List of job IDs. * @throws DCMException */ public List<String> addSchemaScriptsToWorkqueue(String user, String sourceUrl, String schemaUrl) throws DCMException { List<String> result = new ArrayList<String>(); try { if (!SecurityUtil.hasPerm(user, "/" + Names.ACL_WQ_PATH, "i")) { LOGGER.debug("You don't have permissions jobs into workqueue!"); throw new DCMException(BusinessConstants.EXCEPTION_AUTORIZATION_QASCRIPT_UPDATE); } } catch (DCMException e) { throw e; } catch (Exception e) { LOGGER.error("Error adding job to workqueue", e); throw new DCMException(BusinessConstants.EXCEPTION_GENERAL); } XQueryService xqE = new XQueryService(); xqE.setTrustedMode(false); try { Hashtable h = new Hashtable(); Vector files = new Vector(); files.add(sourceUrl); h.put(schemaUrl, files); Vector v_result = xqE.analyzeXMLFiles(h); if (v_result != null) { for (int i = 0; i < v_result.size(); i++) { Vector v = (Vector) v_result.get(i); result.add((String) v.get(0)); } } } catch (Exception e) { e.printStackTrace(); LOGGER.error("Error adding job to workqueue", e); throw new DCMException(BusinessConstants.EXCEPTION_GENERAL); } return result; }
From source file:presentation.webgui.vitroappservlet.StyleCreator.java
private static JFreeChart createChart(CategoryDataset dataset, Vector<String> givCategColors, Model3dStylesEntry givStyleEntry) { String capSimpleName = givStyleEntry.getCorrCapability(); capSimpleName = capSimpleName.replaceAll(Capability.dcaPrefix, ""); JFreeChart chart = ChartFactory.createBarChart("Style Legend for " + capSimpleName, // chart title null, // domain axis label null, // range axis label dataset, // data PlotOrientation.HORIZONTAL, false, // include legend true, false);//from w w w . j a va 2 s . c o m chart.getTitle().setFont(new Font("SansSerif", Font.BOLD, 14)); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // seen CategoryPlot plot = chart.getCategoryPlot(); chart.setPadding(new RectangleInsets(0, 0, 0, 0)); //new plot.setNoDataMessage("NO DATA!"); Paint[] tmpPaintCategories = { Color.white }; if (givCategColors.size() > 0) { tmpPaintCategories = new Paint[givCategColors.size()]; for (int i = 0; i < givCategColors.size(); i++) { tmpPaintCategories[i] = Color.decode(givCategColors.elementAt(i)); } } CategoryItemRenderer renderer = new CustomRenderer(tmpPaintCategories); renderer.setSeriesPaint(0, new Color(255, 204, 51)); //new plot.setRenderer(renderer); plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); //new plot.setForegroundAlpha(1f); //new plot.setBackgroundAlpha(1f); //new plot.setInsets(new RectangleInsets(5, 0, 5, 0)); //new was 5,0,5,0 plot.setRangeGridlinesVisible(false); //new was true plot.setBackgroundPaint(Color.white);//new: was (Color.lightGray); plot.setOutlinePaint(Color.white); //plot.setOrientation(PlotOrientation.HORIZONTAL); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setLowerMargin(0.04); domainAxis.setUpperMargin(0.04); domainAxis.setVisible(true); domainAxis.setLabelAngle(Math.PI / 2); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setRange(0.0, 100.0); // new: was 100 rangeAxis.setVisible(false); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:eionet.meta.DDUser.java
/** * * @return/*w ww .j ava 2 s . c o m*/ */ public String[] getUserRoles() { if (roles == null) { try { Vector v = DirectoryService.getRoles(username); roles = new String[v.size()]; for (int i = 0; i < v.size(); i++) { roles[i] = (String) v.elementAt(i); } LOGGER.debug("Found " + roles.length + " roles for user (" + username + ")"); } catch (Exception e) { LOGGER.error("Unable to get any role for loggedin user (" + username + "). DirServiceException: " + e.getMessage()); roles = new String[] {}; } } return roles; }
From source file:com.phonegap.PhoneGap.java
public static final String[] splitString(final String data, final char splitChar, final boolean allowEmpty) { Vector v = new Vector(); int indexStart = 0; int indexEnd = data.indexOf(splitChar); if (indexEnd != -1) { while (indexEnd != -1) { String s = data.substring(indexStart, indexEnd); if (allowEmpty || s.length() > 0) { v.addElement(s);//from w w w. jav a 2 s .c om } s = null; indexStart = indexEnd + 1; indexEnd = data.indexOf(splitChar, indexStart); } if (indexStart != data.length()) { // Add the rest of the string String s = data.substring(indexStart); if (allowEmpty || s.length() > 0) { v.addElement(s); } s = null; } } else { if (allowEmpty || data.length() > 0) { v.addElement(data); } } String[] result = new String[v.size()]; v.copyInto(result); v = null; return result; }
From source file:com.yahoo.messenger.data.json.PreferenceList.java
public void unserializeJSON(JSONArray a) throws JSONException { Vector v = new Vector(); // Mandatory fields for (int i = 0; i < a.length(); i++) { JSONObject o = a.getJSONObject(i); Preference c = new Preference(); c.unserializeJSON(o.getJSONObject("preference")); v.addElement(c);/*from ww w .j av a 2s.c o m*/ } preferences = new Preference[v.size()]; v.copyInto(preferences); }
From source file:org.mwc.cmap.LiveDataMonitor.views.LiveDataMonitor.java
/** * a watchable item has been selected, better show it * /*ww w . j a va 2 s . c om*/ * @param attribute * what we're going to watch */ private void storeDataset(final IAttribute attribute, final Object index) { final Vector<DataDoublet> data = attribute.getHistoricValues(index); // is there any data in it? if (data.size() == 0) { _chart.setTitle(attribute.getName()); _chart.getXYPlot().setDataset(null); } else { final TimeSeriesCollection dataset = new TimeSeriesCollection(); final TimeSeries series = new TimeSeries(attribute.getName()); for (final Iterator<DataDoublet> iterator = data.iterator(); iterator.hasNext();) { final DataDoublet thisD = (DataDoublet) iterator.next(); final Object thisVal = thisD.getValue(); if (thisVal instanceof Number) { series.addOrUpdate(new Millisecond(new Date(thisD.getTime())), (Number) thisD.getValue()); } } // did it work? if (!series.isEmpty()) { dataset.addSeries(series); _chart.getXYPlot().setDataset(dataset); _chart.setTitle(attribute.getName()); _chart.getXYPlot().getRangeAxis().setLabel(attribute.getUnits()); } } }
From source file:com.cohort.util.String2LogFactory.java
/** * Return an array containing the names of all currently defined * configuration attributes. If there are no such attributes, a zero * length array is returned.//w w w .j ava 2s. com */ public String[] getAttributeNames() { synchronized (attributes) { Vector names = new Vector(); Enumeration keys = attributes.keys(); while (keys.hasMoreElements()) { names.addElement((String) keys.nextElement()); } String results[] = new String[names.size()]; for (int i = 0; i < results.length; i++) { results[i] = (String) names.elementAt(i); } return (results); } }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.clinicalData.SelectOtherIdentifiersListener.java
@Override public void handleEvent(Event event) { //write in a new file File file = new File(this.dataType.getPath().toString() + File.separator + this.dataType.getStudy().toString() + ".columns.tmp"); try {/* w w w . j a v a2 s. c o m*/ 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"); //subject identifier Vector<File> rawFiles = ((ClinicalData) this.dataType).getRawFiles(); Vector<String> siteIds = this.setOtherIdsUI.getSiteIds(); Vector<String> visitNames = this.setOtherIdsUI.getVisitNames(); for (int i = 0; i < rawFiles.size(); i++) { //site identifier if (siteIds.elementAt(i).compareTo("") != 0) { int columnNumber = FileHandler.getHeaderNumber(rawFiles.elementAt(i), siteIds.elementAt(i)); if (columnNumber != -1) { out.write(rawFiles.elementAt(i).getName() + "\t\t" + columnNumber + "\tSITE_ID\t\t\n"); } } //visit name if (visitNames.elementAt(i).compareTo("") != 0) { int columnNumber = FileHandler.getHeaderNumber(rawFiles.elementAt(i), visitNames.elementAt(i)); if (columnNumber != -1) { out.write(rawFiles.elementAt(i).getName() + "\t\t" + columnNumber + "\tVISIT_NAME\t\t\n"); } } } try { BufferedReader br = new BufferedReader(new FileReader(((ClinicalData) this.dataType).getCMF())); String line = br.readLine(); while ((line = br.readLine()) != null) { String[] s = line.split("\t", -1); if (s[3].compareTo("SITE_ID") != 0 && s[3].compareTo("VISIT_NAME") != 0) { out.write(line + "\n"); } } br.close(); } catch (Exception e) { this.setOtherIdsUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); out.close(); } out.close(); try { String fileName = ((ClinicalData) this.dataType).getCMF().getName(); ((ClinicalData) this.dataType).getCMF().delete(); File fileDest = new File(this.dataType.getPath() + File.separator + fileName); FileUtils.moveFile(file, fileDest); ((ClinicalData) this.dataType).setCMF(fileDest); } catch (IOException ioe) { this.setOtherIdsUI.displayMessage("File error: " + ioe.getLocalizedMessage()); return; } } catch (Exception e) { this.setOtherIdsUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } this.setOtherIdsUI.displayMessage("Column mapping file updated"); WorkPart.updateSteps(); WorkPart.updateFiles(); UsedFilesPart.sendFilesChanged(dataType); }
From source file:com.yahoo.messenger.data.json.IgnoredUserList.java
public void unserializeJSON(JSONArray a) throws JSONException { Vector v = new Vector(); // Mandatory fields for (int i = 0; i < a.length(); i++) { JSONObject o = a.getJSONObject(i); IgnoredUser c = new IgnoredUser(); c.unserializeJSON(o.getJSONObject("ignoredUser")); v.addElement(c);/*from ww w.j a v a 2 s.c om*/ } ignoredUsers = new IgnoredUser[v.size()]; v.copyInto(ignoredUsers); }
From source file:com.concursive.connect.web.modules.wiki.jobs.WikiExporterJob.java
public void execute(JobExecutionContext context) throws JobExecutionException { LOG.debug("Starting job..."); SchedulerContext schedulerContext = null; Connection db = null;//from w w w. j a v a 2 s . c o m try { schedulerContext = context.getScheduler().getContext(); ApplicationPrefs prefs = (ApplicationPrefs) schedulerContext.get("ApplicationPrefs"); String fs = System.getProperty("file.separator"); db = SchedulerUtils.getConnection(schedulerContext); Vector exportList = (Vector) schedulerContext.get(WIKI_EXPORT_ARRAY); Vector availableList = (Vector) schedulerContext.get(WIKI_AVAILABLE_ARRAY); while (exportList.size() > 0) { WikiExportBean bean = (WikiExportBean) exportList.get(0); LOG.debug("Exporting a wiki (" + bean.getWikiId() + ")..."); User user = UserUtils.loadUser(bean.getUserId()); if (user == null) { user = UserUtils.createGuestUser(); } // Load the project Project thisProject = new Project(db, bean.getProjectId()); // Load the wiki Wiki wiki = new Wiki(db, bean.getWikiId(), thisProject.getId()); // See if a recent export is already available long currentDate = System.currentTimeMillis(); String destDir = prefs.get("FILELIBRARY") + user.getGroupId() + fs + "wiki" + fs + DateUtils.getDatePath(new Date(currentDate)); File destPath = new File(destDir); destPath.mkdirs(); String filename = "wiki-" + bean.getWikiId() + "-" + bean.getIncludeTitle() + "-" + bean.getFollowLinks() + "-" + WikiUtils.getLatestModifiedDate(wiki, bean.getFollowLinks(), db).getTime(); File exportFile = new File(destDir + filename); WikiExportBean existingBean = getExisting(exportFile, availableList); if (existingBean != null) { if (existingBean.getUserId() == bean.getUserId()) { // This user already has a valid file ready so a new record isn't needed LOG.debug("Exported file already exists (" + existingBean.getWikiId() + ") and was requested by this user"); } else { // Tell the new bean the existing bean's details which another user ran LOG.debug("Exported file already exists (" + existingBean.getWikiId() + ") and will be reused for this user"); bean.setExportedFile(existingBean.getExportedFile()); availableList.add(bean); } } else { // No existing PDF exists so export to PDF if (exportFile.exists()) { LOG.debug("Found the requested file in the FileLibrary (" + wiki.getId() + ")..."); } else { LOG.debug("Generating a new file for wiki (" + wiki.getId() + ")..."); // Load wiki image library dimensions (cache in future) HashMap<String, ImageInfo> imageList = WikiUtils.buildImageInfo(db, wiki.getProjectId()); // Use a context to hold a bunch of stuff WikiPDFContext pdfContext = new WikiPDFContext(thisProject, wiki, exportFile, imageList, prefs.get("FILELIBRARY"), bean); // Execute the export WikiPDFUtils.exportToFile(pdfContext, db); } bean.setExportedFile(exportFile); bean.setFileSize(exportFile.length()); availableList.add(bean); } exportList.remove(0); } } catch (Exception e) { LOG.error("WikiExporterJob Exception", e); throw new JobExecutionException(e.getMessage()); } finally { SchedulerUtils.freeConnection(schedulerContext, db); } }