Class JSONBytesSource

java.lang.Object
org.h2.util.json.JSONTextSource
org.h2.util.json.JSONBytesSource

public final class JSONBytesSource extends JSONTextSource
JSON byte array source.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final byte[]
     
    private int
     
    private final int
     

    Fields inherited from class org.h2.util.json.JSONTextSource

    target
  • Constructor Summary

    Constructors
    Constructor
    Description
    JSONBytesSource(byte[] bytes, JSONTarget<?> target)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) int
    Read the next character.
    (package private) int
    Skip all whitespace characters, and get the next character.
    static byte[]
    normalize(byte[] bytes)
    Converts bytes into normalized JSON representation.
    static <R> R
    parse(byte[] bytes, JSONTarget<R> target)
    Parses source bytes to a specified target.
    (package private) void
    parseNumber(boolean positive)
    Parse a number.
    (package private) char
    Read 4 hex characters (0-9, a-f, A-F), and return the Unicode character.
    (package private) void
    Read the specified keyword, or (it there is no match), throw an IllegalArgumentException.
    private int
    skipInt(int index, boolean hasInt)
     
     

    Methods inherited from class org.h2.util.json.JSONTextSource

    parse

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • bytes

      private final byte[] bytes
    • length

      private final int length
    • index

      private int index
  • Constructor Details

    • JSONBytesSource

      JSONBytesSource(byte[] bytes, JSONTarget<?> target)
  • Method Details

    • parse

      public static <R> R parse(byte[] bytes, JSONTarget<R> target)
      Parses source bytes to a specified target.
      Type Parameters:
      R - the type of the result
      Parameters:
      bytes - source
      target - target
      Returns:
      the result of the target
    • normalize

      public static byte[] normalize(byte[] bytes)
      Converts bytes into normalized JSON representation.
      Parameters:
      bytes - source representation
      Returns:
      normalized representation
    • nextCharAfterWhitespace

      int nextCharAfterWhitespace()
      Description copied from class: JSONTextSource
      Skip all whitespace characters, and get the next character.
      Specified by:
      nextCharAfterWhitespace in class JSONTextSource
      Returns:
      the character code
    • readKeyword1

      void readKeyword1(String keyword)
      Description copied from class: JSONTextSource
      Read the specified keyword, or (it there is no match), throw an IllegalArgumentException.
      Specified by:
      readKeyword1 in class JSONTextSource
      Parameters:
      keyword - the expected keyword
    • parseNumber

      void parseNumber(boolean positive)
      Description copied from class: JSONTextSource
      Parse a number.
      Specified by:
      parseNumber in class JSONTextSource
      Parameters:
      positive - whether it needs to be positive
    • skipInt

      private int skipInt(int index, boolean hasInt)
    • nextChar

      int nextChar()
      Description copied from class: JSONTextSource
      Read the next character.
      Specified by:
      nextChar in class JSONTextSource
      Returns:
      the character code
    • readHex

      char readHex()
      Description copied from class: JSONTextSource
      Read 4 hex characters (0-9, a-f, A-F), and return the Unicode character.
      Specified by:
      readHex in class JSONTextSource
      Returns:
      the character
    • toString

      public String toString()
      Overrides:
      toString in class Object