Class JsonWriter
Writes records as JSON using a
JsonTemplate that defines the header, each record's detail and the footer.-
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.AbstractWriter
currentRecordFields 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
ConstructorsConstructorDescriptionJsonWriter(JsonTemplate template, File file) JsonWriter(JsonTemplate template, Writer writer) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Indicates that this endpoint has finished reading or writing.voidopen()Makes this endpoint ready for reading or writing.setAutoCloseWriter(boolean autoCloseWriter) Indicates if the underlying java.io.BufferedWriter should be closed when this stream closes (defaults to true).setDescription(String description) Sets the optional text shown for this endpoint inEndpoint.toString()and exception properties.setFieldNamesInFirstRow(boolean fieldNamesInFirstRow) Indicates if a header row of field names is written before the first record (default is true); must be called beforeAbstractWriter.open().setFlushOnWrite(boolean flushOnWrite) Indicates if the underlying java.io.BufferedWriter should be flushed after each record is written (defaults to false).protected voidwriteRecord(Record record) Writes one row; called first for the header row (seeAbstractWriter.isHeaderRow()) when field names are written, then for each record.Methods inherited from class com.northconcepts.datapipeline.core.TextWriter
addExceptionProperties, getFile, getWriter, isAppend, isAutoCloseWriter, isFieldNamesInFirstRow, isFlushOnWrite, writeMethods inherited from class com.northconcepts.datapipeline.core.AbstractWriter
createHeaderRecord, isHeaderRow, writeImplMethods inherited from class com.northconcepts.datapipeline.core.DataWriter
available, getNestedEndpoint, getNestedWriter, getRootEndpoint, getRootWriter, getWriterMethods inherited from class com.northconcepts.datapipeline.core.DataEndpoint
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
-
Constructor Details
-
JsonWriter
-
JsonWriter
-
-
Method Details
-
setAutoCloseWriter
Description copied from class:TextWriterIndicates if the underlying java.io.BufferedWriter should be closed when this stream closes (defaults to true).- Overrides:
setAutoCloseWriterin classTextWriter
-
setFlushOnWrite
Description copied from class:TextWriterIndicates if the underlying java.io.BufferedWriter should be flushed after each record is written (defaults to false).- Overrides:
setFlushOnWritein classTextWriter
-
setFieldNamesInFirstRow
Description copied from class:AbstractWriterIndicates if a header row of field names is written before the first record (default is true); must be called beforeAbstractWriter.open().- Overrides:
setFieldNamesInFirstRowin classAbstractWriter
-
setDescription
Description copied from class:EndpointSets the optional text shown for this endpoint inEndpoint.toString()and exception properties.- Overrides:
setDescriptionin classEndpoint
-
open
public void open()Description copied from class:DataEndpointMakes this endpoint ready for reading or writing.- Overrides:
openin classAbstractWriter
-
close
public void close()Description copied from class:DataEndpointIndicates that this endpoint has finished reading or writing.- Overrides:
closein classTextWriter
-
writeRecord
Description copied from class:AbstractWriterWrites one row; called first for the header row (seeAbstractWriter.isHeaderRow()) when field names are written, then for each record.- Specified by:
writeRecordin classAbstractWriter- Throws:
Throwable
-