com.northconcepts.datapipeline.core
Class AbstractReader

java.lang.Object
  extended by com.northconcepts.datapipeline.core.DataEndpoint
      extended by com.northconcepts.datapipeline.core.DataReader
          extended by com.northconcepts.datapipeline.core.AbstractReader
Direct Known Subclasses:
ExcelReader, ParsingReader, TextReader

public abstract class AbstractReader
extends DataReader

Abstract super-class, with some common logic, for reading records. The only method subclasses must implement is fillRecord(Record).


Nested Class Summary
 
Nested classes/interfaces inherited from class com.northconcepts.datapipeline.core.DataEndpoint
DataEndpoint.State
 
Field Summary
protected  Record currentRecord
           
protected  String[] fieldNames
           
protected  int lastRow
           
protected  int startingRow
           
 
Fields inherited from class com.northconcepts.datapipeline.core.DataEndpoint
BUFFER_SIZE, log
 
Constructor Summary
AbstractReader()
           
 
Method Summary
 DataException addExceptionProperties(DataException exception)
          Adds this endpoint's current state to a DataException.
protected abstract  boolean fillRecord(Record record)
           
 String[] getFieldNames()
           
 int getLastRow()
           
 int getStartingRow()
           
 boolean isFieldNamesInFirstRow()
           
 void open()
          Makes this endpoint ready for reading or writing.
 Record read()
          Reads the next record from this DataReader and increases the record-count by 1.
protected  Record readImpl()
          Overridden by subclasses to read the next record from this DataReader.
 AbstractReader setFieldNames(String... fieldNames)
           
 AbstractReader setFieldNamesInFirstRow(boolean fieldNamesInFirstRow)
           
 void setLastRow(int lastRow)
           
 void setStartingRow(int startingRow)
           
 
Methods inherited from class com.northconcepts.datapipeline.core.DataReader
available, getBufferSize, getNestedReader, getRootReader, peek, pop, push, skip
 
Methods inherited from class com.northconcepts.datapipeline.core.DataEndpoint
assertNotOpened, assertOpened, close, decrementRecordCount, exception, exception, exception, finalize, getRecordCount, getRecordCountAsBigInteger, getRecordCountAsString, getState, incrementRecordCount, isClosed, isOpen, isRecordCountBigInteger, resetRecordCount, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fieldNames

protected String[] fieldNames

currentRecord

protected Record currentRecord

startingRow

protected int startingRow

lastRow

protected int lastRow
Constructor Detail

AbstractReader

public AbstractReader()
Method Detail

addExceptionProperties

public DataException addExceptionProperties(DataException exception)
Description copied from class: DataEndpoint
Adds this endpoint's current state to a DataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.

Overrides:
addExceptionProperties in class DataReader

isFieldNamesInFirstRow

public boolean isFieldNamesInFirstRow()

setFieldNamesInFirstRow

public AbstractReader setFieldNamesInFirstRow(boolean fieldNamesInFirstRow)

getFieldNames

public String[] getFieldNames()

setFieldNames

public AbstractReader setFieldNames(String... fieldNames)

setStartingRow

public void setStartingRow(int startingRow)

getStartingRow

public int getStartingRow()

setLastRow

public void setLastRow(int lastRow)

getLastRow

public int getLastRow()

open

public void open()
          throws DataException
Description copied from class: DataEndpoint
Makes this endpoint ready for reading or writing.

Overrides:
open in class DataEndpoint
Throws:
DataException

read

public Record read()
            throws DataException
Description copied from class: DataReader
Reads the next record from this DataReader and increases the record-count by 1. This method will first read any pushed (DataReader.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 writing will be converted to a DataException using DataEndpoint.exception(Throwable).

Subclasses generally do not need to override this method, instead they should implement DataReader.readImpl().

Overrides:
read in class DataReader
Throws:
DataException
See Also:
DataReader.push(Record), DataReader.peek(int), DataReader.read()

readImpl

protected Record readImpl()
                   throws Throwable
Description copied from class: DataReader
Overridden by subclasses to read the next record from this DataReader.

If no record is available, null will be returned.

Specified by:
readImpl in class DataReader
Throws:
Throwable

fillRecord

protected abstract boolean fillRecord(Record record)
                               throws Throwable
Throws:
Throwable


Copyright (c) 2007-2009 North Concepts Inc. All Rights Reserved.