Class Jsonb

java.lang.Object
org.postgresql.util.PGobject
net.bitnine.agensgraph.util.Jsonb
All Implemented Interfaces:
Serializable, Cloneable, JsonbObject

public class Jsonb extends org.postgresql.util.PGobject implements JsonbObject, Serializable, Cloneable
This class is for a Jsonb value which is returned from server or will be sent to the server.
See Also:
  • Field Summary

    Fields inherited from class org.postgresql.util.PGobject

    type, value
  • Constructor Summary

    Constructors
    Constructor
    Description
    This constructor should not be used directly.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if the given key is contained.
    Returns a Jsonb that wraps the array value if the Json value is array or throws UnsupportedOperationException.
    getArray(int index)
    Returns a Jsonb that wraps the array value if the value at index of the array is array or throws UnsupportedOperationException.
    Returns the value stored at the key.
    boolean
    Returns the boolean value if the Json value is boolean.
    boolean
    getBoolean(int index)
    Returns the boolean value if the value at index of the array is boolean or throws UnsupportedOperationException.
    boolean
    Returns the value stored at the key.
    boolean
    getBoolean(String key, boolean defaultValue)
    Returns the value stored at the key.
    double
    Returns the double value if the Json value is double or throws UnsupportedOperationException.
    double
    getDouble(int index)
    Returns the double value if the value at index of the array is double or throws UnsupportedOperationException.
    double
    Returns the value stored at the key.
    double
    getDouble(String key, double defaultValue)
    Returns the value stored at the key.
    int
    Returns the integer value if the Json value is integer or throws UnsupportedOperationException.
    int
    getInt(int index)
    Returns the integer value if the value at index of the array is integer or throws UnsupportedOperationException.
    int
    Returns the value stored at the key.
    int
    getInt(String key, int defaultValue)
    Returns the value stored at the key.
    Returns the internal structure (from json-simple 1.1.1) of the Json value.
    Returns a set of keys.
    long
    Returns the long value if the Json value is long or throws UnsupportedOperationException.
    long
    getLong(int index)
    Returns the long value if the value at index of the array is long or throws UnsupportedOperationException.
    long
    Returns the value stored at the key.
    long
    getLong(String key, long defaultValue)
    Returns the value stored at the key.
    Returns a Jsonb that wraps the object value if the Json value is object or throws UnsupportedOperationException.
    getObject(int index)
    Returns a Jsonb that wraps the object value if the value at index of the array is object or throws UnsupportedOperationException.
    Returns the value stored at the key.
    Returns the string value if the Json value is string or throws UnsupportedOperationException.
    getString(int index)
    Returns the string value if the value at index of the array is string or throws UnsupportedOperationException.
    Returns the value stored at the key.
    getString(String key, String defaultValue)
    Returns the value stored at the key.
    Returns an object that wraps automatically the value by type.
    Returns a string representation of the Json value.
    boolean
    Returns true if the Json value is null.
    boolean
    isNull(int index)
    Returns true if the value at index of the array is null or throws UnsupportedOperationException.
    boolean
    Returns true if the value stored at the key is null.
    void
    This method should not be used directly.
    int
    Returns the size of Json value if the value is array or object.
     
    Returns the string value if the Json value is string or returns null.

    Methods inherited from class org.postgresql.util.PGobject

    clone, equals, equals, getType, hashCode, setType

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Jsonb

      public Jsonb()
      This constructor should not be used directly.
  • Method Details

    • setValue

      public void setValue(String value) throws SQLException
      This method should not be used directly.
      Overrides:
      setValue in class org.postgresql.util.PGobject
      Throws:
      SQLException
    • getValue

      public String getValue()
      Returns a string representation of the Json value.
      Overrides:
      getValue in class org.postgresql.util.PGobject
      Returns:
      a string representation of the Json value
    • getJsonValue

      public Object getJsonValue()
      Returns the internal structure (from json-simple 1.1.1) of the Json value.
      Returns:
      the internal structure (from json-simple 1.1.1) of the Json value
    • tryGetString

      public String tryGetString()
      Returns the string value if the Json value is string or returns null.
      Returns:
      the string value if the Json value is string or returns null
    • getString

      public String getString()
      Returns the string value if the Json value is string or throws UnsupportedOperationException.
      Returns:
      the string value if the Json value is string or throws UnsupportedOperationException
      Throws:
      UnsupportedOperationException - not a string
    • getInt

      public int getInt()
      Returns the integer value if the Json value is integer or throws UnsupportedOperationException.
      Returns:
      the integer value if the Json value is integer or throws UnsupportedOperationException
      Throws:
      UnsupportedOperationException - not an int
    • getLong

      public long getLong()
      Returns the long value if the Json value is long or throws UnsupportedOperationException.
      Returns:
      the long value if the Json value is long or throws UnsupportedOperationException
      Throws:
      UnsupportedOperationException - not a long
    • getDouble

      public double getDouble()
      Returns the double value if the Json value is double or throws UnsupportedOperationException.
      Returns:
      the double value if the Json value is double or throws UnsupportedOperationException
      Throws:
      UnsupportedOperationException - not a double
    • getBoolean

      public boolean getBoolean()
      Returns the boolean value if the Json value is boolean.
      Returns:
      the boolean value if the Json value is boolean
    • isNull

      public boolean isNull()
      Returns true if the Json value is null.
      Overrides:
      isNull in class org.postgresql.util.PGobject
      Returns:
      true if the Json value is null
    • getArray

      public Jsonb getArray()
      Returns a Jsonb that wraps the array value if the Json value is array or throws UnsupportedOperationException.
      Returns:
      a Jsonb that wraps the array value if the Json value is array or throws UnsupportedOperationException
    • getObject

      public Jsonb getObject()
      Returns a Jsonb that wraps the object value if the Json value is object or throws UnsupportedOperationException.
      Returns:
      a Jsonb that wraps the object value if the Json value is object or throws UnsupportedOperationException
      Throws:
      UnsupportedOperationException - not an object
    • getString

      public String getString(int index)
      Returns the string value if the value at index of the array is string or throws UnsupportedOperationException.
      Parameters:
      index - the index of the array
      Returns:
      the string value if the value at index of the array is string or throws UnsupportedOperationException
      Throws:
      UnsupportedOperationException - not an array
    • getInt

      public int getInt(int index)
      Returns the integer value if the value at index of the array is integer or throws UnsupportedOperationException.
      Parameters:
      index - the index of the array
      Returns:
      the integer value if the value at index of the array is integer or throws UnsupportedOperationException
      Throws:
      UnsupportedOperationException - not an array
    • getLong

      public long getLong(int index)
      Returns the long value if the value at index of the array is long or throws UnsupportedOperationException.
      Parameters:
      index - the index of the array
      Returns:
      the long value if the value at index of the array is long or throws UnsupportedOperationException
      Throws:
      UnsupportedOperationException - not an array
    • getDouble

      public double getDouble(int index)
      Returns the double value if the value at index of the array is double or throws UnsupportedOperationException.
      Parameters:
      index - the index of the array
      Returns:
      the double value if the value at index of the array is double or throws UnsupportedOperationException
      Throws:
      UnsupportedOperationException - not an array
    • getBoolean

      public boolean getBoolean(int index)
      Returns the boolean value if the value at index of the array is boolean or throws UnsupportedOperationException.
      Parameters:
      index - the index of the array
      Returns:
      the boolean value if the value at index of the array is boolean or throws UnsupportedOperationException
      Throws:
      UnsupportedOperationException - not an array
    • getArray

      public Jsonb getArray(int index)
      Returns a Jsonb that wraps the array value if the value at index of the array is array or throws UnsupportedOperationException.
      Parameters:
      index - the index of the array
      Returns:
      a Jsonb that wraps the array value if the value at index of the array is array or throws UnsupportedOperationException
      Throws:
      UnsupportedOperationException - not an array
    • getObject

      public Jsonb getObject(int index)
      Returns a Jsonb that wraps the object value if the value at index of the array is object or throws UnsupportedOperationException.
      Parameters:
      index - the index of the array
      Returns:
      a Jsonb that wraps the object value if the value at index of the array is object or throws UnsupportedOperationException
      Throws:
      UnsupportedOperationException - not an array
    • isNull

      public boolean isNull(int index)
      Returns true if the value at index of the array is null or throws UnsupportedOperationException.
      Parameters:
      index - the index of the array
      Returns:
      true if the value at index of the array is null or throws UnsupportedOperationException
      Throws:
      UnsupportedOperationException - not an array
    • getKeys

      public Iterable<String> getKeys()
      Description copied from interface: JsonbObject
      Returns a set of keys.
      Specified by:
      getKeys in interface JsonbObject
      Returns:
      a set of keys
    • containsKey

      public boolean containsKey(String key)
      Description copied from interface: JsonbObject
      Returns true if the given key is contained.
      Specified by:
      containsKey in interface JsonbObject
      Parameters:
      key - the given key
      Returns:
      true if the given key is contained
    • getString

      public String getString(String key)
      Description copied from interface: JsonbObject
      Returns the value stored at the key.
      Specified by:
      getString in interface JsonbObject
      Parameters:
      key - the given key
      Returns:
      the string value stored at the key
    • getString

      public String getString(String key, String defaultValue)
      Description copied from interface: JsonbObject
      Returns the value stored at the key.
      Specified by:
      getString in interface JsonbObject
      Parameters:
      key - the given key
      defaultValue - returned the default value if the value stored at the key is null
      Returns:
      the string value stored at the key
    • getInt

      public int getInt(String key)
      Description copied from interface: JsonbObject
      Returns the value stored at the key.
      Specified by:
      getInt in interface JsonbObject
      Parameters:
      key - the given key
      Returns:
      the int value stored at the key
    • getInt

      public int getInt(String key, int defaultValue)
      Description copied from interface: JsonbObject
      Returns the value stored at the key.
      Specified by:
      getInt in interface JsonbObject
      Parameters:
      key - the given key
      defaultValue - returned the default value if the value stored at the key is null
      Returns:
      the int value stored at the key
    • getLong

      public long getLong(String key)
      Description copied from interface: JsonbObject
      Returns the value stored at the key.
      Specified by:
      getLong in interface JsonbObject
      Parameters:
      key - the given key
      Returns:
      the long value stored at the key
    • getLong

      public long getLong(String key, long defaultValue)
      Description copied from interface: JsonbObject
      Returns the value stored at the key.
      Specified by:
      getLong in interface JsonbObject
      Parameters:
      key - the given key
      defaultValue - returned the default value if the value stored at the key is null
      Returns:
      the long value stored at the key
    • getDouble

      public double getDouble(String key)
      Description copied from interface: JsonbObject
      Returns the value stored at the key.
      Specified by:
      getDouble in interface JsonbObject
      Parameters:
      key - the given key
      Returns:
      the double value stored at the key
    • getDouble

      public double getDouble(String key, double defaultValue)
      Description copied from interface: JsonbObject
      Returns the value stored at the key.
      Specified by:
      getDouble in interface JsonbObject
      Parameters:
      key - the given key
      defaultValue - returned the default value if the value stored at the key is null
      Returns:
      the double value stored at the key
    • getBoolean

      public boolean getBoolean(String key)
      Description copied from interface: JsonbObject
      Returns the value stored at the key.
      Specified by:
      getBoolean in interface JsonbObject
      Parameters:
      key - the given key
      Returns:
      the boolean value stored at the key
    • getBoolean

      public boolean getBoolean(String key, boolean defaultValue)
      Description copied from interface: JsonbObject
      Returns the value stored at the key.
      Specified by:
      getBoolean in interface JsonbObject
      Parameters:
      key - the given key
      defaultValue - returned the default value if the value stored at the key is null
      Returns:
      the boolean value stored at the key
    • getArray

      public Jsonb getArray(String key)
      Description copied from interface: JsonbObject
      Returns the value stored at the key.
      Specified by:
      getArray in interface JsonbObject
      Parameters:
      key - the given key
      Returns:
      the array value stored at the key
    • getObject

      public Jsonb getObject(String key)
      Description copied from interface: JsonbObject
      Returns the value stored at the key.
      Specified by:
      getObject in interface JsonbObject
      Parameters:
      key - the given key
      Returns:
      the object value stored at the key
    • isNull

      public boolean isNull(String key)
      Description copied from interface: JsonbObject
      Returns true if the value stored at the key is null.
      Specified by:
      isNull in interface JsonbObject
      Parameters:
      key - the given key
      Returns:
      true if the value stored at the key is null
    • size

      public int size()
      Returns the size of Json value if the value is array or object.
      Returns:
      the size of Json value if the value is array or object
    • getTypedValue

      public Object getTypedValue()
      Returns an object that wraps automatically the value by type.
      Returns:
      an object that wraps automatically the value by type
    • toString

      public String toString()
      Overrides:
      toString in class org.postgresql.util.PGobject