List of usage examples for java.util List set
E set(int index, E element);
From source file:com.bt.aloha.dao.CallInfoDaoImpl.java
public void update(CallInfo callInfo) { List<Object> paramList = createParams(callInfo); // replace version id with new one paramList.set(V_ID_POS, callInfo.generateNewVersionId()); // remove ID/*from w ww.j a v a2 s .c om*/ paramList.remove(0); // add the ID at the end of the list paramList.add(callInfo.getId()); // add old version ID String oldVersionId = callInfo.getVersionId(); paramList.add(oldVersionId); Object[] params = paramList.toArray(); int rowsUpdated = getJdbcTemplate().update(UPDATE_SQL, params, UPDATE_TYPES); if (1 != rowsUpdated) throw new ConcurrentUpdateException(callInfo.getId(), String.format("Info %s modified in database, try again", callInfo.getId())); }
From source file:de.micromata.genome.gwiki.page.impl.wiki.parser.GWikiWikiParserContext.java
public void replaceFragment(GWikiFragment search, GWikiFragment repl) { for (int i = 0; i < fragStack.size(); ++i) { if (fragStack.get(i) == search) { fragStack.set(i, repl);/*from www .j a va 2 s . c om*/ } } for (List<GWikiFragment> fl : frags) { for (int i = 0; i < fl.size(); ++i) { if (fl.get(i) == search) { fl.set(i, repl); } } } }
From source file:fr.scc.elo.controller.manager.impl.EloManagerImpl.java
private MatchMaking equilibrage(Team teamBlue, Team teamRed, EloType eloType) { List<Player> mb = teamBlue.getMembers(); List<Player> mr = teamRed.getMembers(); int nbBlue = mb.size(); int nbRed = mr.size(); int itB = 0;/*from w w w .j av a2 s. c o m*/ while (itB < nbBlue) { int itR = 0; boolean restart = false; while (!restart && itR < nbRed) { List<Player> copyBlue = new ArrayList<>(mb); List<Player> copyRed = new ArrayList<>(mr); Player tampon = copyBlue.get(itB); copyBlue.set(itB, copyRed.get(itR)); copyRed.set(itR, tampon); if (isNewTeamBetter(mb, mr, copyBlue, copyRed, eloType)) { mb = copyBlue; mr = copyRed; itB = 0; restart = true; } itR++; } if (!restart) { itB++; } else { itB = 0; } } teamBlue.setMembers(mb); teamRed.setMembers(mr); return MatchMaking.builder().type(eloType).teamBlue(teamBlue).teamRed(teamRed).build(); }
From source file:ru.org.linux.user.MemoriesDao.java
/** * get number of memories/favs for topic * @return list(0) - memories, list(1) - favs *//*from w w w.j a v a 2s.c om*/ public List<Integer> getTopicStats(int topic) { final List<Integer> res = Lists.newArrayList(0, 0); jdbcTemplate.query("SELECT watch, count(*) FROM memories WHERE topic=? GROUP BY watch", new RowCallbackHandler() { @Override public void processRow(ResultSet rs) throws SQLException { if (rs.getBoolean("watch")) { res.set(0, rs.getInt("count")); } else { res.set(1, rs.getInt("count")); } } }, topic); return res; }
From source file:com.ms.app.web.commons.statics.StaticResources.java
private void clearSuffix(List<String> list) { if (list == null || list.isEmpty()) { return;/*from w ww . j a v a 2 s . c o m*/ } int length = list.size(); for (int i = 0; i < length; i++) { String str = list.get(i); int index = str.lastIndexOf('.'); if (index != -1) { str = str.substring(0, index); list.set(i, str); } } }
From source file:com.adobe.acs.commons.reports.models.StringReportCellCSVExporter.java
@Override public String getValue(Object result) { Resource resource = (Resource) result; ReportCellValue val = new ReportCellValue(resource, property); List<String> values = new ArrayList<String>(); if (val.getValue() != null) { if (val.isArray()) { for (String value : val.getMultipleValues()) { values.add(value);/* www. j a v a 2s. c om*/ } } else { values.add(val.getSingleValue()); } } if (StringUtils.isNotBlank(format)) { for (int i = 0; i < values.size(); i++) { values.set(i, String.format(format, values.get(i))); } } return StringUtils.join(values, ";"); }
From source file:org.mifos.androidclient.main.CollectionSheetActivity.java
private void updateCustomers(CollectionSheetData collectionSheet) { List<CollectionSheetCustomer> tmpCustomer = collectionSheet.getCollectionSheetCustomer(); for (CollectionSheetCustomer customer : tmpCustomer) { if (customer.getName().equalsIgnoreCase(mSelectedCustomer.getName())) { tmpCustomer.set(tmpCustomer.indexOf(customer), mSelectedCustomer); }// w w w . j a va 2 s . c om } }
From source file:org.apache.solr.handler.component.HttpShardHandlerFactory.java
/** * Creates a list of urls for the given shard. * * @param shard the urls for the shard, separated by '|' * @return A list of valid urls (including protocol) that are replicas for the shard *///from www. j a v a 2 s . co m public List<String> buildURLList(String shard) { List<String> urls = StrUtils.splitSmart(shard, "|", true); // convert shard to URL for (int i = 0; i < urls.size(); i++) { urls.set(i, buildUrl(urls.get(i))); } return urls; }
From source file:com.github.ferstl.spring.jdbc.oracle.BatchingPreparedStatementCallback.java
private void executeUpdate(OraclePreparedStatement ops, InterruptibleBatchPreparedStatementSetter ipss, List<Integer> rowCounts) throws SQLException { ops.setExecuteBatch(this.sendBatchSize); int i = 0;/* w w w . ja v a 2 s . co m*/ while (i < ipss.getBatchSize()) { ipss.setValues(ops, i); if (ipss.isBatchExhausted(i)) { break; } rowCounts.add(ops.executeUpdate()); i++; } if (i > 0 && i % this.sendBatchSize != 0) { rowCounts.set(rowCounts.size() - 1, ops.sendBatch()); } }
From source file:com.evolveum.midpoint.model.intest.manual.CsvBackingStore.java
protected void replaceInCsv(String[] data) throws IOException { List<String> lines = Files.readAllLines(Paths.get(CSV_TARGET_FILE.getPath())); boolean found = false; for (int i = 0; i < lines.size(); i++) { String line = lines.get(i); String[] cols = line.split(","); if (cols[0].matches("\"" + data[0] + "\"")) { lines.set(i, formatCsvLine(data)); found = true;//from w w w . j a v a 2 s . c o m } } if (!found) { throw new IllegalStateException("Not found in CSV: " + data[0]); } Files.write(Paths.get(CSV_TARGET_FILE.getPath()), lines, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING); }