/** * Use the delegate to read the next item, jump to next resource if current one is exhausted. Items are appended to * the buffer. * * @return next item from input */ private T readNextItem() throws Exception { T item = readFromDelegate(); while (item == null) { currentResource++; if (currentResource >= resources.length) { return null; } delegate.close(); delegate.setResource(resources[currentResource]); delegate.open(new ExecutionContext()); item = readFromDelegate(); } return item; }
private T readFromDelegate() throws Exception { T item = delegate.read(); if(item instanceof ResourceAware){ ((ResourceAware) item).setResource(getCurrentResource()); } return item; }
/** * Store the current resource index and position in the resource. */ @Override public void update(ExecutionContext executionContext) throws ItemStreamException { super.update(executionContext); if (saveState) { executionContext.putInt(getExecutionContextKey(RESOURCE_KEY), currentResource); delegate.update(executionContext); } }
/** * Reads the next item, jumping to next resource if necessary. */ @Override public T read() throws Exception, UnexpectedInputException, ParseException { if (noInput) { return null; } // If there is no resource, then this is the first item, set the current // resource to 0 and open the first delegate. if (currentResource == -1) { currentResource = 0; delegate.setResource(resources[currentResource]); delegate.open(new ExecutionContext()); } return readNextItem(); }
@Override public T read() throws Exception { final Resource currentResource = resourceLocator.getResource(executionContext); if (previousResource == null || !previousResource.equals(currentResource)) { delegate.close(); delegate.setResource(currentResource); delegate.open(executionContext); previousResource = currentResource; } return delegate.read(); }
private Map<Long, T> readContent() throws Exception { Map<Long, T> result = new HashMap<>(); try { reader.open(executionContext); int i = 0; for (T item = reader.read(); item != null; item = reader.read()) { Long index = null; if (item instanceof ItemIndexAware) { index = ((ItemIndexAware) item).getIndex(); LOGGER.trace("Retrieving existing index={}", index); } if (index == null) { index = new Long(i++); LOGGER.trace("Setting new index={}", index); } result.put(index, item); LOGGER.debug("Read content : line={}, item={}", index, item); } } finally { reader.close(); } return result; }
/** * Close the {@link #setDelegate(ResourceAwareItemReaderItemStream)} reader and reset instance variable values. */ @Override public void close() throws ItemStreamException { super.close(); if(!this.noInput) { delegate.close(); } noInput = false; }
private void initializeStreams() throws Exception { if (createBackupFile) { outputResource = new FileSystemResource(File.createTempFile(resource.getFilename(), ".tmp", resource.getFile().getParentFile())); } else { outputResource = resource; } reader.setResource(resource); writer.setResource(outputResource); }
delegate.setResource(resources[currentResource]); delegate.open(executionContext);
@Override public void close() throws ItemStreamException { delegate.close(); }
/** * Use the delegate to read the next item, jump to next resource if current one is exhausted. Items are appended to * the buffer. * * @return next item from input */ private T readNextItem() throws Exception { T item = readFromDelegate(); while (item == null) { currentResource++; if (currentResource >= resources.length) { return null; } delegate.close(); delegate.setResource(resources[currentResource]); delegate.open(new ExecutionContext()); item = readFromDelegate(); } return item; }
/** * Reads the next item, jumping to next resource if necessary. */ @Override public T read() throws Exception, UnexpectedInputException, ParseException { if (noInput) { return null; } // If there is no resource, then this is the first item, set the current // resource to 0 and open the first delegate. if (currentResource == -1) { currentResource = 0; delegate.setResource(resources[currentResource]); delegate.open(new ExecutionContext()); } return readNextItem(); }
/** * Close the {@link #setDelegate(ResourceAwareItemReaderItemStream)} reader and reset instance variable values. */ @Override public void close() throws ItemStreamException { super.close(); if(!this.noInput) { delegate.close(); } noInput = false; }
private T readFromDelegate() throws Exception { T item = delegate.read(); if(item instanceof ResourceAware){ ((ResourceAware) item).setResource(getCurrentResource()); } return item; }
/** * Store the current resource index and position in the resource. */ @Override public void update(ExecutionContext executionContext) throws ItemStreamException { super.update(executionContext); if (saveState) { executionContext.putInt(getExecutionContextKey(RESOURCE_KEY), currentResource); delegate.update(executionContext); } }
delegate.setResource(resources[currentResource]); delegate.open(executionContext);