Interface DocumentWriter

All Known Implementing Classes:
JacksonWriter

@ThreadSafe public interface DocumentWriter
Writes Document instances to a variety of output forms.
Author:
Randall Hauch
  • Method Summary

    Modifier and Type
    Method
    Description
    Get the default DocumentWriter instance.
    Get the default DocumentWriter instance that outputs nicely-formatted JSON arrays.
    write(Document document)
    Write the supplied document to a string using UTF-8.
    void
    write(Document document, OutputStream jsonStream)
    Write the supplied document to bytes using UTF-8.
    void
    write(Document document, Writer jsonWriter)
    Write the supplied document to bytes using UTF-8.
    default byte[]
    Write the supplied array to bytes using UTF-8.
  • Method Details

    • defaultWriter

      static DocumentWriter defaultWriter()
      Get the default DocumentWriter instance.
      Returns:
      the shared default writer instance; never null
    • prettyWriter

      static DocumentWriter prettyWriter()
      Get the default DocumentWriter instance that outputs nicely-formatted JSON arrays.
      Returns:
      the shared default pretty writer instance; never null
    • writeAsBytes

      default byte[] writeAsBytes(Document document)
      Write the supplied array to bytes using UTF-8.
      Parameters:
      document - the document to be written; may not be null
      Returns:
      the bytes containing the output JSON-formatted document; never null
    • write

      void write(Document document, OutputStream jsonStream) throws IOException
      Write the supplied document to bytes using UTF-8.
      Parameters:
      document - the array to be written; may not be null
      jsonStream - the stream to which the document is to be written; may not be null
      Throws:
      IOException - if a document could not be written to the supplied stream
    • write

      void write(Document document, Writer jsonWriter) throws IOException
      Write the supplied document to bytes using UTF-8.
      Parameters:
      document - the array to be written; may not be null
      jsonWriter - the writer to which the document is to be written; may not be null
      Throws:
      IOException - if a document could not be written to the supplied stream
    • write

      String write(Document document) throws IOException
      Write the supplied document to a string using UTF-8.
      Parameters:
      document - the document to be written; may not be null
      Returns:
      the string containing the output JSON-formatted document; never null
      Throws:
      IOException - if a document could not be written to the supplied stream