Class JSONStringTarget

java.lang.Object
org.h2.util.json.JSONTarget<String>
org.h2.util.json.JSONStringTarget

public final class JSONStringTarget extends JSONTarget<String>
JSON String target.
  • Field Details

    • HEX

      static final char[] HEX
      The hex characters.
    • OBJECT

      static final byte OBJECT
      A JSON object.
      See Also:
    • ARRAY

      static final byte ARRAY
      A JSON array.
      See Also:
    • builder

      private final StringBuilder builder
    • stack

      private final ByteStack stack
    • asciiPrintableOnly

      private final boolean asciiPrintableOnly
    • needSeparator

      private boolean needSeparator
    • afterName

      private boolean afterName
  • Constructor Details

    • JSONStringTarget

      public JSONStringTarget()
      Creates new instance of JSON String target.
    • JSONStringTarget

      public JSONStringTarget(boolean asciiPrintableOnly)
      Creates new instance of JSON String target.
      Parameters:
      asciiPrintableOnly - whether all non-printable, non-ASCII characters, and ' (single quote) characters should be escaped
  • Method Details

    • encodeString

      public static StringBuilder encodeString(StringBuilder builder, String s, boolean asciiPrintableOnly)
      Encodes a JSON string and appends it to the specified string builder.
      Parameters:
      builder - the string builder to append to
      s - the string to encode
      asciiPrintableOnly - whether all non-printable, non-ASCII characters, and ' (single quote) characters should be escaped
      Returns:
      the specified string builder
    • startObject

      public void startObject()
      Description copied from class: JSONTarget
      Start of an object.
      Specified by:
      startObject in class JSONTarget<String>
    • endObject

      public void endObject()
      Description copied from class: JSONTarget
      End of the current object.
      Specified by:
      endObject in class JSONTarget<String>
    • startArray

      public void startArray()
      Description copied from class: JSONTarget
      Start of an array.
      Specified by:
      startArray in class JSONTarget<String>
    • endArray

      public void endArray()
      Description copied from class: JSONTarget
      End of the current array.
      Specified by:
      endArray in class JSONTarget<String>
    • member

      public void member(String name)
      Description copied from class: JSONTarget
      Name of a member.
      Specified by:
      member in class JSONTarget<String>
      Parameters:
      name - the name
    • valueNull

      public void valueNull()
      Description copied from class: JSONTarget
      Parse "null". null value.
      Specified by:
      valueNull in class JSONTarget<String>
    • valueFalse

      public void valueFalse()
      Description copied from class: JSONTarget
      Parse "false". false value.
      Specified by:
      valueFalse in class JSONTarget<String>
    • valueTrue

      public void valueTrue()
      Description copied from class: JSONTarget
      Parse "true". true value.
      Specified by:
      valueTrue in class JSONTarget<String>
    • valueNumber

      public void valueNumber(BigDecimal number)
      Description copied from class: JSONTarget
      A number value.
      Specified by:
      valueNumber in class JSONTarget<String>
      Parameters:
      number - the number
    • valueString

      public void valueString(String string)
      Description copied from class: JSONTarget
      A string value.
      Specified by:
      valueString in class JSONTarget<String>
      Parameters:
      string - the string
    • beforeValue

      private void beforeValue()
    • afterValue

      private void afterValue()
    • isPropertyExpected

      public boolean isPropertyExpected()
      Description copied from class: JSONTarget
      Returns whether member's name or the end of the current object is expected.
      Specified by:
      isPropertyExpected in class JSONTarget<String>
      Returns:
      true if it is, false otherwise
    • isValueSeparatorExpected

      public boolean isValueSeparatorExpected()
      Description copied from class: JSONTarget
      Returns whether value separator expected before the next member or value.
      Specified by:
      isValueSeparatorExpected in class JSONTarget<String>
      Returns:
      true if it is, false otherwise
    • getResult

      public String getResult()
      Description copied from class: JSONTarget
      Returns the result.
      Specified by:
      getResult in class JSONTarget<String>
      Returns:
      the result