Class XmlGenerator

  • All Implemented Interfaces:
    AutoCloseable, Generator

    public class XmlGenerator
    extends AbstractGenerator
    Generator for eXtended Markup Language CCSDS messages.
    Since:
    11.0
    Author:
    Luc Maisonobe
    • Field Detail

      • DEFAULT_INDENT

        public static final int DEFAULT_INDENT
        Default number of space for each indentation level.
        See Also:
        Constant Field Values
      • NDM_XML_V3_SCHEMA_LOCATION

        public static final String NDM_XML_V3_SCHEMA_LOCATION
        NDM/XML version 3 location.
        Since:
        12.0
        See Also:
        Constant Field Values
    • Constructor Detail

      • XmlGenerator

        public XmlGenerator​(Appendable output,
                            int indentation,
                            String outputName,
                            double maxRelativeOffset,
                            boolean writeUnits,
                            String schemaLocation)
                     throws IOException
        Simple constructor.
        Parameters:
        output - destination of generated output
        indentation - number of space for each indentation level
        outputName - output name for error messages
        maxRelativeOffset - maximum offset in seconds to use relative dates (if a date is too far from reference, it will be displayed as calendar elements)
        writeUnits - if true, units must be written
        schemaLocation - schema location to use, may be null
        Throws:
        IOException - if an I/O error occurs.
        See Also:
        DEFAULT_INDENT, NDM_XML_V3_SCHEMA_LOCATION
    • Method Detail

      • getFormat

        public FileFormat getFormat()
        Get the generated file format.
        Returns:
        generated file format
      • startMessage

        public void startMessage​(String root,
                                 String messageTypeKey,
                                 double version)
                          throws IOException
        Start CCSDS message.
        Parameters:
        root - root element for XML files
        messageTypeKey - key for message type
        version - format version
        Throws:
        IOException - if an I/O error occurs.
      • endMessage

        public void endMessage​(String root)
                        throws IOException
        End CCSDS message.
        Parameters:
        root - root element for XML files
        Throws:
        IOException - if an I/O error occurs.
      • writeComments

        public void writeComments​(List<String> comments)
                           throws IOException
        Write comment lines.
        Parameters:
        comments - comments to write
        Throws:
        IOException - if an I/O error occurs.
      • writeOneAttributeElement

        public void writeOneAttributeElement​(String name,
                                             String value,
                                             String attributeName,
                                             String attributeValue)
                                      throws IOException
        Write an element with one attribute.
        Parameters:
        name - tag name
        value - element value
        attributeName - attribute name
        attributeValue - attribute value
        Throws:
        IOException - if an I/O error occurs.
      • writeTwoAttributesElement

        public void writeTwoAttributesElement​(String name,
                                              String value,
                                              String attribute1Name,
                                              String attribute1Value,
                                              String attribute2Name,
                                              String attribute2Value)
                                       throws IOException
        Write an element with two attributes.
        Parameters:
        name - tag name
        value - element value
        attribute1Name - attribute 1 name
        attribute1Value - attribute 1 value
        attribute2Name - attribute 2 name
        attribute2Value - attribute 2 value
        Throws:
        IOException - if an I/O error occurs.
      • writeEntry

        public void writeEntry​(String key,
                               String value,
                               Unit unit,
                               boolean mandatory)
                        throws IOException
        Write a single key/value entry.
        Parameters:
        key - the keyword to write
        value - the value to write
        unit - output unit (may be null)
        mandatory - if true, null values triggers exception, otherwise they are silently ignored
        Throws:
        IOException - if an I/O error occurs.