List of usage examples for java.util Vector get
public synchronized E get(int index)
From source file:com.vishnuvalleru.travelweatheralertsystem.MainActivity.java
private void drawMarker(LatLng point) { // Creating an instance of MarkerOptions MarkerOptions markerOptions = new MarkerOptions(); Vector<String> wVect = getWeatherInfo(point); // Adding marker on the Google Map myMap.addMarker(markerOptions.position(point).title(wVect.get(3)).snippet("Weather: " + wVect.get(2) + "\nTemperature: " + wVect.get(0) + " F" + "\nHumidity: " + wVect.get(1))).showInfoWindow(); }
From source file:evaluation.ContourPlotter.java
private void setData() { // it should be average or a day data // see Evaluation.java Vector<EvaluationResult> results = (Vector<EvaluationResult>) this.eval.getResult().clone(); EvaluationResult result = results.get(0); result.setUseAccumulatedDistance(true); result.setUseConfidence(true);//w w w . j av a2s . c om // x => index of time line // y => index of stations with virtual stations // z => value int colDataStartPoint = result.COL_DATA_START(); int rowDataStartPoint = result.ROW_DATA_START(); int xSize = result.getRowSize(1) - rowDataStartPoint; int ySize = result.getColumnSize() - colDataStartPoint; // for all data according to time series for (int x = rowDataStartPoint; x < xSize; x++) { // for all station data for (int y = colDataStartPoint; y < ySize; y++) { //System.out.println("x="+x+", y="+y+", z="+Double.parseDouble(result.get(y+colDataStartPoint, x+rowDataStartPoint).toString())); xIndex.add((double) x); yIndex.add((double) y); zValue.add(Double.parseDouble(result.get(y + colDataStartPoint, x + rowDataStartPoint).toString())); } } }
From source file:com.symbian.driver.core.controller.tasks.BuildTaskTest.java
public void testDoBuild_RBuild_NoAbldBat() { if (!iAbldBat.delete()) { fail();//from w w w . j av a 2s. c om } String lPlatform = "armv5"; String lVariant = "udeb"; iTDConfig.expects(once()).method("getPreference").with(eq(TDConfig.PLATFORM)).will(returnValue(lPlatform)); iTDConfig.expects(once()).method("getPreference").with(eq(TDConfig.VARIANT)).will(returnValue(lVariant)); iExecuteFactoryMock.expects(exactly(2)).method("createExecuteOnHost") .with(isA(File.class), isA(String.class)).will(returnValue(iIExecuteOnHostMock.proxy())); iIExecuteOnHostMock.expects(exactly(2)).method("doTask").with(eq(true), ANYTHING); String[] lFiles = { "testexecute.exe", "testexecute.dll", "file.map", "noensense.blah" }; String lReturnGetOutput = ""; for (int i = 0; i < lFiles.length; i++) { lReturnGetOutput += "epoc32\\RELEASE\\" + lPlatform.toUpperCase() + "\\" + lVariant.toUpperCase() + "\\" + lFiles[i] + "\n"; } iIExecuteOnHostMock.expects(exactly(2)).method("getOutput").will(returnValue(lReturnGetOutput)); BuildTask lBuildTask = new BuildTask((ExecuteFactory) iExecuteFactoryMock.proxy(), (TDConfig) iTDConfig.proxy()); try { Vector lTransferVector = lBuildTask.doBuild(iCWD, true, "mmp"); if (lTransferVector == null || lTransferVector.size() != 1 || ((File) lTransferVector.get(0)).getAbsolutePath().indexOf(lFiles[0]) == -1) { fail(); } } catch (TimeLimitExceededException lTimeLimitExceededException) { lTimeLimitExceededException.printStackTrace(); fail(); } catch (IOException e) { e.printStackTrace(); fail(); } catch (ParseException e) { e.printStackTrace(); fail(); } }
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;/* ww w. j av a 2s. 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); } }
From source file:com.autoparts.buyers.activity.InquiryModelActivity.java
public void setData(ResponseModel responseModel) { // {// www.ja v a 2s. c o m // "bandid":"?(int)", // "nam":"???", // "pic":"url", // "first":"?" // } Vector<HashMap<String, Object>> maps = responseModel.getMaps(); for (int i = 0; i < maps.size(); i++) { HashMap<String, Object> map = maps.get(i); String bandid = (String) map.get("bandid"); String nam = (String) map.get("nam"); String pic = (String) map.get("pic"); String first = (String) map.get("first"); CommonLetterModel commonLetterModel = new CommonLetterModel(); commonLetterModel.setUser_id(bandid); commonLetterModel.setUser_image(pic); commonLetterModel.setUser_name(nam); if (TextUtils.isEmpty(first)) { first = "#"; } commonLetterModel.setUser_key(first); mList.add(commonLetterModel); } mList = contactUtils.getListKey(mList); mIndexer = contactUtils.getmIndexer(); actionsAdapter.setData(mList); actionsAdapter.notifyDataSetChanged(); }
From source file:com.globalsight.everest.workflowmanager.WfStatePostThread.java
@SuppressWarnings("unchecked") private JSONObject getNotifyMessage(Task p_task, String p_destinationArrow, boolean isDispatch) throws Exception { String toArrowName = p_destinationArrow; JSONObject jsonObj = new JSONObject(); long jobId = p_task.getJobId(); if (isDispatch) { jsonObj.put("prevActivity", "start"); WorkflowTaskInstance firstTask = ServerProxy.getWorkflowServer() .getWorkflowTaskInstance(p_task.getWorkflow().getId(), p_task.getId()); jsonObj.put("currActivity", firstTask.getActivityDisplayName()); Vector<WorkflowArrowInstance> arrows3 = firstTask.getIncomingArrows(); for (WorkflowArrowInstance arrow3 : arrows3) { WorkflowTaskInstance srcNode = (WorkflowTaskInstance) arrow3.getSourceNode(); if (srcNode.getType() == WorkflowConstants.START) { toArrowName = arrow3.getName(); }//from w ww . ja v a2s . co m } } else { WorkflowTaskInstance nextTask = ServerProxy.getWorkflowServer().nextNodeInstances(p_task, p_destinationArrow, null); if (nextTask != null) { jsonObj.put("currActivity", nextTask.getActivityDisplayName()); } else { jsonObj.put("currActivity", "exit"); } if (StringUtils.isEmpty(p_destinationArrow)) { if (nextTask != null) { Vector<WorkflowArrowInstance> arrows = nextTask.getIncomingArrows(); if (arrows != null && arrows.size() == 1) { toArrowName = arrows.get(0).getName(); } else { for (WorkflowArrowInstance arrow : arrows) { toArrowName = determineIncomingArrow(arrow, p_task.getId()); if (toArrowName != null) break; } } } else { WorkflowTaskInstance currentTask = ServerProxy.getWorkflowServer() .getWorkflowTaskInstance(p_task.getWorkflow().getId(), p_task.getId()); Vector<WorkflowArrowInstance> arrows2 = currentTask.getOutgoingArrows(); for (WorkflowArrowInstance arrow2 : arrows2) { toArrowName = determineOutgoingArrow(arrow2); if (toArrowName != null) break; } } } jsonObj.put("prevActivity", p_task.getTaskDisplayName()); } jsonObj.put("arrowText", toArrowName); jsonObj.put("jobId", jobId); jsonObj.put("jobName", p_task.getJobName()); jsonObj.put("workflowId", p_task.getWorkflow().getIdAsLong()); jsonObj.put("sourceLocale", p_task.getSourceLocale().toString()); jsonObj.put("targetLocale", p_task.getTargetLocale().toString()); return jsonObj; }
From source file:com.duroty.lucene.bookmark.BookmarkToLuceneBookmark.java
/** * DOCUMENT ME!//from www .j ava2s.c om * * @param mime DOCUMENT ME! * * @return DOCUMENT ME! * @throws URISyntaxException * @throws IOException */ public LuceneBookmark parse(String idint, BookmarkObj bookmarkObj) throws URISyntaxException, IOException { if ((idint == null) || (bookmarkObj == null)) { return null; } LuceneBookmark luceneBookmark = new LuceneBookmark(idint); luceneBookmark.setCacheDate(new Date()); String comments = null; try { comments = factory.parse(bookmarkObj.getComments(), "text/html", Charset.defaultCharset().displayName()); } catch (Exception ex) { if (ex != null) { comments = ex.getMessage(); } } luceneBookmark.setComments(comments); if (!StringUtils.isBlank(comments)) { luceneBookmark.setNotebook(true); } String url = bookmarkObj.getUrl(); HttpContent httpContent = new HttpContent(new URL(url)); MimeType mimeType = httpContent.getContentType(); String contentType = "text/html"; if (mimeType != null) { contentType = mimeType.getBaseType(); } InputStream inputStream = httpContent.newInputStream(); if (!StringUtils.isBlank(bookmarkObj.getTitle())) { luceneBookmark.setTitle(bookmarkObj.getTitle()); } else { Vector elements = Extractor.getElements(httpContent.newInputStream(), null, "title"); Text text = null; if ((elements != null) && (elements.size() == 1)) { Element element = (Element) elements.get(0); text = (Text) element.getFirstChild(); } if (text != null) { luceneBookmark.setTitle(text.getData()); } else { luceneBookmark.setTitle(url); } } String charset = httpContent.getCharset(); if (charset == null) { charset = Charset.defaultCharset().displayName(); } String contents = null; try { contents = factory.parse(inputStream, contentType, charset); } catch (Exception ex) { if (ex != null) { contents = ex.getMessage(); } } luceneBookmark.setContents(contents); luceneBookmark.setDepth(bookmarkObj.getDepth()); luceneBookmark.setFlagged(bookmarkObj.isFlagged()); luceneBookmark.setInsertDate(new Date()); luceneBookmark.setKeywords(bookmarkObj.getKeywords()); //luceneBookmark.setNotebook(bookmarkObj.isNotebook()); luceneBookmark.setParent(String.valueOf(bookmarkObj.getParent())); luceneBookmark.setUrl(url); luceneBookmark.setUrlStr(url); return luceneBookmark; }
From source file:biblivre3.z3950.BiblivrePrefixString.java
@Override public InternalModelRootNode toInternalQueryModel(ApplicationContext ctx) throws InvalidQueryException { if (StringUtils.isBlank(queryAttr) || StringUtils.isBlank(queryTerms)) { throw new InvalidQueryException("Null prefix string"); }/* w w w . ja v a2 s. co m*/ try { if (internalModel == null) { internalModel = new InternalModelRootNode(); InternalModelNamespaceNode node = new InternalModelNamespaceNode(); node.setAttrset(DEFAULT_ATTRSET); internalModel.setChild(node); AttrPlusTermNode attrNode = new AttrPlusTermNode(); final String attrValue = "1." + queryAttr; attrNode.setAttr(DEFAULT_ATTRTYPE, new AttrValue(null, attrValue)); Vector terms = new Vector(); StringTokenizer tokenizer = new StringTokenizer(queryTerms); while (tokenizer.hasMoreElements()) { terms.add(tokenizer.nextElement()); } if (terms.size() > 1) { attrNode.setTerm(terms); } else if (terms.size() == 1) { attrNode.setTerm(terms.get(0)); } else { throw new PrefixQueryException("No Terms"); } node.setChild(attrNode); } } catch (Exception e) { throw new InvalidQueryException(e.getMessage()); } return internalModel; }
From source file:com.concursive.connect.indexer.jobs.IndexerJob.java
public void execute(JobExecutionContext context) throws JobExecutionException { SchedulerContext schedulerContext = null; try {/*from w w w.ja va2 s.c om*/ schedulerContext = context.getScheduler().getContext(); // Determine the indexer service IIndexerService indexer = IndexerFactory.getInstance().getIndexerService(); if (indexer == null) { throw (new JobExecutionException("Indexer Configuration error: No indexer defined.")); } // Determine if the indexer job can run boolean canExecute = true; ServletContext servletContext = (ServletContext) schedulerContext.get("ServletContext"); if (servletContext != null) { // If used in a servlet environment, make sure the indexer is initialized canExecute = "true".equals(servletContext.getAttribute(Constants.DIRECTORY_INDEX_INITIALIZED)); } // Execute the indexer if (canExecute) { Vector eventList = (Vector) schedulerContext.get(INDEX_ARRAY); if (eventList.size() > 0) { LOG.debug("Indexing data... " + eventList.size()); indexer.obtainWriterLock(); try { while (eventList.size() > 0) { IndexEvent indexEvent = (IndexEvent) eventList.get(0); if (indexEvent.getAction() == IndexEvent.ADD) { // The object was either added or updated indexer.indexAddItem(indexEvent.getItem()); } else if (indexEvent.getAction() == IndexEvent.DELETE) { // Delete the item and related data indexer.indexDeleteItem(indexEvent.getItem()); } eventList.remove(0); } } catch (Exception e) { LOG.error("Indexing error", e); throw new JobExecutionException(e.getMessage()); } finally { indexer.releaseWriterLock(); } } } } catch (Exception e) { LOG.error("Indexing job error", e); throw new JobExecutionException(e.getMessage()); } }
From source file:export.notes.view.to.excel.ExcelWriter.java
private void createCellStyle(int position, ViewColumn column, ViewEntry entry) throws NotesException { CellStyle cellStyle = workbook.createCellStyle(); Font font = workbook.createFont(); if (column.isFontBold()) { font.setBoldweight(Font.BOLDWEIGHT_BOLD); }/*from ww w . jav a 2 s . c o m*/ font.setItalic(column.isFontItalic()); switch (column.getFontColor()) { case RichTextStyle.COLOR_BLACK: font.setColor(HSSFColor.BLACK.index); break; case RichTextStyle.COLOR_BLUE: font.setColor(HSSFColor.BLUE.index); break; case RichTextStyle.COLOR_CYAN: font.setColor(HSSFColor.CORAL.index); break; case RichTextStyle.COLOR_DARK_BLUE: font.setColor(HSSFColor.DARK_BLUE.index); break; case RichTextStyle.COLOR_DARK_CYAN: font.setColor(HSSFColor.DARK_GREEN.index); break; case RichTextStyle.COLOR_DARK_GREEN: font.setColor(HSSFColor.DARK_GREEN.index); break; case RichTextStyle.COLOR_DARK_MAGENTA: font.setColor(HSSFColor.VIOLET.index); break; case RichTextStyle.COLOR_DARK_RED: font.setColor(HSSFColor.DARK_RED.index); break; case RichTextStyle.COLOR_DARK_YELLOW: font.setColor(HSSFColor.DARK_YELLOW.index); break; case RichTextStyle.COLOR_GRAY: font.setColor(HSSFColor.GREY_80_PERCENT.index); break; case RichTextStyle.COLOR_GREEN: font.setColor(HSSFColor.GREEN.index); break; case RichTextStyle.COLOR_LIGHT_GRAY: font.setColor(HSSFColor.GREY_50_PERCENT.index); break; case RichTextStyle.COLOR_MAGENTA: font.setColor(HSSFColor.VIOLET.index); break; case RichTextStyle.COLOR_RED: font.setColor(HSSFColor.RED.index); break; case RichTextStyle.COLOR_WHITE: font.setColor(HSSFColor.BLACK.index); break; case RichTextStyle.COLOR_YELLOW: font.setColor(HSSFColor.YELLOW.index); break; default: break; } cellStyle.setFont(font); switch (column.getAlignment()) { case ViewColumn.ALIGN_CENTER: cellStyle.setAlignment(CellStyle.ALIGN_CENTER); break; case ViewColumn.ALIGN_LEFT: cellStyle.setAlignment(CellStyle.ALIGN_LEFT); break; case ViewColumn.ALIGN_RIGHT: cellStyle.setAlignment(CellStyle.ALIGN_RIGHT); break; default: break; } @SuppressWarnings("unchecked") Vector<Object> values = entry.getColumnValues(); Object value = values.get(position); String name = value.getClass().getSimpleName(); short format = 0; if (name.contains("Double")) { //$NON-NLS-1$ XSSFDataFormat fmt = (XSSFDataFormat) workbook.createDataFormat(); switch (column.getNumberFormat()) { case ViewColumn.FMT_CURRENCY: format = fmt.getFormat(BuiltinFormats.getBuiltinFormat(6)); break; case ViewColumn.FMT_FIXED: String zero = "0"; //$NON-NLS-1$ String fixedFormat = "#0"; //$NON-NLS-1$ int digits = column.getNumberDigits(); if (digits > 0) { String n = StringUtils.repeat(zero, digits); fixedFormat = fixedFormat + "." + n; } format = fmt.getFormat(fixedFormat); break; default: format = fmt.getFormat(BuiltinFormats.getBuiltinFormat(1)); break; } } else if (name.contains("DateTime")) { //$NON-NLS-1$ XSSFDataFormat fmt = (XSSFDataFormat) workbook.createDataFormat(); switch (column.getTimeDateFmt()) { case ViewColumn.FMT_DATE: format = fmt.getFormat(BuiltinFormats.getBuiltinFormat(0xe)); break; case ViewColumn.FMT_DATETIME: format = fmt.getFormat(BuiltinFormats.getBuiltinFormat(0x16)); break; case ViewColumn.FMT_TIME: format = fmt.getFormat(BuiltinFormats.getBuiltinFormat(0x15)); break; default: format = fmt.getFormat(BuiltinFormats.getBuiltinFormat(0xe)); break; } } cellStyle.setDataFormat(format); styles.add(cellStyle); }