|
jacquard 1.12.0 by The Web Engineering Factory and Toolworks | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.Dictionary
java.util.Hashtable
uk.co.weft.dbutil.Context
A namespace in which to hold arbitrary values. Because so many databases mangle case, the namespace is deemed to be case-insensitive, which is to say both puts and gets are mapped to lower case. Note that this does not inherit from Properties, because the values are arbitrary objects. A load() method is provided similar to Properties.load(), and a store() method similat to Properties.store(). However, it is not guaranteed that a store followed by a load will restore a Context, because not everything that can be held in a Context can be recovered from it's printed form.
| Field Summary | |
static java.lang.String |
endOfCommentMagicToken
Deprecated. there should be no need to use this |
static java.lang.String |
startOfCommentMagicToken
Deprecated. there should be no need to use this |
| Constructor Summary | |
Context()
the default constructor does nothing. |
|
| Method Summary | |
void |
comment(java.lang.String message)
Deprecated. don't use this. Write to your log instead if you have one; otherwise write to standard error (which is what this now does) |
void |
copyDBTokens(java.util.Dictionary donor)
Copy into me the values of the the database magic tokens (URL, username and password) from this donor context |
java.lang.Object |
get(java.lang.String token)
Get the value associated with this token in this context. |
java.lang.Object |
get(java.lang.String token,
java.lang.Object dflt)
Return the value associated with this token if not null else this default |
java.sql.Connection |
getConnection()
Get a database connection using the following magic names in my own name-space: 'db_url', 'db_username', 'db_password'. |
java.sql.Connection |
getConnection(java.lang.String url,
java.lang.String username,
java.lang.String password)
Deprecated. this is really horribly bad design. You should use ConnectionPool.getConnection() instead. |
protected java.util.Enumeration |
getKeys()
Deprecated. probably better to use keys() |
java.lang.Object |
getValue(java.lang.String token)
Deprecated. probably better to use get() |
java.lang.Boolean |
getValueAsBoolean(java.lang.String token)
Coerce this value to a boolean and return it as a Boolean object, not as a bool. |
java.util.Calendar |
getValueAsCalendar(java.lang.String token)
Extract the value associated with this token as a java.util.Calendar object |
java.lang.Character |
getValueAsCharacter(java.lang.String token)
Coerce this value to a Character and return it. |
java.awt.Color |
getValueAsColor(java.lang.String token)
Coerce this value to a java.awt.Color object and return it. |
Currency |
getValueAsCurrency(java.lang.String token)
Coerce the value of this token to a Currency object and return it. |
java.lang.Double |
getValueAsDouble(java.lang.String token)
Coerce this value to a double and return it as a Double object, not as a double. |
java.io.File |
getValueAsFile(java.lang.String token)
Coerce this value to a File object (if this is possible) and return it. |
java.lang.Float |
getValueAsFloat(java.lang.String token)
Coerce this value to a float and return it as a Float object, not as a float. |
java.lang.Integer |
getValueAsInteger(java.lang.String token)
Coerce this value to an integer and return it as an Integer object, not as an int. |
java.lang.String |
getValueAsString(java.lang.String token)
Coerce this value to a String and return it. |
boolean |
intersectMatch(Context compare)
True iff for all the names which I have which compare also has, I have the same values for those names as compare has. |
java.util.Enumeration |
keys()
Return my keys. |
void |
load(java.io.InputStream src)
Load values into this context from this stream. |
Context |
merge(java.util.Dictionary other)
Deprecated. the Dictionary class is obsolete; use merge(Map) instead. |
Context |
merge(java.util.Map other)
Merge values from this context (or other Map) into me, preferring my own existing values where there are conflicts. |
void |
put(java.lang.String token,
boolean value)
A hack around the fact that Java isn't fully object oriented. |
void |
put(java.lang.String token,
double value)
A hack around the fact that Java isn't fully object oriented. |
void |
put(java.lang.String token,
int value)
A hack around the fact that Java isn't fully object oriented. |
void |
put(java.lang.String token,
java.lang.Object value)
Set the value associated with this token to this value. |
void |
putValue(java.lang.String token,
java.lang.Object value)
Deprecated. probably better to use put() |
void |
releaseConnection(java.sql.Connection c)
Release this connection back into my free connections pool. |
void |
releaseConnection(java.sql.Connection c,
boolean dontCloseStatements)
Deprecated. setting dontCloseStatements to true may be associated with connection pool leaks: use with great caution. |
void |
store(java.io.OutputStream out,
java.lang.String header)
Write my keys and values to the output stream in a format which can be read by 'load'. |
void |
unwatch(java.lang.String token)
remove this token from the list of tokens I am watching |
void |
watch(java.lang.String token)
print a stack trace to standard error whenever the value of this token in this context changes |
| Methods inherited from class java.util.Hashtable |
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, rehash, remove, size, toString, values |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final java.lang.String startOfCommentMagicToken
public static final java.lang.String endOfCommentMagicToken
| Constructor Detail |
public Context()
| Method Detail |
public java.sql.Connection getConnection(java.lang.String url,
java.lang.String username,
java.lang.String password)
throws DataStoreException
DataStoreException - throws a DataAuthException if an
unambiguous authentication failure occurs, a
DataStoreException if for some other reason no connection
could be established.ConnectionPool.getConnection(java.lang.String, java.lang.String, java.lang.String)
public java.sql.Connection getConnection()
throws DataStoreException
throws - DataAuthException if a authorisation fails,
DataStoreException if database connection cannot be
established for some other reason
DataStoreExceptionConnectionPool.dbUrlMagicToken,
ConnectionPool.dbUserMagicToken,
ConnectionPool.dbPassMagicTokenpublic java.lang.Object getValue(java.lang.String token)
public java.lang.Boolean getValueAsBoolean(java.lang.String token)
token - the name against which the value to be returned is stored
in this context
public java.util.Calendar getValueAsCalendar(java.lang.String token)
throws DataFormatException
DataFormatExceptionpublic java.lang.Character getValueAsCharacter(java.lang.String token)
public java.awt.Color getValueAsColor(java.lang.String token)
throws DataFormatException
throws - DataFormatException if value is not null and cannot
be coerced to a colour
DataFormatException
public Currency getValueAsCurrency(java.lang.String token)
throws java.lang.NumberFormatException,
DataFormatException
throws - NumberFormatException if value is not null and cannot
be coerced to a float
java.lang.NumberFormatException
DataFormatException
public java.lang.Double getValueAsDouble(java.lang.String token)
throws java.lang.NumberFormatException
throws - NumberFormatException if value is not null and cannot
be coerced to a double
java.lang.NumberFormatExceptionpublic java.io.File getValueAsFile(java.lang.String token)
token - the token which identified that value to be returned
public java.lang.Float getValueAsFloat(java.lang.String token)
throws java.lang.NumberFormatException
throws - NumberFormatException if value is not null and cannot
be coerced to a float
java.lang.NumberFormatException
public java.lang.Integer getValueAsInteger(java.lang.String token)
throws java.lang.NumberFormatException
throws - NumberFormatException if value is not null and cannot
be coerced to an integer
java.lang.NumberFormatExceptionpublic java.lang.String getValueAsString(java.lang.String token)
public void comment(java.lang.String message)
public void copyDBTokens(java.util.Dictionary donor)
donor - the dictionary (usually a context) which is providing the
token valuespublic java.lang.Object get(java.lang.String token)
token - the (non-case-sensitive) name whose value is sought
public java.lang.Object get(java.lang.String token,
java.lang.Object dflt)
public boolean intersectMatch(Context compare)
public java.util.Enumeration keys()
public void load(java.io.InputStream src)
throws java.io.IOException
java.io.IOExceptionpublic Context merge(java.util.Dictionary other)
other - the context to merge in.
public Context merge(java.util.Map other)
other - the context to merge in.
public void put(java.lang.String token,
java.lang.Object value)
public void put(java.lang.String token,
int value)
public void put(java.lang.String token,
double value)
public void put(java.lang.String token,
boolean value)
public void putValue(java.lang.String token,
java.lang.Object value)
public void releaseConnection(java.sql.Connection c)
throws DataStoreException
DataStoreException
public void releaseConnection(java.sql.Connection c,
boolean dontCloseStatements)
throws DataStoreException
DataStoreException
public void store(java.io.OutputStream out,
java.lang.String header)
throws java.io.IOException
java.io.IOExceptionpublic void unwatch(java.lang.String token)
token - the token which no longer needs to be watchedwatch(String)public void watch(java.lang.String token)
token - the token to watchprotected java.util.Enumeration getKeys()
|
jacquard 1.12.0 by The Web Engineering Factory and Toolworks | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||