Package de.oliver.jdb

Class JDocument

java.lang.Object
de.oliver.jdb.JDocument

public class JDocument extends Object
Represents a document that holds a map of key-value pairs with support for nested keys.
  • Constructor Details

  • Method Details

    • get

      public Object get(String key)
      Retrieves a value from the document using the given key.
      Parameters:
      key - the dot-separated key used to locate the value in the document (e.g. "foo.bar.baz")
      Returns:
      the value associated with the given key, or null if the key is not found
    • contains

      public boolean contains(String key)
      Checks if the document contains a value associated with the given key.
      Parameters:
      key - the dot-separated key used to locate the value in the document (e.g. "foo.bar.baz")
      Returns:
      true if the given key exists in the document, otherwise false
    • getKeys

      public Set<String> getKeys(String key)
      Retrieves the set of keys from a map value associated with a given key in the document.
      Parameters:
      key - the dot-separated key used to locate the map value in the document (e.g. "foo.bar.baz")
      Returns:
      a set of keys from the map associated with the given key, or an empty set if the key is not found or the value is not a map
    • getString

      public String getString(String key)
      Retrieves a string value from the document using the given key.
      Parameters:
      key - the dot-separated key used to locate the value in the document (e.g. "foo.bar.baz")
      Returns:
      the string value associated with the given key, or an empty string if the key is not found or the value is not a string
    • getBoolean

      public boolean getBoolean(String key)
      Retrieves a boolean value associated with the given key.
      Parameters:
      key - the dot-separated key used to locate the value in the document (e.g. "foo.bar.baz")
      Returns:
      the boolean value associated with the given key, or false if the key is not found or the value is not a boolean
    • getByte

      public byte getByte(String key)
      Retrieves a byte value associated with the given key.
      Parameters:
      key - the dot-separated key used to locate the value in the document (e.g. "foo.bar.baz")
      Returns:
      the byte value associated with the given key, or 0 if the key is not found or the value is not a byte
    • getShort

      public short getShort(String key)
      Retrieves a short value associated with the given key.
      Parameters:
      key - the dot-separated key used to locate the value in the document (e.g. "foo.bar.baz")
      Returns:
      the short value associated with the given key, or 0 if the key is not found or the value is not a short
    • getInt

      public int getInt(String key)
      Retrieves an integer value associated with the given key from the document.
      Parameters:
      key - the dot-separated key used to locate the value in the document (e.g. "foo.bar.baz")
      Returns:
      the integer value associated with the given key, or 0 if the key is not found or the value is not an integer
    • getLong

      public long getLong(String key)
      Retrieves a long value associated with the given key.
      Parameters:
      key - the dot-separated key used to locate the value in the document (e.g. "foo.bar.baz")
      Returns:
      the long value associated with the given key, or 0 if the key is not found or the value is not a long
    • getFloat

      public float getFloat(String key)
      Retrieves a float value associated with the given key.
      Parameters:
      key - the dot-separated key used to locate the value in the document (e.g. "foo.bar.baz")
      Returns:
      the float value associated with the given key, or 0 if the key is not found or the value is not a float
    • getDouble

      public double getDouble(String key)
      Retrieves a double value associated with the given key.
      Parameters:
      key - the dot-separated key used to locate the value in the document (e.g. "foo.bar.baz")
      Returns:
      the double value associated with the given key, or 0 if the key is not found or the value is not a double