List of usage examples for java.util Vector addElement
public synchronized void addElement(E obj)
From source file:com.toughra.mlearnplayer.MLearnPlayerMidlet.java
/** * Load the table of contents// w w w . j a v a 2 s.c o m * * @param hide - Do not show the table of contents form itself immediately. Do not set curFrm * */ public void loadTOC(boolean hide) { myTOC.readList(currentPackageURI + "/exetoc.xml"); //now check for feedback sounds try { FileConnection con = (FileConnection) Connector.open(currentPackageURI); String prefixes[] = new String[] { "exesfx_good", "exesfx_wrong" }; String extsn = ".mp3"; for (int i = 0; i < prefixes.length; i++) { int c = 0; Vector foundFiles = new Vector(); try { boolean moreFiles = true; do { try { String filename = prefixes[i] + c + extsn; Enumeration e = con.list(filename, true); if (e.hasMoreElements()) { //means this file exists foundFiles.addElement(filename); c++; } else { moreFiles = false; } } catch (Exception e) { moreFiles = false; } } while (moreFiles); } catch (Exception e) { System.out.println("Exception occured looking for audio files"); } finally { if (foundFiles.size() > 0) { if (prefixes[i].equals("exesfx_good")) { posFbURIs = new String[foundFiles.size()]; foundFiles.copyInto(posFbURIs); } else { negFbURIs = new String[foundFiles.size()]; foundFiles.copyInto(negFbURIs); } } } } con.close(); } catch (Exception e) { e.printStackTrace(); } TOCForm = myTOC.getForm(); myTOC.getList().addActionListener(this); if (!hide) { curFrm = TOCForm; } }
From source file:net.longfalcon.newsj.nntp.client.CustomNNTPClient.java
/*** * List all new articles added to the NNTP server since a particular * date subject to the conditions of the specified query. If no new * new news is found, a zero length array will be returned. If the * command fails, null will be returned. You must add at least one * newsgroup to the query, else the command will fail. Each String * in the returned array is a unique message identifier including the * enclosing < and >./*from ww w. j a v a 2s . co m*/ * This uses the "NEWNEWS" command. * <p> * @param query The query restricting how to search for new news. You * must add at least one newsgroup to the query. * @return An array of String instances containing the unique message * identifiers for each new article added to the NNTP server. If no * new news is found, a zero length array will be returned. If the * command fails, null will be returned. * @exception NNTPConnectionClosedException * If the NNTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send NNTP reply code 400. This exception may be caught either * as an IOException or independently as itself. * @exception IOException If an I/O error occurs while either sending a * command to the server or receiving a reply from the server. * * @see #iterateNewNews(NewGroupsOrNewsQuery) ***/ @Override public String[] listNewNews(NewGroupsOrNewsQuery query) throws IOException { if (!NNTPReply.isPositiveCompletion(newnews(query.getNewsgroups(), query.getDate(), query.getTime(), query.isGMT(), query.getDistributions()))) { return null; } Vector<String> list = new Vector<String>(); BufferedReader reader = new DotTerminatedMessageReader(_reader_); String line; try { while ((line = reader.readLine()) != null) { list.addElement(line); } } finally { reader.close(); } int size = list.size(); if (size < 1) { return new String[0]; } String[] result = new String[size]; list.copyInto(result); return result; }
From source file:com.duroty.application.bookmark.manager.BookmarkManager.java
/** * DOCUMENT ME!//ww w . j a v a 2 s . c om * * @param repositoryName DOCUMENT ME! * * @return DOCUMENT ME! * * @throws SearchException DOCUMENT ME! * @throws BookmarkException DOCUMENT ME! */ public Vector getKeywords(String repositoryName) throws SearchException, BookmarkException { Vector keywords = new Vector(); String lucenePath = ""; if (!defaultLucenePath.endsWith(File.separator)) { lucenePath = defaultLucenePath + File.separator + repositoryName + File.separator + Constants.BOOKMARK_LUCENE_BOOKMARK; } else { lucenePath = defaultLucenePath + repositoryName + File.separator + Constants.BOOKMARK_LUCENE_BOOKMARK; } Searcher searcher = null; try { searcher = BookmarkIndexer.getSearcher(lucenePath); Query query = new MatchAllDocsQuery(); Hits hits = searcher.search(query); if (hits != null) { for (int i = 0; i < hits.length(); i++) { Document doc = hits.doc(i); String[] auxk = doc.getValues(Field_keywords); if (auxk != null) { for (int j = 0; j < auxk.length; j++) { if ((auxk[j] != null) && !auxk[j].trim().equals("") && !keywords.contains(auxk[j])) { keywords.addElement(auxk[j].toLowerCase()); } } } } } Collections.sort(keywords); } catch (IOException e) { throw new SearchException(e); } catch (Exception e) { throw new SearchException(e); } finally { if (searcher != null) { try { searcher.close(); } catch (IOException e) { } } } return keywords; }
From source file:com.vsquaresystem.safedeals.location.LocationService.java
public Vector read() throws IOException { File excelFile = attachmentUtils.getDirectoryByAttachmentType(AttachmentUtils.AttachmentType.LOCATION); File[] listofFiles = excelFile.listFiles(); String fileName = excelFile + "/" + listofFiles[0].getName(); Vector cellVectorHolder = new Vector(); int type;//from w w w. j a v a2 s. c o m try { FileInputStream myInput = new FileInputStream(fileName); XSSFWorkbook myWorkBook = new XSSFWorkbook(myInput); XSSFSheet mySheet = myWorkBook.getSheetAt(0); Iterator rowIter = mySheet.rowIterator(); while (rowIter.hasNext()) { XSSFRow myRow = (XSSFRow) rowIter.next(); Iterator cellIter = myRow.cellIterator(); List list = new ArrayList(); while (cellIter.hasNext()) { XSSFCell myCell = (XSSFCell) cellIter.next(); if (myCell != null) { switch (myCell.getCellType()) { case Cell.CELL_TYPE_BOOLEAN: list.add(new DataFormatter().formatCellValue(myCell)); break; case Cell.CELL_TYPE_NUMERIC: list.add(new DataFormatter().formatCellValue(myCell)); break; case Cell.CELL_TYPE_STRING: list.add(new DataFormatter().formatCellValue(myCell)); break; case Cell.CELL_TYPE_BLANK: break; case Cell.CELL_TYPE_ERROR: list.add(new DataFormatter().formatCellValue(myCell)); break; case Cell.CELL_TYPE_FORMULA: break; } } } cellVectorHolder.addElement(list); } } catch (Exception e) { e.printStackTrace(); } return cellVectorHolder; }
From source file:net.longfalcon.newsj.nntp.client.CustomNNTPClient.java
private NewsgroupInfo[] __readNewsgroupListing() throws IOException { BufferedReader reader = new DotTerminatedMessageReader(_reader_); // Start of with a big vector because we may be reading a very large // amount of groups. Vector<NewsgroupInfo> list = new Vector<NewsgroupInfo>(2048); String line;/*from www.j a va2 s .c o m*/ try { while ((line = reader.readLine()) != null) { NewsgroupInfo tmp = __parseNewsgroupListEntry(line); if (tmp != null) { list.addElement(tmp); } else { throw new MalformedServerReplyException(line); } } } finally { reader.close(); } int size; if ((size = list.size()) < 1) { return new NewsgroupInfo[0]; } NewsgroupInfo[] info = new NewsgroupInfo[size]; list.copyInto(info); return info; }
From source file:com.duroty.application.bookmark.manager.BookmarkManager.java
/** * DOCUMENT ME!/* w w w .j a va 2 s.c om*/ * * @param repositoryName DOCUMENT ME! * * @return DOCUMENT ME! * * @throws SearchException DOCUMENT ME! * @throws BookmarkException DOCUMENT ME! */ public Vector getKeywordsNotebook(String repositoryName) throws SearchException, BookmarkException { Vector keywords = new Vector(); String lucenePath = ""; if (!defaultLucenePath.endsWith(File.separator)) { lucenePath = defaultLucenePath + File.separator + repositoryName + File.separator + Constants.BOOKMARK_LUCENE_BOOKMARK; } else { lucenePath = defaultLucenePath + repositoryName + File.separator + Constants.BOOKMARK_LUCENE_BOOKMARK; } Searcher searcher = null; try { searcher = BookmarkIndexer.getSearcher(lucenePath); Query query = SimpleQueryParser.parse("notebook:true", new KeywordAnalyzer()); Hits hits = searcher.search(query); if (hits != null) { for (int i = 0; i < hits.length(); i++) { Document doc = hits.doc(i); String[] auxk = doc.getValues(Field_keywords); if (auxk != null) { for (int j = 0; j < auxk.length; j++) { if ((auxk[j] != null) && !auxk[j].trim().equals("") && !keywords.contains(auxk[j])) { keywords.addElement(auxk[j].toLowerCase()); } } } } } Collections.sort(keywords); } catch (IOException e) { throw new SearchException(e); } catch (Exception e) { throw new SearchException(e); } finally { if (searcher != null) { try { searcher.close(); } catch (IOException e) { } } } return keywords; }
From source file:org.apache.jasper.compiler.TagLibraryInfoImpl.java
private TagInfo createTagInfo(TreeNode elem) throws JasperException { String tagName = null;//from w ww . j av a 2 s . c o m String tagClassName = null; String teiClassName = null; /* * Default body content for JSP 1.2 tag handlers (<body-content> has * become mandatory in JSP 2.0, because the default would be invalid * for simple tag handlers) */ String bodycontent = "JSP"; String info = null; String displayName = null; String smallIcon = null; String largeIcon = null; boolean dynamicAttributes = false; Vector attributeVector = new Vector(); Vector variableVector = new Vector(); Iterator list = elem.findChildren(); while (list.hasNext()) { TreeNode element = (TreeNode) list.next(); String tname = element.getName(); if ("name".equals(tname)) { tagName = element.getBody(); } else if ("tagclass".equals(tname) || "tag-class".equals(tname)) { tagClassName = element.getBody(); } else if ("teiclass".equals(tname) || "tei-class".equals(tname)) { teiClassName = element.getBody(); } else if ("bodycontent".equals(tname) || "body-content".equals(tname)) { bodycontent = element.getBody(); } else if ("display-name".equals(tname)) { displayName = element.getBody(); } else if ("small-icon".equals(tname)) { smallIcon = element.getBody(); } else if ("large-icon".equals(tname)) { largeIcon = element.getBody(); } else if ("info".equals(tname) || "description".equals(tname)) { info = element.getBody(); } else if ("variable".equals(tname)) { variableVector.addElement(createVariable(element)); } else if ("attribute".equals(tname)) { attributeVector.addElement(createAttribute(element)); } else if ("dynamic-attributes".equals(tname)) { dynamicAttributes = JspUtil.booleanValue(element.getBody()); } else if ("example".equals(tname)) { // Ignored elements } else if ("tag-extension".equals(tname)) { // Ignored } else { if (log.isWarnEnabled()) { log.warn(Localizer.getMessage("jsp.warning.unknown.element.in.tag", tname)); } } } TagExtraInfo tei = null; if (teiClassName != null && !teiClassName.equals("")) { try { Class teiClass = ctxt.getClassLoader().loadClass(teiClassName); tei = (TagExtraInfo) teiClass.newInstance(); } catch (Exception e) { err.jspError("jsp.error.teiclass.instantiation", teiClassName, e); } } TagAttributeInfo[] tagAttributeInfo = new TagAttributeInfo[attributeVector.size()]; attributeVector.copyInto(tagAttributeInfo); TagVariableInfo[] tagVariableInfos = new TagVariableInfo[variableVector.size()]; variableVector.copyInto(tagVariableInfos); TagInfo taginfo = new TagInfo(tagName, tagClassName, bodycontent, info, this, tei, tagAttributeInfo, displayName, smallIcon, largeIcon, tagVariableInfos, dynamicAttributes); return taginfo; }
From source file:com.toughra.mlearnplayer.idevices.MCQIdevice.java
/** * Constructor - setup the for, dig through the questions and answers * that are there.//from ww w.ja v a 2s . c o m * * @param host the midlet host * @param data the XML data to construct with */ public MCQIdevice(MLearnPlayerMidlet host, XmlNode data) { super(host); questions = new Vector(); answers = new Vector(); Vector dataQuestions = data.findChildrenByTagName("question", true); hadCorrect = MLearnUtils.makeBooleanArray(false, dataQuestions.size()); qAttempted = MLearnUtils.makeBooleanArray(false, dataQuestions.size()); fbackAreas = new HTMLComponent[dataQuestions.size()]; for (int i = 0; i < dataQuestions.size(); i++) { XmlNode currentNode = (XmlNode) dataQuestions.elementAt(i); if (i == 0 && currentNode.hasAttribute("audio")) { audioURL = currentNode.getAttribute("audio"); } //CDATA text section will always be the first child after question String questionTextHTML = currentNode.getTextChildContent(0); XmlNode tinCanNode = currentNode.findFirstChildByTagName("tincan", true); String tinCanId = null; String tinCanDef = null; JSONObject tcDefObj = null; if (tinCanNode != null) { tinCanDef = currentNode.findFirstChildByTagName("activitydef", true).getTextChildContent(0); tinCanId = tinCanNode.getAttribute("id"); } else { tinCanId = MLearnUtils.TINCAN_PREFIX + "/" + MLearnPlayerMidlet.getInstance().getTinCanPage() + "/mcq" + i; tcDefObj = new JSONObject(); try { String qText = MLearnUtils.removeHTMLTags(questionTextHTML); String qName = "MCQ: " + i + ": " + MLearnPlayerMidlet.getInstance().getTinCanPage(); tcDefObj.put("name", UMTinCan.makeLangMapVal("en-US", qName)); tcDefObj.put("description", UMTinCan.makeLangMapVal("en-US", qName + " " + qText)); tcDefObj.put("type", "http://adlnet.gov/expapi/activities/cmi.interaction"); tcDefObj.put("interactionType", "choice"); } catch (JSONException e) { } } QuestionItem thisItem = new QuestionItem(questionTextHTML, tinCanId, tinCanDef); questions.addElement(thisItem); Vector questionAnswers = currentNode.findChildrenByTagName("answer", true); Vector answerObjVector = new Vector(); String[][] ansInfo = new String[questionAnswers.size()][2]; int correctIndex = 0; for (int j = 0; j < questionAnswers.size(); j++) { XmlNode currentAnswer = (XmlNode) questionAnswers.elementAt(j); String answerText = currentAnswer.getTextChildContent(0); XmlNode feedbackNode = (XmlNode) currentAnswer.findChildrenByTagName("feedback", true).elementAt(0); String feedback = feedbackNode.getTextChildContent(0); String responseId = currentAnswer.getAttribute("id"); if (responseId == null) { responseId = "opt" + j; } boolean thisAnswerCorrect = currentAnswer.getAttribute("iscorrect").equals("true"); Answer answer = new Answer(answerText, thisAnswerCorrect, new Integer(i), feedback, j, responseId); answer.questionId = i; if (thisAnswerCorrect) { correctIndex = j; } if (feedbackNode.hasAttribute("audio")) { answer.fbAudio = feedbackNode.getAttribute("audio"); } answerObjVector.addElement(answer); ansInfo[j][0] = "opt" + j; ansInfo[j][1] = MLearnUtils.removeHTMLTags(answerText).trim(); totalAnswers++; } //complete definition if applicable if (tcDefObj != null) { JSONArray correctArr = new JSONArray(); correctArr.put(ansInfo[correctIndex][0]); try { tcDefObj.put("correctResponsesPattern", correctArr); JSONArray choicesArr = new JSONArray(); for (int j = 0; j < questionAnswers.size(); j++) { JSONObject thisAnsObj = new JSONObject(); thisAnsObj.put("id", ansInfo[j][0]); thisAnsObj.put("description", UMTinCan.makeLangMapVal("en-US", ansInfo[j][1])); choicesArr.put(thisAnsObj); } tcDefObj.put("choices", choicesArr); String jsonStr = tcDefObj.toString(); thisItem.tinCanDefinition = jsonStr; int x = 0; } catch (JSONException e) { } } answers.addElement(answerObjVector); questionAnswers = null; totalQuestions++; } int done = 0; }
From source file:hudson.org.apache.tools.ant.taskdefs.cvslib.ChangeLogTask.java
/** * Filter the specified entries according to an appropriate rule. * * @param entrySet the entry set to filter * @return the filtered entry set//w ww . ja v a 2s . c o m */ private CVSEntry[] filterEntrySet(final CVSEntry[] entrySet) { log("Filtering entries", Project.MSG_VERBOSE); final Vector results = new Vector(); for (int i = 0; i < entrySet.length; i++) { final CVSEntry cvsEntry = entrySet[i]; final Date date = cvsEntry.getDate(); if (date == null) { // skip dates that didn't parse. log("Filtering out " + cvsEntry + " because it has no date", Project.MSG_VERBOSE); continue; } if (null != m_start && m_start.after(date)) { //Skip dates that are too early log("Filtering out " + cvsEntry + " because it's too early compare to " + m_start, Project.MSG_VERBOSE); continue; } if (null != m_stop && m_stop.before(date)) { //Skip dates that are too late log("Filtering out " + cvsEntry + " because it's too late compare to " + m_stop, Project.MSG_VERBOSE); continue; } //if tag was specified, it takes care of branches or HEAD, because it does not go out of one. Otherwise HEAD or specified Brach should be filtered if (null == getTag() && !cvsEntry.containsBranch(branch)) { // didn't match the branch log("Filtering out " + cvsEntry + " because it didn't match the branch '" + branch + "'", Project.MSG_VERBOSE); continue; } results.addElement(cvsEntry); } final CVSEntry[] resultArray = new CVSEntry[results.size()]; results.copyInto(resultArray); return resultArray; }
From source file:com.verisign.epp.codec.launch.EPPLaunchTst.java
/** * Tests the <code>EPPLaunchUpdate</code> update command extension. The * tests include the following:<br> * <br>// ww w . jav a 2 s.com * <ol> * <li>Test update command for launch application * </ol> */ public void testLaunchUpdate() { EPPCodecTst.printStart("testLaunchUpdate"); // Create domain update command for sunrise application abc123 of // example.tld // add Vector addServers = new Vector(); addServers.addElement("ns2.example.com"); // remove Vector removeServers = new Vector(); removeServers.addElement("ns1.example.com"); EPPDomainAddRemove addItems = new EPPDomainAddRemove(addServers, null, null); EPPDomainAddRemove removeItems = new EPPDomainAddRemove(removeServers, null, null); EPPDomainUpdateCmd theCommand = new EPPDomainUpdateCmd("ABC-12345", "example.tkd", addItems, removeItems, null); theCommand.addExtension(new EPPLaunchUpdate(new EPPLaunchPhase(EPPLaunchPhase.PHASE_SUNRISE), "abc123")); EPPEncodeDecodeStats commandStats = EPPCodecTst.testEncodeDecode(theCommand); System.out.println(commandStats); EPPCodecTst.printEnd("testLaunchUpdate"); }