Package de.oliver.fancylib.jdb
Class JDocument
java.lang.Object
de.oliver.fancylib.jdb.JDocument
Represents a document that holds a map of key-value pairs with support for nested keys.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if the document contains a value associated with the given key.Retrieves a value from the document using the given key.booleangetBoolean(String key) Retrieves a boolean value associated with the given key.byteRetrieves a byte value associated with the given key.doubleRetrieves a double value associated with the given key.floatRetrieves a float value associated with the given key.intRetrieves an integer value associated with the given key from the document.Retrieves the set of keys from a map value associated with a given key in the document.longRetrieves a long value associated with the given key.shortRetrieves a short value associated with the given key.Retrieves a string value from the document using the given key.
-
Constructor Details
-
JDocument
-
-
Method Details
-
get
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
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
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
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
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
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
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
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
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
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
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
-