KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > navigator > extensions > EvalutationReference


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  ******************************************************************************/

11
12 package org.eclipse.ui.internal.navigator.extensions;
13
14 import java.lang.ref.SoftReference JavaDoc;
15
16 /**
17  * @since 3.3
18  *
19  */

20 public class EvalutationReference extends SoftReference JavaDoc {
21
22     private final int hashCode;
23
24     private final Class JavaDoc type;
25
26     /**
27      * @param referent
28      * The object to be referenced
29      */

30     public EvalutationReference(Object JavaDoc referent) {
31         super(referent);
32         hashCode = referent.hashCode();
33         type = referent.getClass();
34     }
35
36     /*
37      * (non-Javadoc)
38      *
39      * @see java.lang.Object#hashCode()
40      */

41     public int hashCode() {
42         return hashCode;
43     }
44
45     /*
46      * (non-Javadoc)
47      *
48      * @see java.lang.Object#equals(java.lang.Object)
49      */

50     public boolean equals(Object JavaDoc obj) {
51         if (obj == null)
52             return false;
53         else if (obj instanceof EvalutationReference) {
54             if (!type.equals(((EvalutationReference) obj).type))
55                 return false;
56             return hashCode == obj.hashCode();
57         }
58         return false;
59     }
60     
61     /* (non-Javadoc)
62      * @see java.lang.Object#toString()
63      */

64     public String JavaDoc toString() {
65         Object JavaDoc referent = get();
66         if(referent == null)
67             return "Evalutation[type="+ type +"]"; //$NON-NLS-1$//$NON-NLS-2$
68
return "Evalutation[referent="+ referent +"]"; //$NON-NLS-1$ //$NON-NLS-2$
69
}
70
71 }
72
Popular Tags