Class AbstractMessageWriter<H extends Header,​S extends Segment<?,​?>,​F extends NdmConstituent<H,​S>>

    • Constructor Detail

      • AbstractMessageWriter

        public 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.

        If creation date and originator are not present in header, built-in defaults will be used

        Parameters:
        root - root element for XML files
        formatVersionKey - key for format version
        defaultVersion - default format version
        context - context binding (may be reset for each segment)
    • Method Detail

      • setContext

        public void setContext​(ContextBinding context)
        Reset context binding.
        Parameters:
        context - context binding to use
      • getContext

        public ContextBinding getContext()
        Get the current context.
        Returns:
        current context
      • getTimeConverter

        public TimeConverter getTimeConverter()
        Get the current time converter.
        Returns:
        current time converter
      • getDefaultVersion

        public double getDefaultVersion()
        Get the default format version.
        Returns:
        default format version
      • writeHeader

        public void writeHeader​(Generator generator,
                                H header)
                         throws IOException
        Write header for the file.
        Specified by:
        writeHeader in interface MessageWriter<H extends Header,​S extends Segment<?,​?>,​F extends NdmConstituent<H,​S>>
        Parameters:
        generator - generator to use for producing output
        header - header to write (creation date and originator will be added if missing)
        Throws:
        IOException - if the stream cannot write to stream
      • writeSegmentContent

        protected abstract void writeSegmentContent​(Generator generator,
                                                    double formatVersion,
                                                    S segment)
                                             throws IOException
        Write one segment content (without XML wrapping).
        Parameters:
        generator - generator to use for producing output
        formatVersion - format version to use
        segment - segment to write
        Throws:
        IOException - if any buffer writing operations fails