List of usage examples for java.util List set
E set(int index, E element);
From source file:de.hub.cs.dbis.aeolus.queries.utils.TimestampMergerTest.java
private int mockInputs(int numberOfProducers, int numberOfTasks, boolean tsIndexOrName, int minNumberOfAttributes, int maxNumberOfAttributes) { assert numberOfProducers > 0; assert numberOfTasks != 0; int createdTasks = 0; Map<GlobalStreamId, Grouping> mapping = new HashMap<GlobalStreamId, Grouping>(); for (int i = 0; i < numberOfProducers; ++i) { String b = bolt + i;/*from w w w .j av a2s .co m*/ mapping.put(new GlobalStreamId(b, null), null); int n = numberOfTasks; if (n < 0) { n = 1 + this.r.nextInt(-numberOfTasks); } List<Integer> taskList = new LinkedList<Integer>(); for (int j = createdTasks; j < createdTasks + n; ++j) { taskList.add(new Integer(j)); } createdTasks += n; when(this.contextMock.getComponentId(anyInt())).thenReturn(b); when(this.topologyContextMock.getComponentTasks(b)).thenReturn(taskList); } if (tsIndexOrName) { when(this.contextMock.getComponentOutputFields(anyString(), anyString())).thenReturn(new Fields("ts")); } else { for (int i = 0; i < numberOfProducers; ++i) { int numberOfAttributes = minNumberOfAttributes + this.r.nextInt(maxNumberOfAttributes - minNumberOfAttributes + 1); List<String> schema = new ArrayList<String>(numberOfAttributes); for (int j = 0; j < numberOfAttributes; ++j) { schema.add("a" + j); } schema.set(this.r.nextInt(numberOfAttributes), "ts"); when(this.contextMock.getComponentOutputFields(eq(bolt + i), anyString())) .thenReturn(new Fields(schema)); } } when(this.topologyContextMock.getThisSources()).thenReturn(mapping); return createdTasks; }
From source file:io.hops.transaction.context.BlockInfoContext.java
private void updateInodeBlocks(BlockInfoContiguous newBlock) { if (newBlock == null) return;/*from ww w. j av a2 s . co m*/ List<BlockInfoContiguous> blockList = inodeBlocks.get(newBlock.getInodeId()); if (blockList != null) { int idx = blockList.indexOf(newBlock); if (idx != -1) { blockList.set(idx, newBlock); } else { blockList.add(newBlock); } } else { List<BlockInfoContiguous> list = new ArrayList<>(DEFAULT_NUM_BLOCKS_PER_INODE); list.add(newBlock); inodeBlocks.put(newBlock.getInodeId(), list); } }
From source file:hudson.scm.listtagsparameter.ListSubversionTagsParameterDefinition.java
/** * Appends the target directory to all entries in a list. I.E. 1.2 --> * branches/1.2/*from w w w . j a v a 2 s . co m*/ * * @param targetDir The target directory to append. * @param dirs List of directory entries */ private void appendTargetDir(String targetDir, List<String> dirs) { if ((targetDir != null) && (dirs != null) && (dirs.size() > 0)) { for (int i = 0; i < dirs.size(); i++) { dirs.set(i, targetDir + '/' + dirs.get(i)); } } }
From source file:org.netxilia.spi.impl.storage.db.ColumnsMapper.java
/** * save the given column. adds missing columns * // w w w. j av a 2 s. c o m * @param data * @param sheetFullName * @param column * @param properties * @throws NotFoundException */ public void saveColumn(SheetDbSession data, SheetFullName sheetFullName, ColumnData column, Collection<ColumnData.Property> properties) throws NotFoundException { DbSheetStorageInfo sheetStorageInfo = data.getStorageService().getSheetStorage(data); data.getStorageService().createColumnStorage(data, column.getIndex()); List<ColumnData> columns = loadColumns(data, sheetFullName, Range.ALL); CollectionUtils.atLeastSize(columns, column.getIndex() + 1, COLUMN_DATA_CREATOR); columns.set(column.getIndex(), column); saveColumns(data, sheetStorageInfo.getId(), columns); }
From source file:org.geoserver.wps.kvp.ExecuteKvpRequestReader.java
private BoundingBoxType parseBoundingBox(InputType it, Wps10Factory factory, IOParam param) { try {//w ww.j ava 2 s .c o m ReferencedEnvelope envelope = (ReferencedEnvelope) new org.geoserver.wfs.kvp.BBoxKvpParser() .parse(param.value); if (envelope != null) { BoundingBoxType bbox = Ows11Factory.eINSTANCE.createBoundingBoxType(); if (envelope.getCoordinateReferenceSystem() != null) { bbox.setCrs(GML2EncodingUtils.epsgCode(envelope.getCoordinateReferenceSystem())); } List<Double> min = new ArrayList<Double>(envelope.getDimension()); List<Double> max = new ArrayList<Double>(envelope.getDimension()); for (int i = 0; i < envelope.getDimension(); i++) { min.set(i, envelope.getMinimum(i)); max.set(i, envelope.getMaximum(i)); } return bbox; } else { return null; } } catch (Exception e) { throw new WPSException("Failed to parse the bounding box", e); } }
From source file:com.quigley.filesystem.FilesystemPath.java
public FilesystemPath setLast(String last) { List<String> elementsCopy = new ArrayList<String>(elements); if (elementsCopy.size() > 0) { elementsCopy.set(elementsCopy.size() - 1, last); } else {//from www . j av a2s . com elementsCopy.add(last); } FilesystemPath pathCopy = new FilesystemPath(elementsCopy); pathCopy.isAbsolute = isAbsolute; return pathCopy; }
From source file:com.blackducksoftware.integration.hub.cli.SimpleScanService.java
private void maskIndex(final List<String> cmd, final int indexToMask) { if (indexToMask > -1) { final String cmdToMask = cmd.get(indexToMask); final String[] maskedArray = new String[cmdToMask.length()]; Arrays.fill(maskedArray, "*"); cmd.set(indexToMask, StringUtils.join(maskedArray)); }/* w w w .j a va 2s.c o m*/ }
From source file:de.hub.cs.dbis.aeolus.utils.TimestampMergerTest.java
private int mockInputs(int numberOfProducers, int numberOfTasks, boolean tsIndexOrName, int minNumberOfAttributes, int maxNumberOfAttributes) { assert (numberOfProducers > 0); assert (numberOfTasks != 0); int createdTasks = 0; Map<GlobalStreamId, Grouping> mapping = new HashMap<GlobalStreamId, Grouping>(); for (int i = 0; i < numberOfProducers; ++i) { String b = bolt + i;/* ww w .ja v a 2 s. c o m*/ mapping.put(new GlobalStreamId(b, null), null); int n = numberOfTasks; if (n < 0) { n = 1 + this.r.nextInt(-numberOfTasks); } List<Integer> taskList = new LinkedList<Integer>(); for (int j = createdTasks; j < createdTasks + n; ++j) { taskList.add(new Integer(j)); } createdTasks += n; when(this.contextMock.getComponentId(anyInt())).thenReturn(b); when(this.topologyContextMock.getComponentTasks(b)).thenReturn(taskList); } if (tsIndexOrName) { when(this.contextMock.getComponentOutputFields(anyString(), anyString())).thenReturn(new Fields("ts")); } else { for (int i = 0; i < numberOfProducers; ++i) { int numberOfAttributes = minNumberOfAttributes + this.r.nextInt(maxNumberOfAttributes - minNumberOfAttributes + 1); List<String> schema = new ArrayList<String>(numberOfAttributes); for (int j = 0; j < numberOfAttributes; ++j) { schema.add("a" + j); } schema.set(this.r.nextInt(numberOfAttributes), "ts"); when(this.contextMock.getComponentOutputFields(eq(bolt + i), anyString())) .thenReturn(new Fields(schema)); } } when(this.topologyContextMock.getThisSources()).thenReturn(mapping); return createdTasks; }
From source file:de.ingrid.interfaces.csw.admin.EditIBusHarvesterController.java
private void updateAndSaveConfiguration(HarvesterConfiguration harvester) throws IOException { Configuration configuration = cProvider.getConfiguration(); List<HarvesterConfiguration> hConfigs = configuration.getHarvesterConfigurations(); hConfigs.set(((Identificable) harvester).getId(), harvester); if (log.isDebugEnabled()) { log.debug("Save configuration to: " + cProvider.getConfigurationFile()); }//from ww w .j a va 2 s . c o m cProvider.write(configuration); }
From source file:edworld.pdfreader4humans.PDFReader.java
private void addText(TextComponent component, Component container, List<String> lines) { if (container == lastContainer && consecutiveText(lastComponent, component, container)) { String lastText = lines.get(lines.size() - 1); lines.set(lines.size() - 1, joinConsecutiveText(lastText, component.getText())); } else/*from w w w . ja v a2 s . c o m*/ lines.add(component.getText()); lastContainer = container; lastComponent = component; }