Package org.bson.json

Class StrictCharacterStreamJsonWriter

  • All Implemented Interfaces:
    StrictJsonWriter

    public final class StrictCharacterStreamJsonWriter
    extends java.lang.Object
    implements StrictJsonWriter
    A class that writes JSON texts as a character stream via a provided Writer.
    Since:
    3.5
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getCurrentLength()
      Gets the current length of the JSON text.
      boolean isTruncated()
      Return true if the output has been truncated due to exceeding the length specified in StrictCharacterStreamJsonWriterSettings.getMaxLength().
      void writeBoolean​(boolean value)
      Writes a boolean to the writer.
      void writeBoolean​(java.lang.String name, boolean value)
      Writes a a member with a boolean value to the writer.
      void writeEndArray()
      Writes the end of a JSON array to the writer.
      void writeEndObject()
      Writes the end of a JSON object to the writer.
      void writeName​(java.lang.String name)
      Writes the name of a member to the writer.
      void writeNull()
      Writes a null value to the writer.
      void writeNull​(java.lang.String name)
      Writes a member with a null value to the writer.
      void writeNumber​(java.lang.String value)
      Writes a number to the writer.
      void writeNumber​(java.lang.String name, java.lang.String value)
      Writes a member with a numeric value to the writer.
      void writeRaw​(java.lang.String value)
      Writes a raw value without quoting or escaping.
      void writeRaw​(java.lang.String name, java.lang.String value)
      Writes a member with a raw value without quoting or escaping.
      void writeStartArray()
      Writes the start of a array to the writer.
      void writeStartArray​(java.lang.String name)
      Writes the start of JSON array member to the writer.
      void writeStartObject()
      Writes the start of a JSON object to the writer.
      void writeStartObject​(java.lang.String name)
      Writes the start of a JSON object member to the writer.
      void writeString​(java.lang.String value)
      Writes a String to the writer.
      void writeString​(java.lang.String name, java.lang.String value)
      Writes a member with a string value to the writer.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StrictCharacterStreamJsonWriter

        public StrictCharacterStreamJsonWriter​(java.io.Writer writer,
                                               StrictCharacterStreamJsonWriterSettings settings)
        Construct an instance.
        Parameters:
        writer - the writer to write JSON to.
        settings - the settings to apply to this writer.
    • Method Detail

      • getCurrentLength

        public int getCurrentLength()
        Gets the current length of the JSON text.
        Returns:
        the current length of the JSON text
      • writeStartObject

        public void writeStartObject​(java.lang.String name)
        Description copied from interface: StrictJsonWriter
        Writes the start of a JSON object member to the writer.
        Specified by:
        writeStartObject in interface StrictJsonWriter
        Parameters:
        name - the member name
      • writeStartArray

        public void writeStartArray​(java.lang.String name)
        Description copied from interface: StrictJsonWriter
        Writes the start of JSON array member to the writer.
        Specified by:
        writeStartArray in interface StrictJsonWriter
        Parameters:
        name - the member name
      • writeBoolean

        public void writeBoolean​(java.lang.String name,
                                 boolean value)
        Description copied from interface: StrictJsonWriter
        Writes a a member with a boolean value to the writer.
        Specified by:
        writeBoolean in interface StrictJsonWriter
        Parameters:
        name - the member name
        value - the boolean value
      • writeNumber

        public void writeNumber​(java.lang.String name,
                                java.lang.String value)
        Description copied from interface: StrictJsonWriter
        Writes a member with a numeric value to the writer.
        Specified by:
        writeNumber in interface StrictJsonWriter
        Parameters:
        name - the member name
        value - the Double value, as a String so that clients can take full control over formatting
      • writeString

        public void writeString​(java.lang.String name,
                                java.lang.String value)
        Description copied from interface: StrictJsonWriter
        Writes a member with a string value to the writer.
        Specified by:
        writeString in interface StrictJsonWriter
        Parameters:
        name - the member name
        value - the String value
      • writeRaw

        public void writeRaw​(java.lang.String name,
                             java.lang.String value)
        Description copied from interface: StrictJsonWriter
        Writes a member with a raw value without quoting or escaping.
        Specified by:
        writeRaw in interface StrictJsonWriter
        Parameters:
        name - the member name
        value - the raw value
      • writeNull

        public void writeNull​(java.lang.String name)
        Description copied from interface: StrictJsonWriter
        Writes a member with a null value to the writer.
        Specified by:
        writeNull in interface StrictJsonWriter
        Parameters:
        name - the member name
      • writeName

        public void writeName​(java.lang.String name)
        Description copied from interface: StrictJsonWriter
        Writes the name of a member to the writer.
        Specified by:
        writeName in interface StrictJsonWriter
        Parameters:
        name - the member name
      • writeBoolean

        public void writeBoolean​(boolean value)
        Description copied from interface: StrictJsonWriter
        Writes a boolean to the writer.
        Specified by:
        writeBoolean in interface StrictJsonWriter
        Parameters:
        value - the boolean value.
      • writeNumber

        public void writeNumber​(java.lang.String value)
        Description copied from interface: StrictJsonWriter
        Writes a number to the writer.
        Specified by:
        writeNumber in interface StrictJsonWriter
        Parameters:
        value - the Double value, as a String so that clients can take full control over formatting
      • writeString

        public void writeString​(java.lang.String value)
        Description copied from interface: StrictJsonWriter
        Writes a String to the writer.
        Specified by:
        writeString in interface StrictJsonWriter
        Parameters:
        value - the String value
      • writeRaw

        public void writeRaw​(java.lang.String value)
        Description copied from interface: StrictJsonWriter
        Writes a raw value without quoting or escaping.
        Specified by:
        writeRaw in interface StrictJsonWriter
        Parameters:
        value - the String value