Class AponWriter

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    public class AponWriter
    extends AponFormat
    implements java.io.Flushable, java.io.Closeable
    Converts a Parameters object to an APON formatted string.

    If pretty-printing is enabled, includes spaces, tabs to make the format more readable. By default, pretty-printing is enabled, and the indent string is a tab character.

    • Constructor Detail

      • AponWriter

        public AponWriter​(java.io.Writer writer)
        Instantiates a new AponWriter. By default, pretty printing is enabled, and the indent string is a tab character.
        Parameters:
        writer - the character-output stream
      • AponWriter

        public AponWriter​(java.io.Writer writer,
                          boolean prettyPrint)
        Instantiates a new AponWriter. If pretty-printing is enabled, includes spaces, tabs to make the format more readable. By default, the indent string is a tab character.
        Parameters:
        writer - the character-output stream
        prettyPrint - enables or disables pretty-printing
      • AponWriter

        public AponWriter​(java.io.Writer writer,
                          java.lang.String indentString)
        Instantiates a new AponWriter. If pretty-printing is enabled, includes spaces, tabs to make the format more readable.
        Parameters:
        writer - the character-output stream
        indentString - the string that should be used for indentation when pretty-printing is enabled
      • AponWriter

        public AponWriter​(java.io.File file)
                   throws java.io.IOException
        Instantiates a new AponWriter.
        Parameters:
        file - a File object to write to
        Throws:
        java.io.IOException - if an I/O error occurs
      • AponWriter

        public AponWriter​(java.io.File file,
                          boolean append)
                   throws java.io.IOException
        Instantiates a new AponWriter.
        Parameters:
        file - a File object to write to
        append - if true, then bytes will be written to the end of the file rather than the beginning
        Throws:
        java.io.IOException - if an I/O error occurs
    • Method Detail

      • setPrettyPrint

        public void setPrettyPrint​(boolean prettyPrint)
      • setIndentString

        public void setIndentString​(java.lang.String indentString)
      • setNoQuotes

        public void setNoQuotes​(boolean noQuotes)
        Sets whether wrap a string in quotes.
        Parameters:
        noQuotes - true, wrap a string in quotes
      • setNullWrite

        public void setNullWrite​(boolean nullWrite)
        Sets whether to write a null parameter.
        Parameters:
        nullWrite - true, write a null parameter
      • setTypeHintWrite

        public void setTypeHintWrite​(boolean typeHintWrite)
        Sets whether write a type hint for values.
        Parameters:
        typeHintWrite - true, write a type hint for values
      • write

        public void write​(Parameters parameters)
                   throws java.io.IOException
        Write a Parameters object to the character-output stream.
        Parameters:
        parameters - the Parameters object to be converted
        Throws:
        java.io.IOException - if an I/O error occurs
      • write

        public void write​(Parameter parameter)
                   throws java.io.IOException
        Write a Parameter object to the character-output stream.
        Parameters:
        parameter - the Parameter object to be converted
        Throws:
        java.io.IOException - if an I/O error occurs
      • comment

        public void comment​(java.lang.String describe)
                     throws java.io.IOException
        Writes a comment to the character-output stream.
        Parameters:
        describe - the comment to write to a character-output stream
        Throws:
        java.io.IOException - if an I/O error occurs
      • flush

        public void flush()
                   throws java.io.IOException
        Specified by:
        flush in interface java.io.Flushable
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Closes the writer.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException - if an I/O error occurs
      • stringify

        public static java.lang.String stringify​(Parameters parameters)
        Converts a Parameters object to an APON formatted string. By default, pretty printing is enabled, and the indent string is a tab character.
        Parameters:
        parameters - the Parameters object to be converted
        Returns:
        a string that contains the APON text
      • stringify

        public static java.lang.String stringify​(Parameters parameters,
                                                 boolean prettyPrint)
        Converts a Parameters object to an APON formatted string. If pretty-printing is enabled, includes spaces, tabs to make the format more readable. The default indentation string is a tab character.
        Parameters:
        parameters - the Parameters object to be converted
        prettyPrint - enables or disables pretty-printing
        Returns:
        a string that contains the APON text
      • stringify

        public static java.lang.String stringify​(Parameters parameters,
                                                 java.lang.String indentString)
        Converts a Parameters object to an APON formatted string. If pretty-printing is enabled, includes spaces, tabs to make the format more readable.
        Parameters:
        parameters - the Parameters object to be converted
        indentString - the string that should be used for indentation when pretty-printing is enabled
        Returns:
        a string that contains the APON text