Class XmlWriter
Writes records to an XML stream using a template.
See the Write an XML file example.
-
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
ConstructorsConstructorDescriptionXmlWriter(XmlTemplate template, File file) XmlWriter(XmlTemplate template, Writer writer) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Indicates that this endpoint has finished reading or writing.booleanisPretty()Indicates if line breaks and indentations should be added to output (default false).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).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).setPretty(boolean pretty) Indicates if line breaks and indentations should be added to output (default false). Example output (pretty = true): <?xml version="1.0" ?> <records> <record> <field name="country">Philippines</field> </record> </records> Example output (pretty = false): <?xml version="1.0" ?><records><record><field name="country">Philippines</field></record></records>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, setDescription
-
Constructor Details
-
XmlWriter
-
XmlWriter
-
-
Method Details
-
isPretty
public boolean isPretty()Indicates if line breaks and indentations should be added to output (default false). -
setPretty
Indicates if line breaks and indentations should be added to output (default false). Example output (pretty = true): <?xml version="1.0" ?> <records> <record> <field name="country">Philippines</field> </record> </records> Example output (pretty = false): <?xml version="1.0" ?><records><record><field name="country">Philippines</field></record></records> -
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
-
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
-
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
-