H
- type of the headerS
- type of the segmentsF
- type of the NDM constituentpublic abstract class AbstractMessageWriter<H extends Header,S extends Segment<?,?>,F extends NdmConstituent<H,S>> extends Object implements MessageWriter<H,S,F>
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_ORIGINATOR
Default value for
HeaderKey.ORIGINATOR . |
Constructor and Description |
---|
AbstractMessageWriter(String root,
String formatVersionKey,
double defaultVersion,
ContextBinding context)
Constructor used to create a new NDM writer configured with the necessary parameters
to successfully fill in all required fields that aren't part of a standard object.
|
Modifier and Type | Method and Description |
---|---|
ContextBinding |
getContext()
Get the current context.
|
double |
getDefaultVersion()
Get the default format version.
|
TimeConverter |
getTimeConverter()
Get the current time converter.
|
void |
setContext(ContextBinding context)
Reset context binding.
|
void |
writeFooter(Generator generator)
Write footer for the file.
|
void |
writeHeader(Generator generator,
H header)
Write header for the file.
|
void |
writeSegment(Generator generator,
S segment)
Write one segment.
|
abstract void |
writeSegmentContent(Generator generator,
double formatVersion,
S segment)
Write one segment content (without XML wrapping).
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
writeMessage
public static final String DEFAULT_ORIGINATOR
HeaderKey.ORIGINATOR
.public AbstractMessageWriter(String root, String formatVersionKey, double defaultVersion, ContextBinding context)
If creation date and originator are not present in header, built-in defaults will be used
root
- root element for XML filesformatVersionKey
- key for format versiondefaultVersion
- default format versioncontext
- context binding (may be reset for each segment)public void setContext(ContextBinding context)
context
- context binding to usepublic ContextBinding getContext()
public TimeConverter getTimeConverter()
public double getDefaultVersion()
public void writeHeader(Generator generator, H header) throws IOException
writeHeader
in interface MessageWriter<H extends Header,S extends Segment<?,?>,F extends NdmConstituent<H,S>>
generator
- generator to use for producing outputheader
- header to write (creation date and originator will be added if missing)IOException
- if the stream cannot write to streampublic void writeSegment(Generator generator, S segment) throws IOException
writeSegment
in interface MessageWriter<H extends Header,S extends Segment<?,?>,F extends NdmConstituent<H,S>>
generator
- generator to use for producing outputsegment
- segment to writeIOException
- if any buffer writing operations failspublic abstract void writeSegmentContent(Generator generator, double formatVersion, S segment) throws IOException
generator
- generator to use for producing outputformatVersion
- format version to usesegment
- segment to writeIOException
- if any buffer writing operations failspublic void writeFooter(Generator generator) throws IOException
writeFooter
in interface MessageWriter<H extends Header,S extends Segment<?,?>,F extends NdmConstituent<H,S>>
generator
- generator to use for producing outputIOException
- if the stream cannot write to streamCopyright © 2002-2022 CS GROUP. All rights reserved.