Lines Matching refs:key

54  * <p> Both null values and the null key are supported.  This class has the
65 * key for which there is no mapping in the cache, it will in turn invoke the
66 * <code>fill</code> method on that key in an attempt to construct a
73 * protected Object fill(Object key) {
74 * return ((URL)key).getContent();
90 * <code>false</code> for a given key, for the <code>get</code> method to
91 * return a value for a given key but later return <code>null</code>, for the
93 * <code>remove</code> method to return <code>false</code> for a key that
95 * key set, the value set, and the entry set to yield successively smaller
111 HashMap, each soft reference must contain the key that maps to it so
121 private Object key;
123 private ValueCell(Object key, Object value, ReferenceQueue queue) {
125 this.key = key;
128 private static ValueCell create(Object key, Object value,
132 return new ValueCell(key, value, queue);
144 return (key != INVALID_KEY);
149 key = INVALID_KEY;
171 if (vc.isValid()) hash.remove(vc.key);
220 * Return the number of key-value mappings in this cache. The time
228 * Return <code>true</code> if this cache contains no key-value mappings.
236 * specified key. If there is no mapping for the key, this method will not
239 * @param key The key whose presence in the cache is to be tested
241 public boolean containsKey(Object key) {
242 return ValueCell.strip(hash.get(key), false) != null;
249 * Create a value object for the given <code>key</code>. This method is
251 * <code>key</code>. If this method returns a non-<code>null</code> value,
252 * then the cache will be updated to map <code>key</code> to that value,
256 * <code>null</code> for every <code>key</code> value. A subclass may
259 * @param key The key for which a value is to be computed
261 * @return A value for <code>key</code>, or <code>null</code> if one
265 protected Object fill(Object key) {
271 * <code>key</code>. If the cache does not presently contain a value for
272 * this key, then invoke the <code>fill</code> method in an attempt to
281 * @param key The key whose associated value, if any, is to be returned
285 public Object get(Object key) {
287 Object v = hash.get(key);
289 v = fill(key);
291 hash.put(key, ValueCell.create(key, v, queue));
299 * Update this cache so that the given <code>key</code> maps to the given
301 * <code>key</code> then that mapping is replaced and the old value is
304 * @param key The key that is to be mapped to the given
306 * @param value The value to which the given <code>key</code> is to be
309 * @return The previous value to which this key was mapped, or
310 * <code>null</code> if if there was no mapping for the key
312 public Object put(Object key, Object value) {
314 ValueCell vc = ValueCell.create(key, value, queue);
315 return ValueCell.strip(hash.put(key, vc), true);
319 * Remove the mapping for the given <code>key</code> from this cache, if
322 * @param key The key whose mapping is to be removed
324 * @return The value to which this key was mapped, or <code>null</code> if
325 * there was no mapping for the key
327 public Object remove(Object key) {
329 return ValueCell.strip(hash.remove(key), true);