Constructor and Description |
---|
SimpleDatabaseManager(String parameterString)
Construct a simple database manager from a parameter string using default
separators and keys.
|
SimpleDatabaseManager(String dbName,
String dbClass,
String tdcClass,
Map<String,String> parameters)
Construct a database manager with a name, a class, and a map of
configuration parameters.
|
SimpleDatabaseManager(String listSeparator,
String kvSeparator,
String dbNameKey,
String dbClassKey,
String tdcClassKey,
String fileKey,
String parameterString)
Construct a simple database manager from a parameter string.
|
Modifier and Type | Method and Description |
---|---|
Database |
getDatabase()
Return the database corresponding to the configuration.
|
Map<String,String> |
getParameters()
Return the map containing configuration parameters.
|
public SimpleDatabaseManager(String dbName, String dbClass, String tdcClass, Map<String,String> parameters)
dbName
- the name of the databasedbClass
- the name of a Database
classtdcClass
- the name of a TimeDomainCatalog
class or null or emptyparameters
- a map of key-value pairspublic SimpleDatabaseManager(String listSeparator, String kvSeparator, String dbNameKey, String dbClassKey, String tdcClassKey, String fileKey, String parameterString) throws T2DBException
Key-value pairs are interpreted as parameters except if the key is a file key. In this case the value is interpreted as an absolute file name. The file contains one key-value pair on each line (with the same key-value separator). Lines can be continued by escaping the end of the line with a backslash. Lines starting with a hash sign are ignored. Files can reference files recursively using the file key mechanism.
The file named by a file key can be followed by key mappings, like this:
file=/foo/bar.txt, x=a, y=b
When key mappings are present, only the mapped keys are extracted from the file (x and y) and
they are renamed as specified (a and b). Key remapping is only available inside
files, because the list separators are the same at all levels. If the example
above were included in a parameter string and not a file, x=a would be
interpreted as an independent parameter and not as a key mapping.
The database name and the name of the database class are mandatory. An exception is thrown if the parameter string cannot be parsed successfully.
listSeparator
- a regular expression pattern separating list elementskvSeparator
- a regular expression pattern separating a key and a valuedbNameKey
- the key for the database namedbClassKey
- the key for the name of the Database
classtdcClassKey
- the key for the name of the TimeDomainCatalog
classfileKey
- a key naming a fileparameterString
- a parameter stringT2DBException
public SimpleDatabaseManager(String parameterString) throws T2DBException
db.name, the database class key is
db.class, and the file tag is
file.
parameterString
- a parameter stringT2DBException
public Database getDatabase() throws ch.agent.core.KeyedException
ch.agent.core.KeyedException
public Map<String,String> getParameters()
Copyright © 2017. All rights reserved.