org.jboss.util
Class WeakObject

java.lang.Object
  extended byjava.lang.ref.Reference
      extended byjava.lang.ref.WeakReference
          extended byorg.jboss.util.WeakObject

public final class WeakObject
extends WeakReference

Convenience class to wrap an Object into a WeakReference.

Modified from java.util.WeakHashMap.WeakKey.

Version:
$Revision: 1.1 $
Author:
Jason Dillon

Field Summary
protected  int hashCode
          The hash code of the nested object
 
Constructor Summary
WeakObject(Object obj)
          Construct a WeakObject.
WeakObject(Object obj, ReferenceQueue queue)
          Construct a WeakObject.
 
Method Summary
static WeakObject create(Object obj)
          Create a WeakObject for the given object.
static WeakObject create(Object obj, ReferenceQueue queue)
          Create a WeakObject for the given object.
 boolean equals(Object obj)
          Check the equality of an object with this.
 int hashCode()
          Return the hash code of the nested object.
 
Methods inherited from class java.lang.ref.Reference
clear, enqueue, get, isEnqueued
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hashCode

protected final int hashCode
The hash code of the nested object

Constructor Detail

WeakObject

public WeakObject(Object obj)
Construct a WeakObject.

Parameters:
obj - Object to reference.

WeakObject

public WeakObject(Object obj,
                  ReferenceQueue queue)
Construct a WeakObject.

Parameters:
obj - Object to reference.
queue - Reference queue.
Method Detail

equals

public boolean equals(Object obj)
Check the equality of an object with this.

Parameters:
obj - Object to test equality with.
Returns:
True if object is equal.

hashCode

public int hashCode()
Return the hash code of the nested object.

Returns:
The hash code of the nested object.

create

public static WeakObject create(Object obj)
Create a WeakObject for the given object.

Parameters:
obj - Object to reference.
Returns:
WeakObject or null if object is null.

create

public static WeakObject create(Object obj,
                                ReferenceQueue queue)
Create a WeakObject for the given object.

Parameters:
obj - Object to reference.
queue - Reference queue.
Returns:
WeakObject or null if object is null.


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.