public abstract class DataReader extends DataEndpoint
readImpl()
,
however, most subclasses will also override DataEndpoint.open()
and DataEndpoint.close()
.DataEndpoint.State
Modifier and Type | Field and Description |
---|---|
protected FieldLineage |
fieldLineage |
protected RecordLineage |
recordLineage |
lastRecord, PRODUCT, PRODUCT_VERSION, VENDOR, XML_INPUT_FACTORY_KEY
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZE
id, log, name, TIMESTAMP_FORMAT
Constructor and Description |
---|
DataReader() |
Modifier and Type | Method and Description |
---|---|
DataException |
addExceptionProperties(DataException exception)
Adds this endpoint's current state to a
DataException . |
protected Record |
addLineage(Record record) |
int |
available()
Returns the number of records that can probably be read without blocking.
|
int |
getBufferSize()
Returns the number of records in this
DataReader s buffer. |
DataReader |
getNestedEndpoint()
Returns the
Endpoint held inside this one or null if there isn't one. |
DataReader |
getNestedReader()
Returns the
DataReader held inside this one or null if there isn't one. |
DataReader |
getRootEndpoint()
Returns the deepest, nested
Endpoint held inside this one, otherwise this instance is returned if
there aren't any nested Endpoint s. |
DataReader |
getRootReader()
Returns the deepest, nested
DataReader held inside this one, otherwise this instance is returned if
there aren't any nested DataReader s. |
boolean |
isExhausted()
Returns
true if this stream has already returned a null indicating that no further reads are possible. |
boolean |
isLineageSupported() |
boolean |
isSaveLineage() |
Record |
peek(int index)
Looks ahead to return the next record at the specified index without reading it or
null if one does not exist. |
protected Record |
pop()
Removes and returns the next record in this
DataReader s buffer or null if it is empty. |
void |
push(Record record)
Adds a record to this
DataReader s buffer. |
Record |
read()
Reads the next record from this
DataReader and increases the record-count by 1. |
protected abstract Record |
readImpl()
Overridden by subclasses to read the next record from this
DataReader . |
DataReader |
setSaveLineage(boolean saveLineage) |
int |
skip(int count)
Skips over the specified number of records.
|
close, decrementRecordCount, enableJmx, getLastRecord, getRecordCount, getRecordCountAsBigInteger, getRecordCountAsString, incrementRecordCount, isRecordCountBigInteger, open, resetRecordCount, toString
addElapsedtime, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime, setDescription
protected final RecordLineage recordLineage
protected final FieldLineage fieldLineage
public DataReader getNestedEndpoint()
Endpoint
Endpoint
held inside this one or null
if there isn't one.getNestedEndpoint
in class DataEndpoint
public DataReader getRootEndpoint()
Endpoint
Endpoint
held inside this one, otherwise this instance is returned if
there aren't any nested Endpoint
s.getRootEndpoint
in class DataEndpoint
public DataReader getNestedReader()
DataReader
held inside this one or null
if there isn't one.public DataReader getRootReader()
DataReader
held inside this one, otherwise this instance is returned if
there aren't any nested DataReader
s.public int available() throws DataException
DataException
public final int getBufferSize()
DataReader
s buffer.public boolean isExhausted()
true
if this stream has already returned a null
indicating that no further reads are possible.public void push(Record record)
DataReader
s buffer. Records in the buffer will be returned
by read()
before attempting to read from the underlying implementation.read()
protected Record pop()
DataReader
s buffer or null
if it is empty.push(Record)
public final Record peek(int index)
null
if one does not exist.
The buffer of look ahead records are added to this DataReader
using push(Record)
.index
- specifies how far to look ahead (0 refers to the next record, 1--to the one after that, etc.)null
if one does not existprotected abstract Record readImpl() throws Throwable
DataReader
. The default
implementation of read()
now insures that this method will not be called again after it returns
a null
.
If no record is available, null
will be returned.
Throwable
public Record read() throws DataException
DataReader
and increases the record-count by 1.
This method will first read any pushed (push(Record)
) records before reading from the underlying source.
If no record is available, null
will be returned. This method blocks until a record is available,
the end of the stream is reached, or an exception is thrown.
Any exception raised while reading will be converted to a DataException
using DataObject.exception(Throwable)
.
Subclasses generally do not need to override this method, instead they should implement readImpl()
.
DataException
push(Record)
,
peek(int)
,
read()
public int skip(int count) throws DataException
count
- the number of records to skipDataException
public boolean isLineageSupported()
public boolean isSaveLineage()
public DataReader setSaveLineage(boolean saveLineage)
public DataException addExceptionProperties(DataException exception)
Endpoint
DataException
. Since this method is called whenever an
exception is thrown, subclasses should override it to add their specific information.addExceptionProperties
in class DataEndpoint
Copyright (c) 2006-2024 North Concepts Inc. All Rights Reserved.