| java.util.Properties org.cougaar.util.DBProperties
DBProperties | abstract public class DBProperties extends java.util.Properties (Code) | | This utility extends java.util.Properties by doing parameter
substitutions after loading a .q file. q files are cached, such that they
are only parsed once per VM.
.q files understood by this class are different from those
understood by QueryLDMPlugin and LDMSQLPlugin because the files are
not divided into query handler sections. Instead query handlers are
specified (when necessary) by the following convention: a property
named after the generic query type (e.g. locationQuery) and
suffixed with .handler is defined with a comma-separated list of
handler class names. Each handler class knows the name of the query
property that it uses.
|
Field Summary | |
final protected static Logger | log |
addQueryFile | public void addQueryFile(String qfile) throws IOException(Code) | | Add the queries from the given query file to this instance's collection.
Parameters: qfile - a String query file to parse exception: IOException - if an error occurs |
addQueryFile | public void addQueryFile(String qfile, String module) throws IOException(Code) | | Add the queries from the given query file to this instance's collection.
Parameters: qfile - a String query file to parse Parameters: module - the name of the module to search first for the query file exception: IOException - if an error occurs |
getDBType | public String getDBType()(Code) | | Accessor for the default database type string. This is the
string that is appended to query names (e.g. oracle) to form
the name of a database-specific query (or other value).
|
getDBType | public String getDBType(String dburl)(Code) | | Convert a db url into a database type string
|
getQuery | public String getQuery(String queryName, Map substitutions)(Code) | | Return a query with a given name. Variable substitution is
performed by looking for patterns which are the keys in a Map.
By convention, variable names start with a colon and are
alphanumeric, but this is not required. However, variable names
must not start with the name of another variable. For example,
:a and :aye are not allowed. The query is sought under two
different names, first by suffixing the given name with a dot
(.) and the default database type and, if that query is not
found, again without the suffix.
Parameters: queryName - the name of the query. Parameters: substitutions - The substitutions to be performed. Thequery is examined for occurances of the keys in the Map andreplaced with the corresponding value. |
getQueryForDatabase | public String getQueryForDatabase(String queryName, Map substitutions, String dbspec)(Code) | | Same as
DBProperties.getQuery(String,Map) above , but allows a
different database to be specified.
Parameters: queryName - the name of the query. Parameters: substitutions - a map of translations of substitution variables Parameters: dbspec - the key under which to find the database url forthis query. |
isLocked | abstract public boolean isLocked()(Code) | | |
load | public void load(InputStream i) throws IOException(Code) | | Load properties from an InputStream and post-process to perform
variable substitutions on the values. Substitution is done
using Parameters.replaceParameters.
This method should not normally be used and is defined only to
override the base class version and interpose parameter
replacements from cougaar.rc.
|
lock | abstract public DBProperties lock()(Code) | | Return a locked copy of this DBProperties object.
|
reReadQueryFile | public static DBProperties reReadQueryFile(String qfile) throws IOException(Code) | | Force Re-Read and parse a .q file. If the .q file contains value for
"database" (case-sensitive) the default database type is set accordingly. The
default database type may be set or changed manually with the
setDefaultDatabase method.
Parameters: qfile - the name of the query file |
reReadQueryFile | public static DBProperties reReadQueryFile(String qfile, String module) throws IOException(Code) | | Force Re-Read and parse a .q file. If the .q file contains value for
"database" (case-sensitive) the default database type is set accordingly. The
default database type may be set or changed manually with the
setDefaultDatabase method.
Parameters: qfile - the name of the query file Parameters: module - the name of the module to search first for the query file |
reReadQueryFile | public static DBProperties reReadQueryFile(URL url) throws IOException(Code) | | Force Re-read and parse a .q file specified as a URL. Even if the file was
previously read, re-read. If the .q file
contains a value for "database" (case-sensitive) the default database type is
set accordingly. The default database type may be set or
changed manually with the setDefaultDatabase method.
Parameters: url - the url to be opened to read the query file contents. |
readQueryFile | public static DBProperties readQueryFile(String qfile) throws IOException(Code) | | Read and parse a .q file. If the file was previously parsed, do not
re-read. If the .q file contains value for
"database" (case-sensitive) the default database type is set accordingly. The
default database type may be set or changed manually with the
setDefaultDatabase method.
Parameters: qfile - the name of the query file |
readQueryFile | public static DBProperties readQueryFile(String qfile, String module) throws IOException(Code) | | Read and parse a .q file. If the file was previously parsed, do not
re-read. If the .q file contains value for
"database" (case-sensitive) the default database type is set accordingly. The
default database type may be set or changed manually with the
setDefaultDatabase method.
Parameters: qfile - the name of the query file Parameters: module - the name of the module to search first for the query file |
readQueryFile | public static DBProperties readQueryFile(URL url) throws IOException(Code) | | Read and parse a .q file specified as a URL. If the file was
previously read, do not re-read. If the .q file
contains a value for "database" (case-sensitive) the default database type is
set accordingly. The default database type may be set or
changed manually with the setDefaultDatabase method.
Parameters: url - the url to be opened to read the query filecontents. |
setDebug | public void setDebug(boolean newDebug)(Code) | | Enable debugging. When debugging is enabled, the queries are
printed after substitution has been performed
|
setDefaultDatabase | public void setDefaultDatabase(String dburl)(Code) | | Change the database specification. The database specification
is the name of a database url parameter found using in this
DBProperties.
Parameters: dburl - the jdbc url of the database in which the queriesare to be executed. The database type is extracted from the urland used for getting queries tailored for that database. |
unlock | abstract public DBProperties unlock()(Code) | | Return an unlocked copy of this DBProperties object.
|
|
|