List of usage examples for java.util ListIterator next
E next();
From source file:atfrogs.ox.api.OXWebDAVApi.java
/** * Returns a list of all OXResource objects of resources in resource group * with given gid./*from w w w. j a v a 2 s.co m*/ * You should not pass a pattern as gid. If done so you'll get the * list of OXResource objects of the resource group being the first search result. * * @param gid the gid of resource group requested. * @return the list of OXUser objects. * @throws OXWebDAVApiException if an error occurs during operation. */ public List getResourcesOfResGroup(String gid) throws OXWebDAVApiException { List resourceIdList; // of String List resourceList; // of OXResource ListIterator iterator; if (gid == null) return null; try { resourceIdList = this.getResourceIdsOfResGroup(gid); if (resourceIdList == null) return null; resourceList = new Vector(); iterator = resourceIdList.listIterator(); while (iterator.hasNext()) { String uid; OXResource resource; uid = (String) iterator.next(); resource = this.getOXResource(uid); resourceList.add(resource); } } catch (Exception exc) { exc.printStackTrace(); throw new OXWebDAVApiException(exc.getMessage(), exc); } return resourceList; // note: may be empty }
From source file:CopyOnWriteArrayList.java
/** * Compares the specified object with this list for equality. * Returns true if and only if the specified object is also a {@link * List}, both lists have the same size, and all corresponding pairs * of elements in the two lists are <em>equal</em>. (Two elements * <tt>e1</tt> and <tt>e2</tt> are <em>equal</em> if <tt>(e1==null ? * e2==null : e1.equals(e2))</tt>.) In other words, two lists are * defined to be equal if they contain the same elements in the same * order.// w w w . j a va 2 s .co m * * @param o the object to be compared for equality with this list * @return <tt>true</tt> if the specified object is equal to this list */ public boolean equals(Object o) { if (o == this) return true; if (!(o instanceof List)) return false; List l2 = (List) (o); if (size() != l2.size()) return false; ListIterator e1 = listIterator(); ListIterator e2 = l2.listIterator(); while (e1.hasNext()) { if (!eq(e1.next(), e2.next())) return false; } return true; }
From source file:net.lightbody.bmp.proxy.jetty.http.HttpRequest.java
/** * Get the acceptable transfer encodings. The TE field is used to construct a list of acceptable * extension transfer codings in quality order. An empty list implies that only "chunked" is * acceptable. A null list implies that no transfer coding can be applied. * //from www . j av a 2 s . c o m * If the "trailer" coding is found in the TE field, then message trailers are enabled in any * linked response. * * @return List of codings. */ public List getAcceptableTransferCodings() { if (_dotVersion < 1) return null; if (_te != null) return _te; // Decode any TE field Enumeration tenum = getFieldValues(HttpFields.__TE, HttpFields.__separators); if (tenum != null) { // Sort the list List te = HttpFields.qualityList(tenum); int size = te.size(); // Process if something there if (size > 0) { Object acceptable = null; // remove trailer and chunked items. ListIterator iter = te.listIterator(); while (iter.hasNext()) { String coding = StringUtil .asciiToLowerCase(HttpFields.valueParameters(iter.next().toString(), null)); if (!HttpFields.__Chunked.equalsIgnoreCase(coding)) { acceptable = LazyList.ensureSize(acceptable, size); acceptable = LazyList.add(acceptable, coding); } } _te = LazyList.getList(acceptable); } else _te = Collections.EMPTY_LIST; } else _te = Collections.EMPTY_LIST; return _te; }
From source file:CopyOnWriteArrayList.java
/** * Compares the specified Object with this List for equality. Returns true * if and only if the specified Object is also a List, both Lists have the * same size, and all corresponding pairs of elements in the two Lists are * <em>equal</em>. (Two elements <code>e1</code> and <code>e2</code> * are <em>equal</em> if//from w w w . j a v a 2 s .c om * <code>(e1==null ? e2==null : e1.equals(e2))</code>.) In other words, * two Lists are defined to be equal if they contain the same elements in * the same order. * <p> * This implementation first checks if the specified object is this List. If * so, it returns true; if not, it checks if the specified object is a List. * If not, it returns false; if so, it iterates over both lists, comparing * corresponding pairs of elements. If any comparison returns false, this * method returns false. If either Iterator runs out of elements before * before the other it returns false (as the Lists are of unequal length); * otherwise it returns true when the iterations complete. * * @param o * the Object to be compared for equality with this List. * @return true if the specified Object is equal to this List. */ public boolean equals(Object o) { if (o == this) return true; if (!(o instanceof List)) return false; List l2 = (List) (o); if (size() != l2.size()) return false; ListIterator e1 = listIterator(); ListIterator e2 = l2.listIterator(); while (e1.hasNext()) { Object o1 = e1.next(); Object o2 = e2.next(); if (!(o1 == null ? o2 == null : o1.equals(o2))) return false; } return true; }
From source file:annis.dao.SpringAnnisDao.java
@Override public List<AnnisBinaryMetaData> getBinaryMeta(String toplevelCorpusName, String corpusName) { List<AnnisBinaryMetaData> metaData = getJdbcTemplate().query(MetaByteHelper.SQL, metaByteHelper.getArgs(toplevelCorpusName, corpusName), MetaByteHelper.getArgTypes(), metaByteHelper);//from w ww . j av a 2 s .c o m // get the file size from the real file ListIterator<AnnisBinaryMetaData> it = metaData.listIterator(); while (it.hasNext()) { AnnisBinaryMetaData singleEntry = it.next(); File f = new File(getRealDataDir(), singleEntry.getLocalFileName()); singleEntry.setLength((int) f.length()); } return metaData; }
From source file:com.edgenius.wiki.render.filter.LinkFilter.java
/** * Accept <a> or <object file="*"> tags *///ww w . j av a2 s . c om @Override protected void replaceHTML(HTMLNode node, ListIterator<HTMLNode> nodeIter, RenderContext context) { if (node.getPair() == null || node.getAttributes() == null) { AuditLogger.error("Unexpected case: Unable to find close </a> tag"); return; } Map<String, String> atts = node.getAttributes(); if (atts.get(NameConstants.AID) != null //this is special checking for Safari browser, it remove all other attributes if it has "name" attribute. || (atts.size() == 1 && atts.containsKey(NameConstants.NAME))) { //default link filter won't have "aid" - it should be anchor return; } StringBuffer viewSb = new StringBuffer(); //whatever internal(wajax) or external link, view always parse out from tag surrounded text HTMLNode cursor = node; boolean hasStyleNode = false; for (; nodeIter.hasNext() && cursor != node.getPair(); cursor = nodeIter.next()) { if (cursor.isTextNode()) { viewSb.append(cursor.getText()); } else { hasStyleNode = true; } } LinkModel link = new LinkModel(); if ("object".equals(node.getTagName())) { //pattern ensure it must has "data" attribute String fileURL = node.getAttributes().get("data"); //must root file i.e., file:///myfile.txt if (!StringUtils.startsWith(fileURL, "file:///")) { log.warn("Object type link has invalid URL {}", fileURL); return; } fileURL = fileURL.substring(8); //if it has "/" means it is possible file:///c:/document/myfile.txt format, ignore it if (StringUtils.isBlank(fileURL) || fileURL.indexOf("/") != -1) { log.warn("Object type link is not root file {}", fileURL); return; } link.setLink(fileURL); link.setView(viewSb.toString()); link.setType(LinkModel.LINK_TO_ATTACHMENT); } else { link.fillToObject(node.getText(), viewSb.toString()); if (LinkUtil.isAttachmentLink(link.getLink())) { link.setType(LinkModel.LINK_TO_ATTACHMENT); link.setLink(StringEscapeUtils.unescapeHtml(LinkUtil.getAttachmentFile(link.getLink()))); } } //as link may contain some style mark up, such as [th%%*is is b*%%old>view], so here won't process view //but only if view==link and view is only TextNode, I will reset view TextNode at this case node.reset("[", true); //this endMarkup only include the part after "view", such as ">link@space]". The part before that "[view" is handled above StringBuffer endMarkup = new StringBuffer(); //only the link is not equals view, [view>link] needs display "view" part String escapedLink = EscapeUtil.escapeMarkupLink(link.getLink()); if (!hasStyleNode || !StringUtils.equals(link.getView(), escapedLink)) { endMarkup.append(">"); } else { //clean embedded text of link, as view == link, don't need display cursor = node.next(); for (; cursor != null && cursor != node.getPair(); cursor = cursor.next()) { cursor.reset("", true); } } if (!StringUtils.isBlank(link.getLink())) { if (link.getType() == LinkModel.LINK_TO_ATTACHMENT) { endMarkup.append("^"); } endMarkup.append(escapedLink); } if (!StringUtils.isBlank(link.getAnchor())) { endMarkup.append("#").append(link.getAnchor()); } //only different space, append spaceUname to link if (!StringUtils.isBlank(link.getSpaceUname()) && !StringUtils.equalsIgnoreCase(link.getSpaceUname(), context.getSpaceUname())) { endMarkup.append("@").append(link.getSpaceUname()); } endMarkup.append("]"); node.getPair().reset(endMarkup.toString(), true); }
From source file:com.architexa.diagrams.relo.jdt.parts.CodeUnitEditPart.java
public List<ArtifactFragment> getNonDerivedModelChildren() { List<ArtifactFragment> retVal = new ArrayList<ArtifactFragment>(getModelChildren()); ListIterator<ArtifactFragment> li = retVal.listIterator(); while (li.hasNext()) { if (li.next() instanceof DerivedArtifact) { li.remove();/*from w w w .ja v a 2 s. c o m*/ } } return retVal; }
From source file:io.bibleget.BibleGetDB.java
public boolean renewMetaData() { if (instance.connect()) { try {/* www.j a va2 s . co m*/ DatabaseMetaData dbMeta; dbMeta = instance.conn.getMetaData(); try (ResultSet rs3 = dbMeta.getTables(null, null, "METADATA", null)) { if (rs3.next()) { //System.out.println("Table METADATA exists..."); try (Statement stmt = instance.conn.createStatement()) { HTTPCaller myHTTPCaller = new HTTPCaller(); String myResponse; myResponse = myHTTPCaller.getMetaData("biblebooks"); if (myResponse != null) { JsonReader jsonReader = Json.createReader(new StringReader(myResponse)); JsonObject json = jsonReader.readObject(); JsonArray arrayJson = json.getJsonArray("results"); if (arrayJson != null) { ListIterator pIterator = arrayJson.listIterator(); while (pIterator.hasNext()) { try (Statement stmt1 = instance.conn.createStatement()) { int index = pIterator.nextIndex(); JsonArray currentJson = (JsonArray) pIterator.next(); String biblebooks_str = currentJson.toString(); //.replaceAll("\"", "\\\\\""); //System.out.println("BibleGetDB line 267: BIBLEBOOKS"+Integer.toString(index)+"='"+biblebooks_str+"'"); String stmt_str = "UPDATE METADATA SET BIBLEBOOKS" + Integer.toString(index) + "='" + biblebooks_str + "' WHERE ID=0"; //System.out.println("executing update: "+stmt_str); int update = stmt1.executeUpdate(stmt_str); //System.out.println("executeUpdate resulted in: "+Integer.toString(update)); stmt1.close(); } } } arrayJson = json.getJsonArray("languages"); if (arrayJson != null) { try (Statement stmt2 = instance.conn.createStatement()) { String languages_str = arrayJson.toString(); //.replaceAll("\"", "\\\\\""); String stmt_str = "UPDATE METADATA SET LANGUAGES='" + languages_str + "' WHERE ID=0"; int update = stmt2.executeUpdate(stmt_str); stmt2.close(); } } } myResponse = myHTTPCaller.getMetaData("bibleversions"); if (myResponse != null) { JsonReader jsonReader = Json.createReader(new StringReader(myResponse)); JsonObject json = jsonReader.readObject(); JsonObject objJson = json.getJsonObject("validversions_fullname"); if (objJson != null) { String bibleversions_str = objJson.toString(); //.replaceAll("\"", "\\\\\""); try (Statement stmt3 = instance.conn.createStatement()) { String stmt_str = "UPDATE METADATA SET VERSIONS='" + bibleversions_str + "' WHERE ID=0"; int update = stmt3.executeUpdate(stmt_str); stmt3.close(); } Set<String> versionsabbrev = objJson.keySet(); if (!versionsabbrev.isEmpty()) { String versionsabbrev_str = ""; for (String s : versionsabbrev) { versionsabbrev_str += ("".equals(versionsabbrev_str) ? "" : ",") + s; } myResponse = myHTTPCaller .getMetaData("versionindex&versions=" + versionsabbrev_str); if (myResponse != null) { jsonReader = Json.createReader(new StringReader(myResponse)); json = jsonReader.readObject(); objJson = json.getJsonObject("indexes"); if (objJson != null) { for (String name : objJson.keySet()) { JsonObjectBuilder tempBld = Json.createObjectBuilder(); JsonObject book_num = objJson.getJsonObject(name); tempBld.add("book_num", book_num.getJsonArray("book_num")); tempBld.add("chapter_limit", book_num.getJsonArray("chapter_limit")); tempBld.add("verse_limit", book_num.getJsonArray("verse_limit")); JsonObject temp = tempBld.build(); String versionindex_str = temp.toString(); //.replaceAll("\"", "\\\\\""); //add new column to METADATA table name+"IDX" VARCHAR(5000) //update METADATA table SET name+"IDX" = versionindex_str try (ResultSet rs1 = dbMeta.getColumns(null, null, "METADATA", name + "IDX")) { boolean updateFlag = false; if (rs1.next()) { //column already exists updateFlag = true; } else { try (Statement stmt4 = instance.conn .createStatement()) { String sql = "ALTER TABLE METADATA ADD COLUMN " + name + "IDX VARCHAR(5000)"; boolean colAdded = stmt4.execute(sql); if (colAdded == false) { int count = stmt4.getUpdateCount(); if (count == -1) { //System.out.println("The result is a ResultSet object or there are no more results."); } else if (count == 0) { //0 rows affected updateFlag = true; } } stmt4.close(); } } if (updateFlag) { try (Statement stmt5 = instance.conn .createStatement()) { String sql1 = "UPDATE METADATA SET " + name + "IDX='" + versionindex_str + "' WHERE ID=0"; boolean rowsUpdated = stmt5.execute(sql1); stmt5.close(); } } } } } } } } } stmt.close(); } } rs3.close(); } instance.disconnect(); } catch (SQLException ex) { Logger.getLogger(BibleGetDB.class.getName()).log(Level.SEVERE, null, ex); return false; } return true; } return false; }
From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmDb2LUW.CFCrmDb2LUWVersionTable.java
public CFCrmVersionBuff[] readDerivedByTenantIdx(CFCrmAuthorization Authorization, long TenantId) { final String S_ProcName = "readDerivedByTenantIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/*from www .java2s. c o m*/ ArrayList<String> classCodeList = new ArrayList<String>(); String classCode; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_read_verndef_cc_by_tenantidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadClassCodeByTenantIdx == null) { stmtReadClassCodeByTenantIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadClassCodeByTenantIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadClassCodeByTenantIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadClassCodeByTenantIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadClassCodeByTenantIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadClassCodeByTenantIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadClassCodeByTenantIdx.setLong(argIdx++, TenantId); resultSet = stmtReadClassCodeByTenantIdx.executeQuery(); while (resultSet.next()) { classCode = resultSet.getString(1); classCodeList.add(classCode); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } List<CFCrmVersionBuff> resultList = new LinkedList<CFCrmVersionBuff>(); ListIterator<String> classCodeIter = classCodeList.listIterator(); while (classCodeIter.hasNext()) { classCode = classCodeIter.next(); if (classCode.equals("VERN")) { CFCrmVersionBuff[] subList = readBuffByTenantIdx(Authorization, TenantId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("MJVR")) { CFCrmMajorVersionBuff[] subList = schema.getTableMajorVersion().readBuffByTenantIdx(Authorization, TenantId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("MNVR")) { CFCrmMinorVersionBuff[] subList = schema.getTableMinorVersion().readBuffByTenantIdx(Authorization, TenantId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect ClassCode \"" + classCode + "\""); } } int idx = 0; CFCrmVersionBuff[] retBuff = new CFCrmVersionBuff[resultList.size()]; Iterator<CFCrmVersionBuff> iter = resultList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); }
From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmDb2LUW.CFCrmDb2LUWRealProjectTable.java
public CFCrmRealProjectBuff[] readDerivedByTenantIdx(CFCrmAuthorization Authorization, long TenantId) { final String S_ProcName = "readDerivedByTenantIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }//from w ww .j a v a 2 s . c om ArrayList<String> classCodeList = new ArrayList<String>(); String classCode; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_read_rprjdef_cc_by_tenantidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadClassCodeByTenantIdx == null) { stmtReadClassCodeByTenantIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadClassCodeByTenantIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadClassCodeByTenantIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadClassCodeByTenantIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadClassCodeByTenantIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadClassCodeByTenantIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadClassCodeByTenantIdx.setLong(argIdx++, TenantId); resultSet = stmtReadClassCodeByTenantIdx.executeQuery(); while (resultSet.next()) { classCode = resultSet.getString(1); classCodeList.add(classCode); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } List<CFCrmRealProjectBuff> resultList = new LinkedList<CFCrmRealProjectBuff>(); ListIterator<String> classCodeIter = classCodeList.listIterator(); while (classCodeIter.hasNext()) { classCode = classCodeIter.next(); if (classCode.equals("RPRJ")) { CFCrmRealProjectBuff[] subList = readBuffByTenantIdx(Authorization, TenantId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TPRJ")) { CFCrmTopProjectBuff[] subList = schema.getTableTopProject().readBuffByTenantIdx(Authorization, TenantId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SPRJ")) { CFCrmSubProjectBuff[] subList = schema.getTableSubProject().readBuffByTenantIdx(Authorization, TenantId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect ClassCode \"" + classCode + "\""); } } int idx = 0; CFCrmRealProjectBuff[] retBuff = new CFCrmRealProjectBuff[resultList.size()]; Iterator<CFCrmRealProjectBuff> iter = resultList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); }