Class UonWriter

All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable

public final class UonWriter extends SerializerWriter
Specialized writer for serializing UON-encoded text.
Notes:
  • This class is not intended for external use.
See Also:
  • Constructor Details

    • UonWriter

      protected UonWriter(UonSerializerSession session, Writer out, boolean useWhitespace, int maxIndent, boolean encodeChars, boolean trimStrings, boolean plainTextParams, char quoteChar, UriResolver uriResolver)
      Constructor.
      Parameters:
      session - The session that created this writer.
      out - The writer being wrapped.
      useWhitespace - If true, tabs will be used in output.
      maxIndent - The maximum indentation level.
      encodeChars - If true, special characters should be encoded.
      trimStrings - If true, strings should be trimmed before they're serialized.
      plainTextParams - If true, don't use UON notation for values.
      quoteChar - The quote character to use. If 0, defaults to '\''.
      uriResolver - The URI resolver for resolving URIs to absolute or root-relative form.
  • Method Details

    • appendObject

      public UonWriter appendObject(Object o, boolean isTopAttrName)
      Serializes the specified simple object as a UON string value.
      Parameters:
      o - The object being serialized.
      isTopAttrName - If this is a top-level attribute name we're serializing.
      Returns:
      This object.
    • appendBoolean

      Appends a boolean value to the output.
      Parameters:
      o - The boolean value to append to the output.
      Returns:
      This object.
    • appendNumber

      protected UonWriter appendNumber(Object o)
      Appends a numeric value to the output.
      Parameters:
      o - The numeric value to append to the output.
      Returns:
      This object.
    • appendUri

      Appends a URI to the output.
      Overrides:
      appendUri in class SerializerWriter
      Parameters:
      uri - The URI to append to the output.
      Returns:
      This object.
    • cr

      public UonWriter cr(int depth)
      Description copied from class: SerializerWriter
      Performs a carriage return.

      Adds a newline and the specified number of tabs (if the useWhitespace setting is enabled) to the output.

      Overrides:
      cr in class SerializerWriter
      Parameters:
      depth - The indentation.
      Returns:
      This object.
    • cre

      public UonWriter cre(int depth)
      Description copied from class: SerializerWriter
      Performs a carriage return at the end of a line.

      Adds a newline and the specified number of tabs (if the useWhitespace setting is enabled) to the output.

      Overrides:
      cre in class SerializerWriter
      Parameters:
      depth - The indentation.
      Returns:
      This object.
    • appendln

      public UonWriter appendln(int indent, String text)
      Description copied from class: SerializerWriter
      Writes an indent (if the useWhitespace setting is enabled), followed by text, followed by a newline (if the useWhitespace setting is enabled).
      Overrides:
      appendln in class SerializerWriter
      Parameters:
      indent - The number of tabs to indent.
      text - The text to write.
      Returns:
      This object.
    • appendln

      public UonWriter appendln(String text)
      Description copied from class: SerializerWriter
      Writes the specified text followed by a newline (if the useWhitespace setting is enabled).
      Overrides:
      appendln in class SerializerWriter
      Parameters:
      text - The text to write.
      Returns:
      This object.
    • append

      public UonWriter append(int indent, String text)
      Description copied from class: SerializerWriter
      Writes an indent (if the useWhitespace setting is enabled), followed by text.
      Overrides:
      append in class SerializerWriter
      Parameters:
      indent - The number of tabs to indent.
      text - The text to write.
      Returns:
      This object.
    • append

      public UonWriter append(int indent, char c)
      Description copied from class: SerializerWriter
      Writes an indent (if the useWhitespace setting is enabled), followed by text.
      Overrides:
      append in class SerializerWriter
      Parameters:
      indent - The number of tabs to indent.
      c - The character to write.
      Returns:
      This object.
    • q

      public UonWriter q()
      Description copied from class: SerializerWriter
      Adds the quote character specified by the quoteChar setting to the output.
      Overrides:
      q in class SerializerWriter
      Returns:
      This object.
    • i

      public UonWriter i(int indent)
      Description copied from class: SerializerWriter
      Writes an indent to the writer if the useWhitespace setting is enabled.
      Overrides:
      i in class SerializerWriter
      Parameters:
      indent - The number of tabs to indent.
      Returns:
      This object.
    • nl

      public UonWriter nl(int indent)
      Description copied from class: SerializerWriter
      Writes a newline to the writer if the useWhitespace setting is enabled.
      Overrides:
      nl in class SerializerWriter
      Parameters:
      indent - The current indentation level.
      Returns:
      This object.
    • append

      public UonWriter append(Object text)
      Description copied from class: SerializerWriter
      Writes the specified text to the writer if it isn't null.
      Overrides:
      append in class SerializerWriter
      Parameters:
      text - The text to write.
      Returns:
      This object.
    • append

      public UonWriter append(String text)
      Description copied from class: SerializerWriter
      Writes the specified text to the writer if it isn't null.
      Overrides:
      append in class SerializerWriter
      Parameters:
      text - The text to write.
      Returns:
      This object.
    • appendIf

      public UonWriter appendIf(boolean b, String text)
      Description copied from class: SerializerWriter
      Writes the specified text to the writer if b is true.
      Overrides:
      appendIf in class SerializerWriter
      Parameters:
      b - Boolean flag.
      text - The text to write.
      Returns:
      This object.
    • appendIf

      public UonWriter appendIf(boolean b, char c)
      Description copied from class: SerializerWriter
      Writes the specified text to the writer if b is true.
      Overrides:
      appendIf in class SerializerWriter
      Parameters:
      b - Boolean flag.
      c - The text to write.
      Returns:
      This object.
    • append

      public UonWriter append(char c)
      Specified by:
      append in interface Appendable
      Overrides:
      append in class SerializerWriter