Class TextStreamWriter
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.TextStreamWriter
- Direct Known Subclasses:
JsonRecordWriter,XmlRecordWriter
Abstract super-class for writing records to a text stream. Unike
TextWriter, this writer doesn't force the concept of
fieldNamesInFirstRow and doesn't assume the output is line based.-
Nested Class Summary
Nested classes/interfaces inherited from class com.northconcepts.datapipeline.core.DataEndpoint
DataEndpoint.State -
Field Summary
Fields 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
ConstructorsConstructorDescriptionTextStreamWriter(File file) Creates a writer that overwrites the file, which this constructor opens immediately rather than inopen().TextStreamWriter(Writer writer) -
Method Summary
Modifier and TypeMethodDescriptionaddExceptionProperties(DataException exception) Adds this endpoint's current state to aDataException.voidclose()Indicates that this endpoint has finished reading or writing.getFile()Returns the target file or null if this writer was created from aWriter.booleanIndicates if the underlying java.io.BufferedWriter should be closed when this stream closes (defaults to true).booleanIndicates if the underlying java.io.BufferedWriter should be flushed after each record is written.setAutoCloseWriter(boolean autoCloseWriter) Indicates if the underlying java.io.BufferedWriter should be closed when this stream closes (defaults to true).setFlushOnWrite(boolean flushOnWrite) Indicates if the underlying java.io.BufferedWriter should be flushed after each record is written (defaults to false).voidWrites the specified record to thisDataWriterand increases the record-count by 1.Methods inherited from class com.northconcepts.datapipeline.core.DataWriter
available, getNestedEndpoint, getNestedWriter, getRootEndpoint, getRootWriter, getWriter, writeImplMethods inherited from class com.northconcepts.datapipeline.core.DataEndpoint
decrementRecordCount, enableJmx, getLastRecord, getRecordCount, getRecordCountAsBigInteger, getRecordCountAsString, incrementRecordCount, isRecordCountBigInteger, open, 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
-
Constructor Details
-
TextStreamWriter
Creates a writer that overwrites the file, which this constructor opens immediately rather than inopen(). -
TextStreamWriter
-
-
Method Details
-
getWriter
-
getFile
Returns the target file or null if this writer was created from aWriter. -
isAutoCloseWriter
public boolean isAutoCloseWriter()Indicates if the underlying java.io.BufferedWriter should be closed when this stream closes (defaults to true). -
setAutoCloseWriter
Indicates if the underlying java.io.BufferedWriter should be closed when this stream closes (defaults to true). -
isFlushOnWrite
public boolean isFlushOnWrite()Indicates if the underlying java.io.BufferedWriter should be flushed after each record is written. -
setFlushOnWrite
Indicates if the underlying java.io.BufferedWriter should be flushed after each record is written (defaults to false). -
close
public void close()Description copied from class:DataEndpointIndicates that this endpoint has finished reading or writing.- Overrides:
closein 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
-
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
-