Class AbstractWriter
java.lang.Object
com.northconcepts.datapipeline.core.DataObject
com.northconcepts.datapipeline.core.Endpoint
com.northconcepts.datapipeline.core.DataEndpoint
com.northconcepts.datapipeline.core.DataWriter
com.northconcepts.datapipeline.core.AbstractWriter
- Direct Known Subclasses:
BinaryWriter,ExcelWriter,GoogleSheetWriter,TextWriter
Abstract super-class, with some common logic, for writing records. The only method subclasses must implement is
writeRecord(Record).-
Nested Class Summary
Nested classes/interfaces inherited from class com.northconcepts.datapipeline.core.DataEndpoint
DataEndpoint.State -
Field Summary
FieldsFields inherited from class com.northconcepts.datapipeline.core.DataEndpoint
lastRecord, PRODUCT, PRODUCT_VERSION, VENDOR, XML_INPUT_FACTORY_KEYFields inherited from class com.northconcepts.datapipeline.core.Endpoint
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZEFields inherited from class com.northconcepts.datapipeline.core.DataObject
id, log, name, TIMESTAMP_FORMAT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddExceptionProperties(DataException exception) Adds this endpoint's current state to aDataException.protected RecordcreateHeaderRecord(Record record) Builds the header row from the first record: a copy whose field values are the field names, without session properties.booleanIndicates if a header row of field names is written before the first record (default is true).booleanReturnstrueif the current record being written is the header row.voidopen()Makes this endpoint ready for reading or writing.setFieldNamesInFirstRow(boolean fieldNamesInFirstRow) Indicates if a header row of field names is written before the first record (default is true); must be called beforeopen().voidWrites the specified record to thisDataWriterand increases the record-count by 1.protected voidOverridden by subclasses to write the specified record to thisDataWriter.protected abstract voidwriteRecord(Record record) Writes one row; called first for the header row (seeisHeaderRow()) when field names are written, then for each record.Methods inherited from class com.northconcepts.datapipeline.core.DataWriter
available, getNestedEndpoint, getNestedWriter, getRootEndpoint, getRootWriter, getWriterMethods inherited from class com.northconcepts.datapipeline.core.DataEndpoint
close, decrementRecordCount, enableJmx, getLastRecord, getRecordCount, getRecordCountAsBigInteger, getRecordCountAsString, incrementRecordCount, isRecordCountBigInteger, resetRecordCount, toStringMethods inherited from class com.northconcepts.datapipeline.core.Endpoint
addElapsedtime, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime, setDescription
-
Field Details
-
currentRecord
-
-
Constructor Details
-
AbstractWriter
public AbstractWriter()
-
-
Method Details
-
addExceptionProperties
Description copied from class:EndpointAdds this endpoint's current state to aDataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.- Overrides:
addExceptionPropertiesin classDataWriter
-
setFieldNamesInFirstRow
Indicates if a header row of field names is written before the first record (default is true); must be called beforeopen(). -
isFieldNamesInFirstRow
public boolean isFieldNamesInFirstRow()Indicates if a header row of field names is written before the first record (default is true). -
isHeaderRow
public boolean isHeaderRow()Returnstrueif the current record being written is the header row. This flag is only useful when called inside ofwriteRecord(Record), otherwise, it will always returnfalse. -
open
public void open()Description copied from class:DataEndpointMakes this endpoint ready for reading or writing.- Overrides:
openin classDataEndpoint
-
write
Description copied from class:DataWriterWrites the specified record to thisDataWriterand increases the record-count by 1. Any exception raised while writing will be converted to aDataExceptionusingDataObject.exception(Throwable).Subclasses generally do not need to override this method, instead they should implement
DataWriter.writeImpl(Record).- Overrides:
writein classDataWriter- Throws:
DataException
-
writeImpl
Description copied from class:DataWriterOverridden by subclasses to write the specified record to thisDataWriter.Contract for subclasses (see also
docs/authoring/DataWriter.md):- Do not call this method directly —
DataWriter.write(Record)is the template method that wraps exceptions, increments the record count, and attaches the offending record to thrownDataExceptions. - Do not call
DataEndpoint.incrementRecordCount()here;DataWriter.write(Record)already does. - Throw raw exceptions;
DataWriter.write(Record)wraps them viaexception(throwable).setRecord(record).
- Specified by:
writeImplin classDataWriter- Throws:
Throwable
- Do not call this method directly —
-
createHeaderRecord
Builds the header row from the first record: a copy whose field values are the field names, without session properties. -
writeRecord
Writes one row; called first for the header row (seeisHeaderRow()) when field names are written, then for each record.- Throws:
Throwable
-