List of usage examples for java.util ListIterator nextIndex
int nextIndex();
From source file:com.adaptris.core.ServiceList.java
private ListIterator<Service> resolveNext(ListIterator<Service> current, String serviceId) { ListIterator<Service> result = current; if (!listIsSearchable) { return result; }/*from w w w. j a v a 2s. c o m*/ if (!isBlank(serviceId)) { Integer i = serviceIndex.get(serviceId); if (i != null && i >= current.nextIndex()) { result = listIterator(i); log.trace("Skipping to [{}]", serviceId); } else { log.trace("Cannot branch to [{}], no skipping", serviceId); } } return result; }
From source file:org.graylog.plugins.collector.configurations.CollectorConfigurationService.java
public CollectorConfiguration updateInputFromRequest(String id, String inputId, CollectorInput request) { CollectorConfiguration collectorConfiguration = dbCollection.findOne(DBQuery.is("_id", id)); ListIterator<CollectorInput> inputIterator = collectorConfiguration.inputs().listIterator(); while (inputIterator.hasNext()) { int i = inputIterator.nextIndex(); CollectorInput input = inputIterator.next(); if (input.inputId().equals(inputId)) { collectorConfiguration.inputs().set(i, request); }// ww w . jav a 2s.c o m } return collectorConfiguration; }
From source file:org.graylog.plugins.collector.configurations.CollectorConfigurationService.java
public CollectorConfiguration updateOutputFromRequest(String id, String outputId, CollectorOutput request) { CollectorConfiguration collectorConfiguration = dbCollection.findOne(DBQuery.is("_id", id)); ListIterator<CollectorOutput> outputIterator = collectorConfiguration.outputs().listIterator(); while (outputIterator.hasNext()) { int i = outputIterator.nextIndex(); CollectorOutput output = outputIterator.next(); if (output.outputId().equals(outputId)) { collectorConfiguration.outputs().set(i, request); }/*from ww w.j a va 2 s. c o m*/ } return collectorConfiguration; }
From source file:bzstats.chart.KillRatioHistoryChart.java
private void fillDataset(DefaultTableXYDataset dataset) { ListIterator i = period.listIterator(); GameEvent event;// ww w . ja va 2s. c om XYSeries playerseries; PeriodStats stats = new PeriodStats(); int x; float y; Iterator statiter; Map.Entry entry; PlayerStats playerstats; while (i.hasNext()) { x = i.nextIndex(); event = (GameEvent) i.next(); event.collectStats(stats); statiter = stats.getPlayerStats().entrySet().iterator(); while (statiter.hasNext()) { entry = (Map.Entry) statiter.next(); playerstats = (PlayerStats) entry.getValue(); y = playerstats.getKillRatio(); playerseries = getSeries(playerstats.getName()); if (playerseries != null) { playerseries.add(x, y); } } } // add the series to the dataset Iterator serieiter = series.entrySet().iterator(); while (serieiter.hasNext()) { entry = (Map.Entry) serieiter.next(); dataset.addSeries((XYSeries) entry.getValue()); } }
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 w w w .j a v a 2s .c o 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. * //w w w . j ava 2 s . c om * @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:com.mirth.connect.server.userutil.DatabaseConnection.java
/** * Executes a prepared INSERT/UPDATE statement on the database and returns a CachedRowSet * containing any generated keys./*w ww . j a v a 2 s . com*/ * * @param expression * The prepared statement to be executed. * @param parameters * The parameters for the prepared statement. * @return A CachedRowSet containing any generated keys. * @throws SQLException */ public CachedRowSet executeUpdateAndGetGeneratedKeys(String expression, List<Object> parameters) throws SQLException { PreparedStatement statement = null; try { statement = connection.prepareStatement(expression, Statement.RETURN_GENERATED_KEYS); 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); } statement.executeUpdate(); CachedRowSet crs = new MirthCachedRowSet(); crs.populate(statement.getGeneratedKeys()); return crs; } catch (SQLException e) { throw e; } finally { DbUtils.closeQuietly(statement); } }
From source file:org.jasig.portal.redirect.PortletRedirectionController.java
protected String getUrlString(IRedirectionUrl url, HttpServletRequest request, List<String> extraPath) { if (url instanceof ExternalRedirectionUrl) { ExternalRedirectionUrl externalUrl = (ExternalRedirectionUrl) url; StringBuffer urlStr = new StringBuffer(); urlStr.append(externalUrl.getUrl()); try {//from w w w. ja v a2 s. c om // add any additional parameters String separator = "?"; for (Map.Entry<String, String[]> param : externalUrl.getAdditionalParameters().entrySet()) { for (String value : param.getValue()) { urlStr.append(separator); urlStr.append(param.getKey()); urlStr.append("="); urlStr.append(URLEncoder.encode(value, "UTF-8")); separator = "&"; } } // add any dynamic parameters for (Map.Entry<String, String> param : externalUrl.getDynamicParameters().entrySet()) { String[] values = request.getParameterValues(param.getKey()); if (values != null) { for (String value : values) { urlStr.append(separator); urlStr.append(param.getValue()); urlStr.append("="); urlStr.append(URLEncoder.encode(value, "UTF-8")); separator = "&"; } } } if (!extraPath.isEmpty()) { List<String> paramNames = externalUrl.getPathParameters(); ListIterator<String> itt = paramNames.listIterator(); while (itt.hasNext() && !extraPath.isEmpty()) { int index = itt.nextIndex(); String param = itt.next(); String value; if (itt.hasNext()) { value = extraPath.remove(0); } else { value = StringUtils.join(extraPath, "/"); } urlStr.append(separator); urlStr.append(param); urlStr.append("="); urlStr.append(URLEncoder.encode(value, "UTF-8")); separator = "&"; } } return urlStr.toString(); } catch (UnsupportedEncodingException ex) { log.error("Unable to encode URL parameter for external service redirect", ex); return null; } } else { PortletRedirectionUrl portletUrl = (PortletRedirectionUrl) url; // create the base URL for the portlet final IPortletWindow portletWindow = this.portletWindowRegistry .getOrCreateDefaultPortletWindowByFname(request, portletUrl.getFname()); final IPortalUrlBuilder portalUrlBuilder = this.portalUrlProvider.getPortalUrlBuilderByPortletWindow( request, portletWindow.getPortletWindowId(), portletUrl.getType()); final IPortletUrlBuilder portletUrlBuilder = portalUrlBuilder.getTargetedPortletUrlBuilder(); portletUrlBuilder.setPortletMode(portletUrl.getMode()); portletUrlBuilder.setWindowState(WindowState.MAXIMIZED); // for each of the defined additional parameters, add a matching // parameter to the portlet URL for (Map.Entry<String, String[]> param : portletUrl.getAdditionalParameters().entrySet()) { portletUrlBuilder.addParameter(param.getKey(), param.getValue()); } // for each of the defined dynamic parameters, add a parameter if // the value submitted to this service was non-null for (Map.Entry<String, String> param : portletUrl.getDynamicParameters().entrySet()) { String[] values = request.getParameterValues(param.getKey()); if (values != null) { portletUrlBuilder.addParameter(param.getValue(), values); } } if (!extraPath.isEmpty()) { List<String> paramNames = portletUrl.getPathParameters(); ListIterator<String> itt = paramNames.listIterator(); while (itt.hasNext() && !extraPath.isEmpty()) { String param = itt.next(); String value; if (itt.hasNext()) { value = extraPath.remove(0); } else { value = StringUtils.join(extraPath, "/"); } if (StringUtils.isEmpty(value)) { break; } else portletUrlBuilder.addParameter(param, value); } } return portalUrlBuilder.getUrlString(); } }
From source file:com.krawler.esp.utils.ConfigReader.java
private synchronized Properties getProps() { if (properties == null) { Properties defaults = new Properties(); Properties newProps = new Properties(defaults); ListIterator i = resourceNames.listIterator(); while (i.hasNext()) { if (i.nextIndex() == 0) { // load defaults loadResource(defaults, i.next(), false); } else if (i.nextIndex() == resourceNames.size() - 1) { // load // site loadResource(newProps, i.next(), true); } else { // load intermediate loadResource(newProps, i.next(), false); }/*from w w w. j ava2 s .c o m*/ } properties = newProps; } return properties; }
From source file:io.github.swagger2markup.markup.builder.internal.confluenceMarkup.ConfluenceMarkupBuilder.java
@Override public MarkupDocBuilder tableWithColumnSpecs(List<MarkupTableColumn> columnSpecs, List<List<String>> cells) { Validate.notEmpty(cells, "cells must not be null"); documentBuilder.append(newLine);//from ww w.ja va 2 s .c o m if (columnSpecs != null && !columnSpecs.isEmpty()) { documentBuilder.append("||"); for (MarkupTableColumn column : columnSpecs) { documentBuilder.append(formatCellContent(defaultString(column.header))).append("||"); } documentBuilder.append(newLine); } for (List<String> row : cells) { documentBuilder.append(ConfluenceMarkup.TABLE_COLUMN_DELIMITER); ListIterator<String> cellIterator = row.listIterator(); while (cellIterator.hasNext()) { int cellIndex = cellIterator.nextIndex(); if (columnSpecs != null && columnSpecs.size() > cellIndex && columnSpecs.get(cellIndex).headerColumn) documentBuilder.append(ConfluenceMarkup.TABLE_COLUMN_DELIMITER); documentBuilder.append(formatCellContent(cellIterator.next())) .append(ConfluenceMarkup.TABLE_COLUMN_DELIMITER); } documentBuilder.append(newLine); } documentBuilder.append(newLine); return this; }