Interface ArrayWriter

  • All Known Implementing Classes:
    JacksonWriter

    @ThreadSafe
    public interface ArrayWriter
    Writes Array instances to a variety of output forms.
    Author:
    Randall Hauch
    • Method Detail

      • defaultWriter

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

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

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

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

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

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