List of usage examples for java.util List listIterator
ListIterator<E> listIterator();
From source file:com.mirth.connect.server.userutil.DatabaseConnection.java
/** * Executes a prepared INSERT/UPDATE statement on the database and returns the row count. * /*from ww w . ja v a 2s.co m*/ * @param expression * The prepared statement to be executed. * @param parameters * The parameters for the prepared statement. * @return A count of the number of updated rows. * @throws SQLException */ public int executeUpdate(String expression, List<Object> parameters) throws SQLException { PreparedStatement statement = null; try { statement = connection.prepareStatement(expression); logger.debug("executing prepared statement:\n" + expression); ListIterator<Object> iterator = parameters.listIterator(); while (iterator.hasNext()) { int index = iterator.nextIndex() + 1; Object value = iterator.next(); logger.debug("adding parameter: index=" + index + ", value=" + value); statement.setObject(index, value); } if (statement.execute()) { return -1; } else { return statement.getUpdateCount(); } } catch (SQLException e) { throw e; } finally { DbUtils.closeQuietly(statement); } }
From source file:com.mirth.connect.server.userutil.DatabaseConnection.java
/** * Executes a prepared query on the database and returns a CachedRowSet. * //from w ww.jav a2 s . co m * @param expression * The prepared statement to be executed. * @param parameters * The parameters for the prepared statement. * @return The result of the query, as a CachedRowSet. * @throws SQLException */ public CachedRowSet executeCachedQuery(String expression, List<Object> parameters) throws SQLException { PreparedStatement statement = null; try { statement = connection.prepareStatement(expression); logger.debug("executing prepared statement:\n" + expression); ListIterator<Object> iterator = parameters.listIterator(); while (iterator.hasNext()) { int index = iterator.nextIndex() + 1; Object value = iterator.next(); logger.debug("adding parameter: index=" + index + ", value=" + value); statement.setObject(index, value); } ResultSet result = statement.executeQuery(); CachedRowSet crs = new MirthCachedRowSet(); crs.populate(result); DbUtils.closeQuietly(result); return crs; } catch (SQLException e) { throw e; } finally { DbUtils.closeQuietly(statement); } }
From source file:org.apache.fop.logging.LoggingElementListObserver.java
/** @see org.apache.fop.layoutmgr.ElementListObserver.Observer */ public void observe(List elementList, String category, String id) { Log log = LogFactory.getLog(LoggingElementListObserver.class.getName() + "." + category); if (!log.isDebugEnabled()) { return;// w ww .j ava 2 s . c o m } log.debug(" "); int len = (elementList != null ? ElementListUtils.calcContentLength(elementList) : 0); log.debug("ElementList: category=" + category + ", id=" + id + ", len=" + len + "mpt"); if (elementList == null) { log.debug("<<empty list>>"); return; } ListIterator tempIter = elementList.listIterator(); ListElement temp; while (tempIter.hasNext()) { temp = (ListElement) tempIter.next(); if (temp.isBox()) { log.debug(tempIter.previousIndex() + ") " + temp); } else if (temp.isGlue()) { log.debug(tempIter.previousIndex() + ") " + temp); } else { log.debug(tempIter.previousIndex() + ") " + temp); } if (temp.getPosition() != null) { log.debug(" " + temp.getPosition()); } } log.debug(" "); }
From source file:com.projity.pm.graphic.model.transform.NodeCacheTransformer.java
private void removeVoids(List list) { GraphicNode current;/*w w w . j ava 2s. c o m*/ for (ListIterator i = list.listIterator(); i.hasNext();) { current = (GraphicNode) i.next(); if (current.isVoid()) { i.remove(); } } }
From source file:com.projity.pm.graphic.model.transform.NodeCacheTransformer.java
private void removeSummaries(List list) { GraphicNode current;/*w w w. ja v a 2 s . c om*/ for (ListIterator i = list.listIterator(); i.hasNext();) { current = (GraphicNode) i.next(); if (current.isSummary()) { i.remove(); } } }
From source file:com.projity.pm.graphic.model.transform.NodeCacheTransformer.java
private void removeAssignments(List list) { GraphicNode current;// w w w .j a va 2 s . c o m for (ListIterator i = list.listIterator(); i.hasNext();) { current = (GraphicNode) i.next(); if (current.isAssignment()) { i.remove(); } } }
From source file:de.ingrid.iplug.dscmapclient.index.producer.PlugDescriptionConfiguredWmsRecordSetProducer.java
/** * /* ww w. j av a2 s. com*/ * create the ids form an xml file invokes private method readXmlFIle takes * the received NodeList, parses it into a list which serves as the iterator * or better iteratedlist * */ private void createRecordIdsFromXmlFile() { List<String> recordIds = new ArrayList<String>(); NodeList nl = null; nl = readXmlFile(this.xmlFilePath, idTag); for (int i = 0; i < nl.getLength(); i++) { if (!recordIds.contains(nl.item(i).getTextContent())) recordIds.add(nl.item(i).getTextContent()); } statusProvider.addState("FETCH", "Found " + nl.getLength() + " records in mapclient configuration."); recordIdIterator = recordIds.listIterator(); }
From source file:com.clemot.julian.easylib.EasyActivity.java
public Fragment getLastFragment() { List<Fragment> fragmentList = getFragments(); Fragment returnFrag = null;/* ww w .ja v a 2 s .co m*/ if (fragmentList != null && fragmentList.size() > 0) { Iterator<Fragment> itFrag = fragmentList.listIterator(); while (itFrag.hasNext()) { Fragment f = itFrag.next(); if (null != f) { returnFrag = f; } } } return returnFrag; }
From source file:de.ingrid.iplug.dsc.index.producer.PlugDescriptionConfiguredDatabaseRecordSetProducer.java
private void createRecordIdsFromDatabase() { try {//from ww w . ja va 2 s .c o m List<String> recordIds = new ArrayList<String>(); if (log.isDebugEnabled()) { log.debug("SQL: " + recordSql); } PreparedStatement ps = connection.prepareStatement(recordSql); try { ResultSet rs = ps.executeQuery(); try { while (rs.next()) { recordIds.add(rs.getString(1)); } recordIdIterator = recordIds.listIterator(); numRecords = recordIds.size(); } catch (Exception e) { throw e; } finally { rs.close(); } } catch (Exception e) { throw e; } finally { ps.close(); } } catch (Exception e) { log.error("Error creating record ids.", e); } }
From source file:edu.cornell.mannlib.vedit.controller.BaseEditController.java
public List<Option> getSortedList(HashMap<String, Option> hashMap, List<Option> optionList, VitroRequest vreq) { class ListComparator implements Comparator<String> { Collator collator;//from w w w .j ava2 s . c o m public ListComparator(Collator collator) { this.collator = collator; } @Override public int compare(String str1, String str2) { return collator.compare(str1, str2); } } List<String> bodyVal = new ArrayList<String>(); List<Option> options = new ArrayList<Option>(); Iterator<Option> itr = optionList.iterator(); while (itr.hasNext()) { Option option = itr.next(); hashMap.put(option.getBody(), option); bodyVal.add(option.getBody()); } Collections.sort(bodyVal, new ListComparator(vreq.getCollator())); ListIterator<String> itrStr = bodyVal.listIterator(); while (itrStr.hasNext()) { options.add(hashMap.get(itrStr.next())); } return options; }