java.lang.Object
com.foursoft.harness.navext.runtime.io.write.XMLWriter<T>

public class XMLWriter<T> extends Object
Serializes a valid JAXB object structure to XML with the following additional features: - Can add comments to the xml file - Formats the XML output
  • Constructor Details

    • XMLWriter

      public XMLWriter(Class<T> baseType)
    • XMLWriter

      public XMLWriter(Class<T> baseType, Consumer<jakarta.xml.bind.ValidationEvent> validationEventConsumer)
  • Method Details

    • write

      public void write(T container, OutputStream outputStream)
      write the JAXB model to an output stream
      Parameters:
      container - the jaxb model to deserialize into the given stream
      outputStream - the output to write to
    • write

      public void write(T container, XMLMeta meta, OutputStream outputStream)
      write the JAXB model to an output stream
      Parameters:
      container - the jaxb model to deserialize into the given stream
      outputStream - the output to write to
      meta - additional meta information which should be added to output XMLMeta
    • writeToString

      public String writeToString(T container)
      write the JAXB model to a string
      Parameters:
      container - the jaxb model to deserialize into the given stream
      Returns:
      the model as xml string
    • writeToString

      public String writeToString(T container, XMLMeta meta)
      Write the JAXB model to a String. Allows Meta Data as like as comments to be passed with.
      Parameters:
      container - the jaxb model to deserialize into the given stream
      meta - additional meta information which should be added to output XMLMeta
      Returns:
      the model as xml string
    • configureMarshaller

      protected void configureMarshaller(jakarta.xml.bind.Marshaller marshaller) throws Exception
      Method which can be overridden for further configuration on the marshaller.
      Parameters:
      marshaller - Marshaller to configure.
      Throws:
      Exception - In case something went wrong.