Class JSONNull

java.lang.Object
org.kordamp.json.JSONNull
All Implemented Interfaces:
Serializable, JSON

public final class JSONNull extends Object implements JSON
JSONNull is equivalent to the value that JavaScript calls null, whilst Java's null is equivalent to the value that JavaScript calls undefined.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static JSONNull
    singleton instance
    private static final long
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(Object object)
    A Null object is equal to the null value and to itself.
    static JSONNull
    Returns the singleton instance of JSONNull
    int
     
    boolean
    Returns true if this object is a JSONArray, false otherwise.
    boolean
    Returns true if this object has no elements or keys.
    int
    Returns the number of properties in an object or the size of the array.
    Get the "null" string value.
    toString(int indentFactor)
    Make a prettyprinted JSON text.
    toString(int indentFactor, int indent)
    Make a prettyprinted JSON text.
    write(Writer writer)
    Write the contents as JSON text to a writer.
    Writes the canonicalized form of this JSON object.

    Methods inherited from class java.lang.Object

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

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • instance

      private static JSONNull instance
      singleton instance
  • Constructor Details

    • JSONNull

      private JSONNull()
  • Method Details

    • getInstance

      public static JSONNull getInstance()
      Returns the singleton instance of JSONNull
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object object)
      A Null object is equal to the null value and to itself.
      Overrides:
      equals in class Object
      Parameters:
      object - An object to test for nullness.
      Returns:
      true if the object parameter is the JSONObject.NULL object or null.
    • toString

      public String toString()
      Get the "null" string value.
      Overrides:
      toString in class Object
      Returns:
      The string "null".
    • isArray

      public boolean isArray()
      Description copied from interface: JSON
      Returns true if this object is a JSONArray, false otherwise.
      Specified by:
      isArray in interface JSON
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: JSON
      Returns true if this object has no elements or keys.
      Specified by:
      isEmpty in interface JSON
    • size

      public int size()
      Description copied from interface: JSON
      Returns the number of properties in an object or the size of the array.
      Specified by:
      size in interface JSON
      Returns:
      the size of an json object or array
    • toString

      public String toString(int indentFactor)
      Description copied from interface: JSON
      Make a prettyprinted JSON text.

      Warning: This method assumes that the data structure is acyclical.

      Specified by:
      toString in interface JSON
      Parameters:
      indentFactor - The number of spaces to add to each level of indentation.
      Returns:
      a printable, displayable, portable, transmittable representation of the object, beginning with { (left brace) and ending with } (right brace).
    • toString

      public String toString(int indentFactor, int indent)
      Description copied from interface: JSON
      Make a prettyprinted JSON text.

      Warning: This method assumes that the data structure is acyclical.

      Specified by:
      toString in interface JSON
      Parameters:
      indentFactor - The number of spaces to add to each level of indentation.
      indent - The indentation of the top level.
      Returns:
      a printable, displayable, transmittable representation of the object, beginning with { (left brace) and ending with } (right brace).
    • write

      public Writer write(Writer writer) throws IOException
      Description copied from interface: JSON
      Write the contents as JSON text to a writer. For compactness, no whitespace is added.

      Warning: This method assumes that the data structure is acyclical.

      Specified by:
      write in interface JSON
      Returns:
      The writer.
      Throws:
      IOException
    • writeCanonical

      public Writer writeCanonical(Writer w) throws IOException
      Description copied from interface: JSON
      Writes the canonicalized form of this JSON object.
      Specified by:
      writeCanonical in interface JSON
      Throws:
      IOException