List of usage examples for java.util ListIterator hasNext
boolean hasNext();
From source file:com.aliyun.odps.conf.Configuration.java
@SuppressWarnings("rawtypes") private void toString(List resources, StringBuffer sb) { ListIterator i = resources.listIterator(); while (i.hasNext()) { if (i.nextIndex() != 0) { sb.append(", "); }//from w ww . j a v a 2 s . c o m sb.append(i.next()); } }
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.//from www. j av a 2s . com * * @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: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/* www. j a v a 2s . co m*/ * <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:au.edu.ausstage.networks.LookupManager.java
/** * A method to take a group of collaborators and output HTML encoded text * * @param collaborators the list of collaborators * @return the HTML encoded string *///w ww .j a va 2 s.co m private String createHTMLOutput(LinkedList<Collaborator> collaborators) { // assume that all sorting and ordering has already been carried out // loop through the list of collaborators and build the HTML ListIterator iterator = collaborators.listIterator(0); // declare helper variables StringBuilder htmlMarkup = new StringBuilder("<table id=\"key-collaborators\">"); String[] functions = null; String[] tmp = null; String firstDate = null; String lastDate = null; Collaborator collaborator = null; int count = 0; // add the header and footer htmlMarkup.append("<thead><tr><th>Name</th><th>Period</th><th>Function(s)</th><th>Count</th></tr></thead>"); htmlMarkup.append("<tfoot><tr><td>Name</td><td>Period</td><td>Function(s)</td><td>Count</td></tr></tfoot>"); while (iterator.hasNext()) { // get the collaborator collaborator = (Collaborator) iterator.next(); // start the row htmlMarkup.append("<tr id=\"key-collaborator-" + collaborator.getId() + "\">"); // add the cell with the link and name htmlMarkup.append("<th scop=\"row\"><a href=\"" + StringEscapeUtils.escapeHtml(collaborator.getUrl()) + "\" title=\"View " + collaborator.getName() + " record in AusStage\">"); htmlMarkup.append(collaborator.getName() + "</a></th>"); // build the dates tmp = DateUtils.getExplodedDate(collaborator.getFirstDate(), "-"); firstDate = DateUtils.buildDisplayDate(tmp[0], tmp[1], tmp[2]); tmp = DateUtils.getExplodedDate(collaborator.getLastDate(), "-"); lastDate = DateUtils.buildDisplayDate(tmp[0], tmp[1], tmp[2]); // add the cell with the collaboration period htmlMarkup.append("<td>" + firstDate + " - " + lastDate + "</td>"); // add the functions htmlMarkup.append("<td>" + collaborator.getFunction().replaceAll("\\|", "<br/>") + "</td>"); // add the count htmlMarkup.append("<td>" + collaborator.getCollaborations() + "</td>"); // end the row htmlMarkup.append("</tr>"); // increment the count count++; } // end the table htmlMarkup.append("</table>"); // add a comment htmlMarkup.append("<!-- Contributors listed: " + count + " -->"); return htmlMarkup.toString(); }
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 ww w . j a va 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_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"); }// w ww .ja va2 s .co m 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); }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskDb2LUW.CFAsteriskDb2LUWVersionTable.java
public CFInternetVersionBuff[] readDerivedByTenantIdx(CFSecurityAuthorization Authorization, long TenantId) { final String S_ProcName = "readDerivedByTenantIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/* w w w. ja v a 2 s . com*/ 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<CFInternetVersionBuff> resultList = new LinkedList<CFInternetVersionBuff>(); ListIterator<String> classCodeIter = classCodeList.listIterator(); while (classCodeIter.hasNext()) { classCode = classCodeIter.next(); if (classCode.equals("VERN")) { CFInternetVersionBuff[] subList = readBuffByTenantIdx(Authorization, TenantId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("MJVR")) { CFInternetMajorVersionBuff[] subList = schema.getTableMajorVersion() .readBuffByTenantIdx(Authorization, TenantId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("MNVR")) { CFInternetMinorVersionBuff[] 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; CFInternetVersionBuff[] retBuff = new CFInternetVersionBuff[resultList.size()]; Iterator<CFInternetVersionBuff> iter = resultList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); }
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 ww w . j a v a2 s. c om } } return retVal; }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskPgSql.CFAsteriskPgSqlVersionTable.java
public CFInternetVersionBuff[] readDerivedByTenantIdx(CFSecurityAuthorization Authorization, long TenantId) { final String S_ProcName = "readDerivedByTenantIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }//from ww w . j a v a 2s . com ArrayList<String> classCodeList = new ArrayList<String>(); String classCode; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); String sql = "SELECT * FROM " + schema.getLowerDbSchemaName() + ".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<CFInternetVersionBuff> resultList = new LinkedList<CFInternetVersionBuff>(); ListIterator<String> classCodeIter = classCodeList.listIterator(); while (classCodeIter.hasNext()) { classCode = classCodeIter.next(); if (classCode.equals("VERN")) { CFInternetVersionBuff[] subList = readBuffByTenantIdx(Authorization, TenantId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("MJVR")) { CFInternetMajorVersionBuff[] subList = schema.getTableMajorVersion() .readBuffByTenantIdx(Authorization, TenantId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("MNVR")) { CFInternetMinorVersionBuff[] 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; CFInternetVersionBuff[] retBuff = new CFInternetVersionBuff[resultList.size()]; Iterator<CFInternetVersionBuff> iter = resultList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskDb2LUW.CFAsteriskDb2LUWRealProjectTable.java
public CFInternetRealProjectBuff[] readDerivedByTenantIdx(CFSecurityAuthorization Authorization, long TenantId) { final String S_ProcName = "readDerivedByTenantIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/*from ww w . j a v a 2 s . 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_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<CFInternetRealProjectBuff> resultList = new LinkedList<CFInternetRealProjectBuff>(); ListIterator<String> classCodeIter = classCodeList.listIterator(); while (classCodeIter.hasNext()) { classCode = classCodeIter.next(); if (classCode.equals("RPRJ")) { CFInternetRealProjectBuff[] subList = readBuffByTenantIdx(Authorization, TenantId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TPRJ")) { CFInternetTopProjectBuff[] subList = schema.getTableTopProject().readBuffByTenantIdx(Authorization, TenantId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SPRJ")) { CFInternetSubProjectBuff[] 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; CFInternetRealProjectBuff[] retBuff = new CFInternetRealProjectBuff[resultList.size()]; Iterator<CFInternetRealProjectBuff> iter = resultList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); }