org.bsf.listOfValues.util
Class LovDefinitionCache

java.lang.Object
  extended byorg.bsf.listOfValues.util.LovDefinitionCache

public class LovDefinitionCache
extends java.lang.Object

This class is used to store the "lov definitions" (in a LovEntityCacheItem) to prevent the reexecution of a select statement to obtain the to be executed SQL statement defined in the corresponding LOV.

Note that this Class is used as a singleton and that the LovEntityCacheItem is never used outside of this cache.

See Also:
(in this file as well)

Nested Class Summary
(package private)  class LovDefinitionCache.LovEntityCacheItem
          Stores the needed informations related to the LovBean (mainly the SQL statement).
 
Field Summary
private  java.util.HashMap _cache
          Cache that holds the LovEntityCacheItems.
private static LovDefinitionCache _lovCacheInstance
           
 
Constructor Summary
private LovDefinitionCache()
           
 
Method Summary
 void addToCache(java.lang.Long p_lovOID, java.lang.String p_lovName, java.lang.String p_lovRequest, java.util.List p_metaData)
          Adds a new item to the cache (will use a LovEntityCacheItem to do so).
static LovDefinitionCache getInstance()
          Gives access to the singleton.
 java.lang.Long getLovOID(java.lang.String p_lovName)
          Returns the LovOID corresponding to a given LovName or null if no match is found in the cache.
 java.lang.String getRequestForLovOID(java.lang.Long p_lovOID)
          Returns the sql statement (or null if no match is found) stored in the LovDefinitionCache and corresponding to the Lov with the given OID.
 java.util.List getTypesForLovOID(java.lang.Long p_lovOID)
          Returns a collection of type corresponding to the the metadata(or null if no match is found) stored in the LovDefinitionCache and corresponding to the Lov with the given OID.
 boolean isNameInCache(java.lang.String p_lovName)
          Returns whether or not informations, for a given LOV, are stored in the LovDefinitionCache.
 boolean isOIDInCache(java.lang.Long p_lovOID)
          Returns whether or not informations, for a given LOV, are stored in the LovDefinitionCache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_lovCacheInstance

private static LovDefinitionCache _lovCacheInstance

_cache

private java.util.HashMap _cache
Cache that holds the LovEntityCacheItems. Informations are stored as (aLovOID, aLovEntityCacheItem). Initial cache size is 50 and shuold be enough for most applications (otherwise the map extends itself, minor performance cost).

Constructor Detail

LovDefinitionCache

private LovDefinitionCache()
Method Detail

getInstance

public static LovDefinitionCache getInstance()
Gives access to the singleton.

Returns:
the singleton

getRequestForLovOID

public java.lang.String getRequestForLovOID(java.lang.Long p_lovOID)
Returns the sql statement (or null if no match is found) stored in the LovDefinitionCache and corresponding to the Lov with the given OID.

Parameters:
p_lovOID - The OID of the LOV whose SQL statement is desired.
Returns:
the sql statement stored in the LovDefinitionCache corresponding to the given OID or null if the given oid is not found.
See Also:
isOIDInCache(java.lang.Long)

getTypesForLovOID

public java.util.List getTypesForLovOID(java.lang.Long p_lovOID)
Returns a collection of type corresponding to the the metadata(or null if no match is found) stored in the LovDefinitionCache and corresponding to the Lov with the given OID.

Parameters:
p_lovOID - The OID of the LOV whose types are desired.
Returns:
the List of types stored in the LovDefinitionCache corresponding to the given OID or null if the given oid is not found.
See Also:
isOIDInCache(java.lang.Long)

isOIDInCache

public boolean isOIDInCache(java.lang.Long p_lovOID)
Returns whether or not informations, for a given LOV, are stored in the LovDefinitionCache.

Parameters:
p_lovOID - The OID of the LOV for which we want to know if it is in cache.
Returns:
true if we have the informations for the given LovOID in the cache and false otherwise.

isNameInCache

public boolean isNameInCache(java.lang.String p_lovName)
Returns whether or not informations, for a given LOV, are stored in the LovDefinitionCache.

Parameters:
p_lovName - The name of the LOV for which we want to know if it is in cache.
Returns:
true if we have the informations for the given LovName in the cache and false otherwise (or if the name is null).

addToCache

public void addToCache(java.lang.Long p_lovOID,
                       java.lang.String p_lovName,
                       java.lang.String p_lovRequest,
                       java.util.List p_metaData)
Adds a new item to the cache (will use a LovEntityCacheItem to do so).

Parameters:
p_lovOID - The LovOID for which we want to store the informations.
p_lovName - The LovName corresponding to the LovOID.
p_lovRequest - The LovRequest corresponding to the LovOID.
Throws:
java.lang.IllegalArgumentException - if the OID or the NAME or the REQUEST is (are) null.

getLovOID

public java.lang.Long getLovOID(java.lang.String p_lovName)
Returns the LovOID corresponding to a given LovName or null if no match is found in the cache. Note that it only checks in the cache and not anywhere else.

Parameters:
p_lovName - The name for which we want to obtain the LovOID.
Returns:
The LovOID corresponding to the given LovName, null if no match is found in the cache.