@SuppressWarnings("unchecked")
    public boolean containsKey(Object key) {
        synchronized( this ) {
            //WeakReference ref;
            SoftReference ref;
            V item;
            
            if( !cache.containsKey(key) ) {
                return false;
            }
            ref = cache.get(key);
            item = (V)ref.get();
            if( item == null ) {
                return false;
            }
            if( item instanceof CachedItem ) {
                CachedItem ci = (CachedItem)item;
                
                if( !ci.isValidForCache() ) {
                    remove(key);
                    return false;
                }
            }
            return true;
        }
    }
@ SuppressWarnings ( "unchecked" ) public boolean containsKey ( Object key ) { synchronized ( this ) { SoftReference ref ; V item ; if ( ! cache . containsKey ( key ) ) { return false ; } ref = cache . get ( key ) ; item = ( V ) ref . get ( ) ; if ( item == null ) { return false ; } if ( item instanceof CachedItem ) { CachedItem ci = ( CachedItem ) item ; if ( ! ci . isValidForCache ( ) ) { remove ( key ) ; return false ; } } return true ; } }
This method will verify both that the key exists and the value is currently
value for the cache.
@param key the key to test for existence
@return true if the cache has a value with the specified key