Config Class

Provides thread-safe methods used to get and set application variables.

Constructors

Config( )

Public Methods

init( JSONObject json ) returns void
Used to initialize the config with a given JSON document. This will replace any previously assigned config values.
get( String key ) returns JSONValue
Returns the value for a given key.
get( String... path ) returns JSONValue
Returns a nested value associated with the given keys
set( String key, Object value ) returns void
Used to set the value for a given key.
has( String key ) returns boolean
Returns true if the config has a given key.
getKeys( ) returns ArrayList<String>
Returns a list of keys found in the config.
isEmpty( ) returns boolean
Returns true if there are no entries in the config.
getDatabase( ) returns javaxt.sql.Database
Returns a Database assigned to a "database" key.
setDatabase( javaxt.sql.Database database ) returns void
Used to assign a Database to a "database" key.
toJson( ) returns JSONObject
Returns the current config in JSON notation.

Static Methods

getDatabase( JSONValue val ) returns javaxt.sql.Database
Used to parse database connection information found in a given JSONValue and returns a Database object.
getDatabase( JSONObject json ) returns javaxt.sql.Database
Used to parse database connection information found in a given JSONObject and returns a Database object. Example:
    {
        "driver": "PostgreSQL",
        "host": "localhost:5432",
        "name": "test",
        "username": "postgres",
        "password": "xxxxxxxx",
        "maxConnections": 35
    }