Interface IJAXBVersatileWriter<T>

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default ByteBuffer getAsByteBuffer()
      Write the passed object to a ByteBuffer and return it (write).
      default byte[] getAsBytes()
      Write the passed object to a byte array and return the created byte array (write).
      default Document getAsDocument()
      Convert the passed object to a new DOM document (write).
      default com.helger.commons.io.stream.NonBlockingByteArrayInputStream getAsInputStream()
      Write the passed object to a byte array and return the input stream on that array.
      default com.helger.xml.microdom.IMicroDocument getAsMicroDocument()
      Convert the passed object to a new micro document (write).
      default com.helger.xml.microdom.IMicroElement getAsMicroElement()
      Convert the passed object to a new micro document and return only the root element (write).
      default String getAsString()
      Utility method to directly convert the passed domain object to an XML string (write).
      T getObjectToWrite()  
      com.helger.jaxb.IJAXBWriter<T> getWriter()  
      default com.helger.commons.state.ESuccess write​(com.helger.commons.io.resource.IWritableResource aResource)
      Write the passed object to an IWritableResource.
      default com.helger.commons.state.ESuccess write​(com.helger.jaxb.IJAXBWriter.IJAXBMarshaller<T> aMarshallerFunc)
      Convert the passed object to XML.
      default com.helger.commons.state.ESuccess write​(File aResultFile)
      Write the passed object to a File.
      default com.helger.commons.state.ESuccess write​(OutputStream aOS)
      Write the passed object to an OutputStream.
      default com.helger.commons.state.ESuccess write​(Writer aWriter)
      Write the passed object to a Writer.
      default com.helger.commons.state.ESuccess write​(ByteBuffer aBuffer)
      Write the passed object to a ByteBuffer.
      default com.helger.commons.state.ESuccess write​(Path aResultPath)
      Write the passed object to a Path.
      default com.helger.commons.state.ESuccess write​(XMLStreamWriter aWriter)
      Convert the passed object to XML.
      default com.helger.commons.state.ESuccess write​(Result aResult)
      Convert the passed object to XML.
      default com.helger.commons.state.ESuccess write​(ContentHandler aHandler)
      Convert the passed object to XML.
    • Method Detail

      • getObjectToWrite

        @Nonnull
        T getObjectToWrite()
        Returns:
        The object to write. May not be null.
      • getWriter

        @Nonnull
        com.helger.jaxb.IJAXBWriter<T> getWriter()
        Returns:
        The JAXB writer to use. May not be null.
      • write

        @Nonnull
        default com.helger.commons.state.ESuccess write​(@Nonnull
                                                        File aResultFile)
        Write the passed object to a File.
        Specified by:
        write in interface IVersatileWriter<T>
        Parameters:
        aResultFile - The result file to be written to. May not be null.
        Returns:
        ESuccess
      • write

        @Nonnull
        default com.helger.commons.state.ESuccess write​(@Nonnull
                                                        Path aResultPath)
        Write the passed object to a Path.
        Specified by:
        write in interface IVersatileWriter<T>
        Parameters:
        aResultPath - The result path to be written to. May not be null.
        Returns:
        ESuccess
      • write

        @Nonnull
        default com.helger.commons.state.ESuccess write​(@Nonnull @WillClose
                                                        OutputStream aOS)
        Write the passed object to an OutputStream.
        Specified by:
        write in interface IVersatileWriter<T>
        Parameters:
        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 @WillClose
                                                        Writer aWriter)
        Write the passed object to a Writer.
        Specified by:
        write in interface IVersatileWriter<T>
        Parameters:
        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
                                                        ByteBuffer aBuffer)
        Write the passed object to a ByteBuffer.
        Specified by:
        write in interface IVersatileWriter<T>
        Parameters:
        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
                                                        com.helger.commons.io.resource.IWritableResource aResource)
        Write the passed object to an IWritableResource.
        Specified by:
        write in interface IVersatileWriter<T>
        Parameters:
        aResource - The result resource to be written to. May not be null.
        Returns:
        ESuccess
      • write

        @Nonnull
        default com.helger.commons.state.ESuccess write​(@Nonnull
                                                        com.helger.jaxb.IJAXBWriter.IJAXBMarshaller<T> aMarshallerFunc)
        Convert the passed object to XML.
        Specified by:
        write in interface IVersatileWriter<T>
        Parameters:
        aMarshallerFunc - The marshalling function. May not be null.
        Returns:
        ESuccess
      • write

        @Nonnull
        default com.helger.commons.state.ESuccess write​(@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!
        Specified by:
        write in interface IVersatileWriter<T>
        Parameters:
        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
                                                        ContentHandler aHandler)
        Convert the passed object to XML.
        Specified by:
        write in interface IVersatileWriter<T>
        Parameters:
        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 @WillClose
                                                        XMLStreamWriter aWriter)
        Convert the passed object to XML.
        Specified by:
        write in interface IVersatileWriter<T>
        Parameters:
        aWriter - XML will be sent to this writer. May not be null.
        Returns:
        ESuccess
      • getAsDocument

        @Nullable
        default Document getAsDocument()
        Convert the passed object to a new DOM document (write).
        Specified by:
        getAsDocument in interface IVersatileWriter<T>
        Returns:
        null if converting the document failed.
      • getAsMicroDocument

        @Nullable
        default com.helger.xml.microdom.IMicroDocument getAsMicroDocument()
        Convert the passed object to a new micro document (write).
        Specified by:
        getAsMicroDocument in interface IVersatileWriter<T>
        Returns:
        null if converting the document failed.
      • getAsMicroElement

        @Nullable
        default com.helger.xml.microdom.IMicroElement getAsMicroElement()
        Convert the passed object to a new micro document and return only the root element (write).
        Specified by:
        getAsMicroElement in interface IVersatileWriter<T>
        Returns:
        null if converting the document failed.
      • getAsString

        @Nullable
        default String getAsString()
        Utility method to directly convert the passed domain object to an XML string (write).
        Specified by:
        getAsString in interface IVersatileWriter<T>
        Returns:
        null if the passed domain object could not be converted because of validation errors.
      • getAsByteBuffer

        @Nullable
        default ByteBuffer getAsByteBuffer()
        Write the passed object to a ByteBuffer and return it (write).
        Specified by:
        getAsByteBuffer in interface IVersatileWriter<T>
        Returns:
        null if the passed domain object could not be converted because of validation errors.
      • getAsBytes

        @Nullable
        default byte[] getAsBytes()
        Write the passed object to a byte array and return the created byte array (write).
        Specified by:
        getAsBytes in interface IVersatileWriter<T>
        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()
        Write the passed object to a byte array and return the input stream on that array.
        Specified by:
        getAsInputStream in interface IVersatileWriter<T>
        Returns:
        null if the passed domain object could not be converted because of validation errors.