public class FileReader<T,S> extends AbstractReader<File,T,S>
File
as a Resource
), read each file in all the directories (nested optional); and for each file return
a n entity of type T.FileReader - transformer :FileToProductsTransformer
- Predicate filter : NULL - Lookup entitiesLookup :FileToProductLookup
- productService : xxx - Pattern extractionPattern : xxx - relatedFieldName : xxx - Transformer pathTransformer :FileToPathTransformer
- FacetMeta contentFacet : xxx - Predicate filter :FileResourceFilter
- Pattern fileNamePattern : xxx
Process.Event, Process.EventPoint
Modifier and Type | Field and Description |
---|---|
protected Iterator<File> |
fileIter |
protected boolean |
recurse
If true, will recurse through sub-folders and drill down
|
exceptions, failFast, filter, hasNext, index, messages, params, paused, resource, transformer
listeners, processState
Constructor and Description |
---|
FileReader()
Default Constructor to allow lazy initialization
If so, init() must be called by the calling API explicitly after calling BaseIterativeProcessor.setResource(Resource) |
FileReader(org.springframework.core.io.Resource resource)
The resource is the root
File path to scan/read from |
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Un-initialize reader, so that it maybe re consumed
Except for the main Resource & configuration set by Spring context
all other instance variables used will be re-set/disposed/cleared. |
Long |
getCurrentRawIndex(File file)
Get the raw index/position on the source;
BaseIterativeProcessor.getCurrentIndex() only tracks the relevant position. |
String |
getCurrentTupleIdentifier()
{
BaseIterativeProcessor.getCurrentIndex() keeps track of the number or index, but for many readers
it maybe useful to have some Name or description define the current Tuple. |
S |
getState()
Get current state of process
|
boolean |
hasNext()
True if there is another record that can be read by the parser, false implies end of parse/read
|
void |
init()
Allow lazy initialization of Reader in cases where the resource may not be known @
PostConstruct time |
boolean |
isInitialized()
Allow the calling API to determine if the reader has been initialized via
RealTimeLineReader.init() or PostConstruct phase
If not RealTimeLineReader.init() should be called upon the instance. |
boolean |
isRecurse()
If true, will recurse through sub-folders and drill down
|
protected File |
nextRecord() |
void |
resume() |
void |
resumeFromState(S state)
Resume process from the given State provided
|
void |
setRecurse(boolean recurse)
If true, will recurse through sub-folders and drill down
|
Long |
size()
Get number of tuples/records in resource
|
close, filter, getCurrentIndex, getExceptions, getFilter, getId, getMessages, getMeta, getParams, getResource, getSourceLocation, getTransformer, handleMiscException, isFailFast, isPaused, kill, next, nextTupleResult, pause, remove, setExceptions, setFailFast, setFilter, setId, setMessages, setMeta, setParams, setResource, setTransformer, stop, transform
addListener, getListeners, onChangeHandler, setListeners
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
protected boolean recurse
public FileReader(org.springframework.core.io.Resource resource)
File
path to scan/read frompublic FileReader()
init()
must be called by the calling API explicitly after calling BaseIterativeProcessor.setResource(Resource)
@PostConstruct public void init() throws IOException, Exception
RealTimeLineReader
PostConstruct
timeinit
in interface RealTimeLineReader<T>
init
in class BaseIterativeProcessor<File,T,S>
Exception
IOException
public void dispose()
RealTimeLineReader
Resource
& configuration set by Spring context
all other instance variables used will be re-set/disposed/cleared.public boolean isInitialized() throws Exception
RealTimeLineReader
RealTimeLineReader.init()
or PostConstruct
phase
RealTimeLineReader.init()
should be called upon the instance.Exception
public boolean hasNext()
RealTimeLineReader
public void resume() throws Exception
resume
in interface ControllableProcess<S>
resume
in class BaseIterativeProcessor<File,T,S>
Exception
protected File nextRecord()
nextRecord
in class BaseIterativeProcessor<File,T,S>
public Long size()
ResourceAwareRealTimeLineReader
public void resumeFromState(S state) throws Exception
ControllableProcess
Exception
public Long getCurrentRawIndex(File file)
BaseIterativeProcessor
BaseIterativeProcessor.getCurrentIndex()
only tracks the relevant position.
This method allows us to get the position on the source.
BaseIterativeProcessor.getCurrentIndex()
getCurrentRawIndex
in class BaseIterativeProcessor<File,T,S>
public S getState() throws Exception
ControllableProcess
Exception
public boolean isRecurse()
public void setRecurse(boolean recurse)
public String getCurrentTupleIdentifier()
BaseIterativeProcessor
BaseIterativeProcessor.getCurrentIndex()
keeps track of the number or index, but for many readers
it maybe useful to have some Name or description define the current Tuple.
BaseIterativeProcessor.getCurrentIndex()
getCurrentTupleIdentifier
in class BaseIterativeProcessor<File,T,S>
Copyright © 2018. All rights reserved.