velosurf.context
Class DBReference

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<java.lang.String,java.lang.Object>
          extended by velosurf.context.DBReference
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,java.lang.Object>
Direct Known Subclasses:
Velosurf, VelosurfTool

public class DBReference
extends java.util.HashMap<java.lang.String,java.lang.Object>

A context wrapper for the main database connection object.

The "$db" context variable is assigned a new instance of this class at each velocity parsing.

Author:
Claude Brisson
See Also:
Serialized Form

Field Summary
private  java.util.Map<java.lang.String,java.lang.Object> cache
          A cache used by the generic getter.
private  Database db
          The wrapped database connection.
private  java.util.Map<java.lang.String,java.lang.Object> externalParams
          The map of external query parameters used by children attributes.
 
Constructor Summary
protected DBReference()
          Default constructor for use by derived classes.
  DBReference(Database db)
          Constructs a new database reference.
 
Method Summary
 java.lang.String deobfuscate(java.lang.Object value)
          De-obfuscate the given value.
 java.lang.Object get(java.lang.Object key)
          Generic getter, used to access entities or root attributes by their name.
 java.lang.String getSchema()
          Get the schema name.
protected  void init(Database db)
          Protected initialization method.
 java.lang.String obfuscate(java.lang.Object value)
          Obfuscate the given value.
 java.lang.Object put(java.lang.String key, java.lang.Object value)
          Generic setter used to set external params for children attributes.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, isEmpty, keySet, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

db

private Database db
The wrapped database connection.


cache

private java.util.Map<java.lang.String,java.lang.Object> cache
A cache used by the generic getter. Its purpose is to avoid the creation of several attribute references for the same multivalued attribute.


externalParams

private java.util.Map<java.lang.String,java.lang.Object> externalParams
The map of external query parameters used by children attributes.

Constructor Detail

DBReference

protected DBReference()
Default constructor for use by derived classes.


DBReference

public DBReference(Database db)
Constructs a new database reference.

Parameters:
db - the wrapped database connection
Method Detail

init

protected void init(Database db)
Protected initialization method.

Parameters:
db - database connection

get

public java.lang.Object get(java.lang.Object key)

Generic getter, used to access entities or root attributes by their name.

For attributes, the return value depends upon the type of the attribute :

Specified by:
get in interface java.util.Map<java.lang.String,java.lang.Object>
Overrides:
get in class java.util.HashMap<java.lang.String,java.lang.Object>
Parameters:
key - the name of the desired entity or root attribute.
Returns:
an entity, an attribute reference, an instance, a string or null if not found. See See above.

put

public java.lang.Object put(java.lang.String key,
                            java.lang.Object value)
Generic setter used to set external params for children attributes.

Specified by:
put in interface java.util.Map<java.lang.String,java.lang.Object>
Overrides:
put in class java.util.HashMap<java.lang.String,java.lang.Object>
Parameters:
key - name of the external parameter
value - value given to the external parameter
Returns:
the previous value, if any

getSchema

public java.lang.String getSchema()
Get the schema name.

Returns:
the schema

obfuscate

public java.lang.String obfuscate(java.lang.Object value)
Obfuscate the given value.

Parameters:
value - value to obfuscate
Returns:
obfuscated value

deobfuscate

public java.lang.String deobfuscate(java.lang.Object value)
De-obfuscate the given value.

Parameters:
value - value to de-obfuscate
Returns:
obfuscated value


~ooOoo~