|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.core.Config
public class Config
Use this class to access the configuration settings for BASE.
The configuration settings are always stored in a file named
base.config
. It should be located at the root of
one of the paths in the CLASSPATH environment variable. For Tomcat this
means it should be located in the WEB-INF/classes
folder.
Field Summary | |
---|---|
private static SortedSet<String> |
allCharsets
|
private static SortedSet<String> |
commonCharsets
|
private static Properties |
config
Variable for holding the configuration properties. |
private static File |
configDir
|
private static boolean |
isInitialised
|
private static Locale |
locale
|
private static Properties |
overridden
Properties that has been programmatically overridden. |
Constructor Summary | |
---|---|
Config()
|
Method Summary | |
---|---|
static SortedSet<String> |
getAllCharsets()
Get a set containing all character sets known to the current java virtual machine. |
static boolean |
getBoolean(String key)
Get the configuration setting specified by key as a boolean
value. |
static String |
getCharset()
Get the default character set to use when no other has been specified. |
static SortedSet<String> |
getCommonCharsets()
Get a set containing the most common character sets used by text files. |
static File |
getConfigDirectory()
Get the directory where the BASE configuration files are located. |
static int |
getInt(String key)
Get the configuration setting specified by key as an integer value. |
static int |
getInt(String key,
int defaultValue)
Get the configuration setting specified by key as an integer value. |
static Locale |
getLocale()
Get the default locale configured for the server. |
static long |
getLong(String key,
long defaultValue)
Get the configuration setting specified by key as a long value. |
static String |
getString(String key)
Get the configuration setting specified by key as a String value. |
static String |
getString(String key,
String defaultValue)
Get the configuration setting specified by key as a String value. |
(package private) static void |
init()
Loads the settings from the configuration file. |
static void |
setProperty(String key,
String value)
Programatically set a configuration property that overrides a configuration setting in the base.config file. |
(package private) static void |
unload()
Unload all settings. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static Properties config
private static Properties overridden
private static boolean isInitialised
private static File configDir
private static Locale locale
private static SortedSet<String> commonCharsets
private static SortedSet<String> allCharsets
Constructor Detail |
---|
public Config()
Method Detail |
---|
static void init() throws ConfigurationException
ConfigurationException
- This exception is thrown if the
configuration settings cannot be loadedstatic void unload()
public static void setProperty(String key, String value)
init()
method is called (eg. before Application.start()
is called). The configuration can't be changed once BASE has been started.
Properties that has been overridden are automatically cleared when BASE is
stopped (Application.stop()
, unload()
).
key
- The name of the configuration propertyvalue
- The value or null to remove the overridden propertypublic static File getConfigDirectory()
java.io.File
objectpublic static String getString(String key)
key
as a String value.
key
- The key for the setting
key
or null if it is not foundpublic static String getString(String key, String defaultValue)
key
as a String value.
key
- The key for the settingdefaultValue
- The value to return if the key
is not found
key
or defaultValue
if it is not found or is emptypublic static int getInt(String key)
key
as an integer value.
key
- The key for the setting
key
or 0 if it is not found or
is not a numberpublic static int getInt(String key, int defaultValue)
key
as an integer value.
key
- The key for the settingdefaultValue
- The value to return if the key
is not found
key
or defaultValue
if it is not foundpublic static long getLong(String key, long defaultValue)
key
as a long value.
key
- The key for the settingdefaultValue
- The value to return if the key
is not found
key
or defaultValue
if it is not foundpublic static boolean getBoolean(String key)
key
as a boolean
value. FALSE is returned if the setting doesn't exist, if it contains an
empty string, or one of the values 'no', 'false' or '0'.
In all other cases TRUE is returned.
key
- The key for the setting
key
public static String getCharset()
defaultCharset
setting and uses ISO-8859-1
if not specified.
public static SortedSet<String> getCommonCharsets()
public static SortedSet<String> getAllCharsets()
public static Locale getLocale()
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |