Interface IJAXBWriter<JAXBTYPE>

Type Parameters:
JAXBTYPE - The JAXB type to be written
All Known Implementing Classes:
GenericJAXBMarshaller, JAXBWriterBuilder

public interface IJAXBWriter<JAXBTYPE>
Interface for writing JAXB documents to various destinations.
Author:
Philip Helger
  • Field Details

    • USE_JAXB_CHARSET_FIX

      static final boolean USE_JAXB_CHARSET_FIX
      Use the SafeXMLStreamWriter where applicable to ensure valid XML is created? This is a work around for https://github.com/eclipse-ee4j/jaxb-ri/issues/614 and https://github.com/eclipse-ee4j/jaxb-ri/issues/960
      Note: these bugs are still open for JAXB 4.0.0
      See Also:
  • Method Details

    • getNamespaceContext

      @Nullable NamespaceContext getNamespaceContext()
      Returns:
      The special JAXB namespace context to be used. May be null.
      Since:
      8.5.3 in this interface
    • isFormattedOutput

      boolean isFormattedOutput()
      Returns:
      true if the JAXB output should be formatted. Default is false.
      Since:
      8.5.3 in this interface
    • getCharset

      @Nullable Charset getCharset()
      Returns:
      The special JAXB Charset to be used for writing. null by default.
      Since:
      8.5.3 in this interface
    • hasCharset

      default boolean hasCharset()
    • getIndentString

      @Nullable String getIndentString()
      Returns:
      The JAXB indentation string to be used for writing. null by default. Only used when formatted output is used.
      Since:
      8.5.3 in this interface
    • hasIndentString

      default boolean hasIndentString()
    • isUseSchema

      boolean isUseSchema()
      Returns:
      true if an eventually configured XML Schema should be used, false to explicitly disable the usage of XML Schema.
      Since:
      11.0.3
    • getSchemaLocation

      @Nullable String getSchemaLocation()
      Returns:
      The schema location to be used for writing. null by default.
      Since:
      8.6.0
    • hasSchemaLocation

      default boolean hasSchemaLocation()
    • getNoNamespaceSchemaLocation

      @Nullable String getNoNamespaceSchemaLocation()
      Returns:
      The no namespace schema location to be used for writing. null by default.
      Since:
      9.0.0
    • hasNoNamespaceSchemaLocation

      default boolean hasNoNamespaceSchemaLocation()
    • getXMLWriterSettings

      @Nonnull default com.helger.xml.serialize.write.IXMLWriterSettings getXMLWriterSettings()
      Returns:
      The XML writer settings to be used based on this writer settings. Never null.
    • write

      @Nonnull default com.helger.commons.state.ESuccess write(@Nonnull JAXBTYPE aObject, @Nonnull File aResultFile)
      Write the passed object to a File.
      Parameters:
      aObject - The object to be written. May not be null.
      aResultFile - The result file to be written to. May not be null.
      Returns:
      ESuccess
    • write

      @Nonnull default com.helger.commons.state.ESuccess write(@Nonnull JAXBTYPE aObject, @Nonnull Path aResultPath)
      Write the passed object to a Path.
      Parameters:
      aObject - The object to be written. May not be null.
      aResultPath - The result path to be written to. May not be null.
      Returns:
      ESuccess
    • write

      @Nonnull default com.helger.commons.state.ESuccess write(@Nonnull JAXBTYPE aObject, @Nonnull @WillClose OutputStream aOS)
      Write the passed object to an OutputStream.
      Parameters:
      aObject - The object to be written. May not be null.
      aOS - The output stream to write to. Will always be closed. May not be null.
      Returns:
      ESuccess
    • write

      @Nonnull default com.helger.commons.state.ESuccess write(@Nonnull JAXBTYPE aObject, @Nonnull @WillClose Writer aWriter)
      Write the passed object to a Writer.
      Parameters:
      aObject - The object to be written. May not be null.
      aWriter - The writer to write to. Will always be closed. May not be null.
      Returns:
      ESuccess
    • write

      @Nonnull default com.helger.commons.state.ESuccess write(@Nonnull JAXBTYPE aObject, @Nonnull ByteBuffer aBuffer)
      Write the passed object to a ByteBuffer.
      Parameters:
      aObject - The object to be written. May not be null.
      aBuffer - The byte buffer to write to. If the buffer is too small, it is automatically extended. May not be null.
      Returns:
      ESuccess
      Throws:
      BufferOverflowException - If the ByteBuffer is too small
    • write

      @Nonnull default com.helger.commons.state.ESuccess write(@Nonnull JAXBTYPE aObject, @Nonnull com.helger.commons.io.resource.IWritableResource aResource)
      Write the passed object to an IWritableResource.
      Parameters:
      aObject - The object to be written. May not be null.
      aResource - The result resource to be written to. May not be null.
      Returns:
      ESuccess
    • write

      @Nonnull com.helger.commons.state.ESuccess write(@Nonnull JAXBTYPE aObject, @Nonnull IJAXBMarshaller<JAXBTYPE> aMarshallerFunc)
      Convert the passed object to XML.
      Parameters:
      aObject - The object to be converted. May not be null.
      aMarshallerFunc - The marshalling function. May not be null.
      Returns:
      ESuccess
    • write

      @Nonnull default com.helger.commons.state.ESuccess write(@Nonnull JAXBTYPE aObject, @Nonnull Result aResult)
      Convert the passed object to XML. This method is potentially dangerous, when using StreamResult because it may create invalid XML. Only when using the SafeXMLStreamWriter it is ensured that only valid XML is created!
      Parameters:
      aObject - The object to be converted. May not be null.
      aResult - The result object holder. May not be null. Usually SAXResult, DOMResult and StreamResult are supported.
      Returns:
      ESuccess
    • write

      @Nonnull default com.helger.commons.state.ESuccess write(@Nonnull JAXBTYPE aObject, @Nonnull ContentHandler aHandler)
      Convert the passed object to XML.
      Parameters:
      aObject - The object to be converted. May not be null.
      aHandler - XML will be sent to this handler as SAX2 events. May not be null.
      Returns:
      ESuccess
    • write

      @Nonnull default com.helger.commons.state.ESuccess write(@Nonnull JAXBTYPE aObject, @Nonnull @WillClose XMLStreamWriter aWriter)
      Convert the passed object to XML.
      Parameters:
      aObject - The object to be converted. May not be null.
      aWriter - XML will be sent to this writer. May not be null.
      Returns:
      ESuccess
    • getAsDocument

      @Nullable default Document getAsDocument(@Nonnull JAXBTYPE aObject)
      Convert the passed object to a new DOM document (write).
      Parameters:
      aObject - The object to be converted. May not be null.
      Returns:
      null if converting the document failed.
    • getAsElement

      @Nullable default Element getAsElement(@Nonnull JAXBTYPE aObject)
      Convert the passed object to a new DOM document and return the document element (write).
      Parameters:
      aObject - The object to be converted. May not be null.
      Returns:
      null if converting the document failed.
      Since:
      11.0.2
    • getAsMicroDocument

      @Nullable default com.helger.xml.microdom.IMicroDocument getAsMicroDocument(@Nonnull JAXBTYPE aObject)
      Convert the passed object to a new micro document (write).
      Parameters:
      aObject - The object to be converted. May not be null.
      Returns:
      null if converting the document failed.
    • getAsMicroElement

      @Nullable default com.helger.xml.microdom.IMicroElement getAsMicroElement(@Nonnull JAXBTYPE aObject)
      Convert the passed object to a new micro document and return only the root element (write).
      Parameters:
      aObject - The object to be converted. May not be null.
      Returns:
      null if converting the document failed.
    • getAsString

      @Nullable default String getAsString(@Nonnull JAXBTYPE aObject)
      Utility method to directly convert the passed domain object to an XML string (write).
      Parameters:
      aObject - The domain object to be converted. May not be null.
      Returns:
      null if the passed domain object could not be converted because of validation errors.
    • getAsByteBuffer

      @Nullable default ByteBuffer getAsByteBuffer(@Nonnull JAXBTYPE aObject)
      Write the passed object to a ByteBuffer and return it (write).
      Parameters:
      aObject - The object to be written. May not be null.
      Returns:
      null if the passed domain object could not be converted because of validation errors.
    • getAsBytes

      @Nullable default byte[] getAsBytes(@Nonnull JAXBTYPE aObject)
      Write the passed object to a byte array and return the created byte array (write).
      Parameters:
      aObject - The object to be written. May not be null.
      Returns:
      null if the passed domain object could not be converted because of validation errors.
    • getAsInputStream

      @Nullable default com.helger.commons.io.stream.NonBlockingByteArrayInputStream getAsInputStream(@Nonnull JAXBTYPE aObject)
      Write the passed object to a byte array and return the input stream on that array.
      Parameters:
      aObject - The object to be written. May not be null.
      Returns:
      null if the passed domain object could not be converted because of validation errors.
      Since:
      9.1.8