public final class Settings
extends java.lang.Object
implements java.io.Externalizable
connection
). Qualifiers are delimited by a dot (.
).Modifier and Type | Field and Description |
---|---|
private static java.util.Map<Database,Settings> |
all
Map of all configured settings, by database identifier
|
static java.lang.String |
BATCH_SIZE
JDBC batch size key
|
private java.util.TreeMap<java.lang.String,java.lang.Object> |
config
Configuration map for a particular database
|
static java.lang.String |
CPSTREAM
table dump file codepage, optional
|
static java.lang.String |
DATABASE_NAME
Database dialect key
|
static java.lang.String |
DIALECT
Database dialect key
|
static java.lang.String |
DRIVER
Connection driver class key
|
static java.lang.String |
FETCH_SIZE
JDBC fetch size key
|
static java.lang.String |
PASSWORD
Connection password key
|
static java.lang.String |
RELEASE_CONNECTIONS
Release connections key
|
private boolean |
temporary
Flag to indicate if the settings are made for a temporary database.
|
static java.lang.String |
URL
Connection URL key
|
static java.lang.String |
USER
Connection user name key
|
Constructor and Description |
---|
Settings()
Default constructor.
|
Settings(Database database)
Construct an instance of this class and store it by the given database for retrieval
later.
|
Settings(Database database,
java.util.Properties props)
Construct an instance of this class and store it by the given database for retrieval
later.
|
Modifier and Type | Method and Description |
---|---|
static Settings |
get(Database database)
Retrieve the settings for a particular database.
|
java.util.Map<java.lang.String,java.lang.Object> |
getAllForCategory(java.lang.String qualifier)
Get a map of the sub-set of settings whose keys are prefixed by the given qualifier.
|
java.lang.Boolean |
getBoolean(java.lang.String key,
java.lang.Boolean defaultValue)
Retrieve the setting with the given key, as a boolean.
|
java.lang.Integer |
getInteger(java.lang.String key,
java.lang.Integer defaultValue)
Retrieve the setting with the given key, as an integer.
|
java.lang.String |
getString(java.lang.String key,
java.lang.String defaultValue)
Retrieve the setting with the given key, as a string.
|
boolean |
put(java.lang.String key,
java.lang.Object value)
Store a setting, overwriting any previous setting with the same key.
|
void |
readExternal(java.io.ObjectInput in)
Replacement for the default object reading method.
|
void |
writeExternal(java.io.ObjectOutput out)
Replacement for the default object writing method.
|
public static final java.lang.String DATABASE_NAME
public static final java.lang.String DIALECT
public static final java.lang.String URL
public static final java.lang.String USER
public static final java.lang.String PASSWORD
public static final java.lang.String CPSTREAM
public static final java.lang.String DRIVER
public static final java.lang.String FETCH_SIZE
public static final java.lang.String BATCH_SIZE
public static final java.lang.String RELEASE_CONNECTIONS
private static final java.util.Map<Database,Settings> all
private java.util.TreeMap<java.lang.String,java.lang.Object> config
private boolean temporary
public Settings()
public Settings(Database database)
database
- Database with which these settings are associated.public Settings(Database database, java.util.Properties props)
database
- Database with which these settings are associated.props
- A set of properties that will be copied into the newly created @Settings@ object.public static Settings get(Database database) throws PersistenceException
database
- Database identifier.PersistenceException
- if no settings are found for the given database identifier.public java.lang.String getString(java.lang.String key, java.lang.String defaultValue)
key
- Setting key.defaultValue
- Default value if there is no setting with the given key. Set to null
to
indicate no default should be used.defaultValue
is null
, return
null
.java.lang.ClassCastException
- if the setting exists, but is not a String
.java.lang.NullPointerException
- if key
is null
.public java.lang.Integer getInteger(java.lang.String key, java.lang.Integer defaultValue)
key
- Setting key.defaultValue
- Default value if there is no setting with the given key. Set to null
to
indicate no default should be used.defaultValue
is null
, return
null
.java.lang.ClassCastException
- if the setting exists, but is not an Integer
.java.lang.NullPointerException
- if key
is null
.public java.lang.Boolean getBoolean(java.lang.String key, java.lang.Boolean defaultValue)
key
- Setting key.defaultValue
- Default value if there is no setting with the given key. Set to null
to
indicate no default should be used.defaultValue
is null
, return
null
.java.lang.ClassCastException
- if the setting exists, but is not a Boolean
.java.lang.NullPointerException
- if key
is null
.public boolean put(java.lang.String key, java.lang.Object value)
key
- Setting key.value
- Setting value.true
if the setting was newly stored; false
if a setting already
exists with the given key (the previous setting is still overwritten in this case).public java.util.Map<java.lang.String,java.lang.Object> getAllForCategory(java.lang.String qualifier)
qualifier
- Qualifier for the keys of the settings desired. If the qualifier does not match
any setting key, an empty map is returned.qualifier
, if any.
The elements will be ordered alphabetically by key.public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
out
- The output destination to which fields will be saved.java.io.IOException
- In case of I/O errors.public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
in
- Input source from which fields will be restored.java.io.IOException
- In case of I/O errors.java.lang.ClassNotFoundException
- If payload can't be instantiated.