net.sourceforge.sqlunit.utils
Class TypeMap

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap
          extended by net.sourceforge.sqlunit.utils.TypeMap
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map

public class TypeMap
extends java.util.HashMap

A specialized HashMap to lookup values in a server specific manner. If the server specific value is not found, then it falls back to the default lookup.

Version:
$Revision: 1.4 $
Author:
Sujit Pal (spal@users.sourceforge.net)
See Also:
Serialized Form

Constructor Summary
TypeMap()
           
 
Method Summary
 java.lang.Object get(java.lang.String key)
          Overrides the superclass method to add server-specific logic.
 java.lang.Object rget(java.lang.String value)
          Reverse lookup of the key by value.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, 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
 

Constructor Detail

TypeMap

public TypeMap()
Method Detail

get

public final java.lang.Object get(java.lang.String key)
Overrides the superclass method to add server-specific logic. The method will first lookup up the current server name from the ConnectionRegistry, and attempt to look up the value using the key ${servername}.key. This corresponds to the override type mapping for that particular server. If no value is found for this key, then it falls back on the default lookup by type, which corresponds to type mappings which have not been overriden and are valid for this server. If neither key is found, then it returns null.

Parameters:
key - the type name to look up.
Returns:
the corresponding value for the ${servername}.key or the value corresponding to key if the former is not found. May return null if neither value is found.

rget

public final java.lang.Object rget(java.lang.String value)
Reverse lookup of the key by value. The method will first lookup the current server name from the ConnectionRegistry. It then gets all the values in the map, then iterates over the list to find entries of the form ${servername}.value, and returns the corresponding key if found. If not found, it will fall back to look for value, and return the corresponding key if that is found. If neither value is found, then it returns null.

Parameters:
value - the value to look up.
Returns:
the key corresponding to ${servername}.value or value. May return null if neither is found.