Interface IVersatileWriter<T>

  • Type Parameters:
    T - Type to be written.
    All Known Subinterfaces:
    IJAXBVersatileWriter<T>
    All Known Implementing Classes:
    JAXBVersatileWriter

    public interface IVersatileWriter<T>
    Base interface for something that can be written to different destinations.
    Author:
    Philip Helger
    • Method Summary

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

      • write

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

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

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

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

        @Nonnull
        com.helger.commons.state.ESuccess write​(@Nonnull
                                                ByteBuffer aBuffer)
        Write the object to a ByteBuffer.
        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
        com.helger.commons.state.ESuccess write​(@Nonnull
                                                com.helger.commons.io.resource.IWritableResource aResource)
        Write the object to an IWritableResource.
        Parameters:
        aResource - The result resource to be written to. May not be null.
        Returns:
        ESuccess
      • write

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

        @Nonnull
        com.helger.commons.state.ESuccess write​(@Nonnull
                                                Result aResult)
        Convert the 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:
        aResult - The result object holder. May not be null. Usually SAXResult, DOMResult and StreamResult are supported.
        Returns:
        ESuccess
      • write

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

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

        @Nullable
        Document getAsDocument()
        Convert the object to a new DOM document (write).
        Returns:
        null if converting the document failed.
      • getAsMicroDocument

        @Nullable
        com.helger.xml.microdom.IMicroDocument getAsMicroDocument()
        Convert the object to a new micro document (write).
        Returns:
        null if converting the document failed.
      • getAsMicroElement

        @Nullable
        com.helger.xml.microdom.IMicroElement getAsMicroElement()
        Convert the object to a new micro document and return only the root element (write).
        Returns:
        null if converting the document failed.
      • getAsString

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

        @Nullable
        ByteBuffer getAsByteBuffer()
        Write the object to a ByteBuffer and return it (write).
        Returns:
        null if the passed domain object could not be converted because of validation errors.
      • getAsBytes

        @Nullable
        byte[] getAsBytes()
        Write the object to a byte array and return the created byte array (write).
        Returns:
        null if the passed domain object could not be converted because of validation errors.
      • getAsInputStream

        @Nullable
        com.helger.commons.io.stream.NonBlockingByteArrayInputStream getAsInputStream()
        Write the object to a byte array and return the input stream on that array.
        Returns:
        null if the passed domain object could not be converted because of validation errors.