Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.commons.collections.map
Class AbstractReferenceMap.ReferenceEntry

    java.lang.Object
      |
      +--org.apache.commons.collections.map.AbstractHashedMap.HashEntry
            |
            +--org.apache.commons.collections.map.AbstractReferenceMap.ReferenceEntry

All Implemented Interfaces:
  KeyValue, Map.Entry

Enclosing class:
  AbstractReferenceMap

protected static class AbstractReferenceMap.ReferenceEntry
extends AbstractHashedMap.HashEntry

A MapEntry implementation for the map.

If getKey() or getValue() returns null, it means the mapping is stale and should be removed.

Since:
  Commons Collections 3.1

Field Summary
`protected AbstractReferenceMap` | `parent` The parent map

Fields inherited from class org.apache.commons.collections.map.AbstractHashedMap.HashEntry
`hashCode, key, next, value`

Constructor Summary
`AbstractReferenceMap.ReferenceEntry(AbstractReferenceMap parent, AbstractHashedMap.HashEntry next, int hashCode, Object key, Object value)` Creates a new entry object for the ReferenceMap.

Method Summary
`boolean` | `equals(Object obj)` Compares this map entry to another.
`Object` | `getKey()` Gets the key from the entry.
`Object` | `getValue()` Gets the value from the entry.
`int` | `hashCode()` Gets the hashcode of the entry using temporary hard references.
`protected AbstractReferenceMap.ReferenceEntry` | `next()` Gets the next entry in the bucket.
`Object` | `setValue(Object obj)` Sets the value of the entry.
`protected Object` | `toReference(int type, Object referent, int hash)` Constructs a reference of the given type to the given referent.

Methods inherited from class org.apache.commons.collections.map.AbstractHashedMap.HashEntry
`toString`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### parent

    protected final AbstractReferenceMap parent

  The parent map

Constructor Detail

### AbstractReferenceMap.ReferenceEntry

    public AbstractReferenceMap.ReferenceEntry(AbstractReferenceMap parent,
                                               AbstractHashedMap.HashEntry next,
                                               int hashCode,
                                               Object key,
                                               Object value)

  Creates a new entry object for the ReferenceMap.

Parameters:
  `parent` - the parent map
  `next` - the next entry in the hash bucket
  `hashCode` - the hash code of the key
  `key` - the key
  `value` - the value

Method Detail

### getKey

    public Object getKey()

  Gets the key from the entry. This method dereferences weak and soft keys and thus may return null.

  Specified by:
    `getKey` in interface `Map.Entry`
  Overrides:
    `getKey` in class `AbstractHashedMap.HashEntry`
  Returns:
    the key, which may be null if it was garbage collected

### getValue

    public Object getValue()

  Gets the value from the entry. This method dereferences weak and soft value and thus may return null.

  Specified by:
    `getValue` in interface `Map.Entry`
  Overrides:
    `getValue` in class `AbstractHashedMap.HashEntry`
  Returns:
    the value, which may be null if it was garbage collected

### setValue

    public Object setValue(Object obj)

  Sets the value of the entry.

  Specified by:
    `setValue` in interface `Map.Entry`
  Overrides:
    `setValue` in class `AbstractHashedMap.HashEntry`
  Parameters:
    `obj` - the object to store
  Returns:
    the previous value

### equals

    public boolean equals(Object obj)

  Compares this map entry to another.

  This implementation uses `isEqualKey` and `isEqualValue` on the main map for comparison.

  Specified by:
    `equals` in interface `Map.Entry`
  Overrides:
    `equals` in class `AbstractHashedMap.HashEntry`
  Parameters:
    `obj` - the other map entry to compare to
  Returns:
    true if equal, false if not

### hashCode

    public int hashCode()

  Gets the hashcode of the entry using temporary hard references.

  This implementation uses `hashEntry` on the main map.

  Specified by:
    `hashCode` in interface `Map.Entry`
  Overrides:
    `hashCode` in class `AbstractHashedMap.HashEntry`
  Returns:
    the hashcode of the entry

### toReference

    protected Object toReference(int type,
                                 Object referent,
                                 int hash)

  Constructs a reference of the given type to the given referent. The reference is registered with the queue for later purging.

  Parameters:
    `type` - HARD, SOFT or WEAK
    `referent` - the object to refer to
    `hash` - the hash code of the key of the mapping; this number might be different from referent.hashCode() if the referent represents a value and not a key

### next

    protected AbstractReferenceMap.ReferenceEntry next()

  Gets the next entry in the bucket.

  Returns:
    the next entry in the bucket

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2004 Apache Software Foundation. All Rights Reserved.