|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.xbus.base.core.config.Configuration
public class Configuration
This class reads program parameters from different sources and makes them accessible. The entries of the configuration are organized in a three-level hierarchie:
Configuration
implements the Singleton
Design-Pattern.
Up to now, only the Java- Properties
can be used as a source
for the configuration. Other sources like XML-files or a database are
prepared.
Field Summary | |
---|---|
static java.lang.String |
MAPPING_DEFAULT
|
static java.lang.String |
STANDARD_CONFIG
|
static java.lang.String |
VARIABLE_END
|
static java.lang.String |
VARIABLE_PREFIX
|
Method Summary | |
---|---|
java.util.List |
getChapters()
Returns a list of all chapters. |
static java.lang.String |
getClass(java.lang.String type,
java.lang.String name)
Returns an entry of the class table. |
static Configuration |
getInstance()
Returns an instance of the standard Configuration . |
static Configuration |
getInstance(java.lang.String source)
Returns a named instance of the Configuration . |
java.util.Map |
getKeysAndValues(java.lang.String chapter,
java.lang.String section)
Returns a map of all keys and their values for the given chapter and section. |
static java.lang.String |
getMapping(java.lang.String section,
java.lang.String key)
Returns an entry of the mapping table. |
static java.lang.String |
getMappingDefault(java.lang.String section)
|
static java.lang.String |
getMappingOptional(java.lang.String section,
java.lang.String key)
Returns an entry of the mapping table or null if it
doesn't exist. |
java.util.List |
getSections(java.lang.String chapter)
Returns a list of all sections for the given chapter |
java.lang.String |
getValue(java.lang.String chapter,
java.lang.String section,
java.lang.String key)
Returns the value of an entry. |
boolean |
getValueAsBoolean(java.lang.String chapter,
java.lang.String section,
java.lang.String key)
Returns the value of an entry as a boolean. |
boolean |
getValueAsBooleanOptional(java.lang.String chapter,
java.lang.String section,
java.lang.String key)
Returns the optional value of an entry as a boolean. |
int |
getValueAsInt(java.lang.String chapter,
java.lang.String section,
java.lang.String key)
Returns the value of an entry as an integer. |
int |
getValueAsIntOptional(java.lang.String chapter,
java.lang.String section,
java.lang.String key)
Returns the optional value of an entry as an integer. |
long |
getValueAsLongOptional(java.lang.String chapter,
java.lang.String section,
java.lang.String key)
Returns the optional value of an entry as an long value. |
java.lang.String |
getValueOptional(java.lang.String chapter,
java.lang.String section,
java.lang.String key)
Returns the value of an entry. |
static void |
refresh()
Creates an updated instance of the standard Configuration . |
static void |
refresh(java.lang.String source)
Creates an updated instance of the named Configuration . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String STANDARD_CONFIG
public static final java.lang.String VARIABLE_PREFIX
public static final java.lang.String VARIABLE_END
public static final java.lang.String MAPPING_DEFAULT
Method Detail |
---|
public static Configuration getInstance() throws XException
Configuration
.
The first call creates a new Configuration
and reads all
entries. Following calls will return the object, that has been created by
the first call.
Configuration
XException
- if any error occurspublic static Configuration getInstance(java.lang.String source) throws XException
Configuration
.
The first call creates a new Configuration
and reads all
entries. Following calls will return the object, that has been created by
the first call.
source
- the source of the properties.
Configuration
XException
- if any error occurspublic static void refresh() throws XException
Configuration
.
XException
- if any error occurspublic static void refresh(java.lang.String source) throws XException
Configuration
.
source
- the source of the properties
XException
- if any error occurspublic java.lang.String getValue(java.lang.String chapter, java.lang.String section, java.lang.String key) throws XException
If the desired entry can not be found, a XException
is
thrown.
chapter
- The first level from the three-level hierarchie hashtablesection
- The second level from the three-level hierarchie hashtable
that belongs to this chapterkey
- The bottom level from the three-level hierarchie hashtable
that belongs to these chapter and section
XException
- if the entry in configuration is not exist or any
error occurspublic int getValueAsInt(java.lang.String chapter, java.lang.String section, java.lang.String key) throws XException
If the desired entry can not be found or the value is not an integer, a
XException
is thrown.
chapter
- The first level from the three-level hierarchie hashtablesection
- The second level from the three-level hierarchie hashtable
that belongs to this chapterkey
- The bottom level from the three-level hierarchie hashtable
that belongs to these chapter and section
XException
- if the entry in configuratiuon is not exist or it
is not an integerpublic int getValueAsIntOptional(java.lang.String chapter, java.lang.String section, java.lang.String key) throws XException
If the desired entry is not an integer, a XException
is
thrown.
chapter
- The first level from the three-level hierarchie hashtablesection
- The second level from the three-level hierarchie hashtable
that belongs to this chapterkey
- The bottom level from the three-level hierarchie hashtable
that belongs to these chapter and section
0
is returned.
XException
- if the entry is not an integerpublic long getValueAsLongOptional(java.lang.String chapter, java.lang.String section, java.lang.String key) throws XException
If the desired entry is not an long value, a XException
is
thrown.
chapter
- The first level from the three-level hierarchie hashtablesection
- The second level from the three-level hierarchie hashtable
that belongs to this chapterkey
- The bottom level from the three-level hierarchie hashtable
that belongs to these chapter and section
0
is returned.
XException
- if the entry is not an integerpublic boolean getValueAsBoolean(java.lang.String chapter, java.lang.String section, java.lang.String key) throws XException
If the desired entry can not be found or the value is not a boolean, a
XException
is thrown.
chapter
- The first level from the three-level hierarchie hashtablesection
- The second level from the three-level hierarchie hashtable
that belongs to this chapterkey
- The bottom level from the three-level hierarchie hashtable
that belongs to these chapter and section
XException
- if the entry in the configuration is not exist or
it is not a boolean valuepublic boolean getValueAsBooleanOptional(java.lang.String chapter, java.lang.String section, java.lang.String key) throws XException
If the desired entry can not be found, false is returned. If the value is
not a boolean, a XException
is thrown.
chapter
- The first level from the three-level hierarchie hashtablesection
- The second level from the three-level hierarchie hashtable
that belongs to this chapterkey
- The bottom level from the three-level hierarchie hashtable
that belongs to these chapter and section
XException
- if the entry is not a boolean value or any error
occurspublic java.lang.String getValueOptional(java.lang.String chapter, java.lang.String section, java.lang.String key)
If the desired entry is not in the configuration, null
will be returned.
chapter
- The first level from the three-level hierarchie hashtablesection
- The second level from the three-level hierarchie hashtable
that belongs to this chapterkey
- The bottom level from the three-level hierarchie hashtable
that belongs to these chapter and section
public java.util.List getChapters()
XException
- if any error occurspublic java.util.List getSections(java.lang.String chapter)
chapter
- The first level from the three-level hierarchie hashtable
XException
- if any error occurspublic java.util.Map getKeysAndValues(java.lang.String chapter, java.lang.String section)
chapter
- The first level from the three-level hierarchie hashtablesection
- The second level from the three-level hierarchie hashtable
that belongs to this chapter
XException
- if any error occurspublic static java.lang.String getClass(java.lang.String type, java.lang.String name) throws XException
type
- The second level from the three-level hierarchie hashtable
that belongs to the chapter: Class name
- The bottom level from the three-level hierarchie hashtable
that belongs to the chapter: Class and this
section
XException
- if the entry is not found or any error occursgetValue(String, String, String)
public static java.lang.String getMapping(java.lang.String section, java.lang.String key) throws XException
section
- The second level from the three-level hierarchie hashtable
that belongs to the chapter: Mapping key
- The bottom level from the three-level hierarchie hashtable
that belongs to the chapter: Mapping and this
section
XException
- if the entry is not found or any error occursgetValue(String, String, String)
public static java.lang.String getMappingOptional(java.lang.String section, java.lang.String key) throws XException
null
if it
doesn't exist.
section
- The second level from the three-level hierarchie hashtable
that belongs to the chapter: Mapping key
- The bottom level from the three-level hierarchie hashtable
that belongs to the chapter: Mapping and this
section
XException
- if the entry is not found or any error occurspublic static java.lang.String getMappingDefault(java.lang.String section) throws XException
section
-
XException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |