KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ch > ethz > prose > query > AspectSurrogate


1 // $Id: AspectSurrogate.java,v 1.1.1.1 2003/07/02 15:30:52 apopovic Exp $
2
// =====================================================================
3
//
4
// (history at end)
5
//
6

7 package ch.ethz.prose.query;
8
9 import ch.ethz.prose.Aspect;
10
11
12 /**
13  * Class AspectSurrogate XXX
14  *
15  * @version $Revision: 1.1.1.1 $
16  * @author Andrei Popovici
17  */

18 public
19 class AspectSurrogate implements java.io.Serializable JavaDoc{
20
21     private String JavaDoc aspectClassName;
22     private Object JavaDoc associatedObject;
23
24   public AspectSurrogate(String JavaDoc aspectClassName, Object JavaDoc associatedObject)
25     {
26       this.aspectClassName = aspectClassName;
27       this.associatedObject = associatedObject;
28     }
29
30     public AspectSurrogate(Aspect asp)
31     {
32     if (asp == null)
33         throw new IllegalArgumentException JavaDoc("AspectSurrogate.init: null arg");
34     aspectClassName = asp.getClass().getName();
35     associatedObject = asp.getAssociatedObject();
36     }
37
38     public String JavaDoc getAspectClassName()
39     {
40     return aspectClassName;
41     }
42
43     public Object JavaDoc getAssociatedObject()
44     {
45     return associatedObject;
46     }
47
48      /**
49       * Indicates whether some other object is "equal to" this one. The
50       * result is <code>true</code> if and only if <code>obj</code> is
51       * not <code>null</code> and is a instance of
52       * <code>AspectSurrogate</code> and has equal contents as this
53       * object.
54       * @param obj other object with which to compare
55       * @return <code>true</code> iff <code>obj</code> is equal to this
56       * <code>AspectSurrogate</code>
57       */

58     public
59     boolean equals(Object JavaDoc obj)
60     {
61     return
62         obj instanceof AspectSurrogate &&
63         associatedObject.equals(((AspectSurrogate) obj).associatedObject);
64     }
65
66     /**
67      * Returns a hashcode for this object.
68      * @return hashcode value
69      */

70     public
71     int hashCode()
72     {
73     return associatedObject.hashCode();
74     }
75
76     public String JavaDoc toString()
77     {
78     return aspectClassName + "[" + associatedObject + "]";
79     }
80 }
81
82
83 //======================================================================
84
//
85
// $Log: AspectSurrogate.java,v $
86
// Revision 1.1.1.1 2003/07/02 15:30:52 apopovic
87
// Imported from ETH Zurich
88
//
89
// Revision 1.2 2003/05/25 11:37:13 popovici
90
// Redefinitions: Aspects surrogates do not need to have the class to
91
// be recreated; aspects surrogates can now be created without a real aspect
92
//
93
// Revision 1.1 2003/05/20 16:05:06 popovici
94
//
95
// New QueryManager replaces functionality in AspectManager (better Soc)
96
// New 'Surrogate' classes for usage in the QueryManager
97
// The 'RemoteAspectManager' and tools modified to use the Surrogates and the QueryManager
98
//
99
Popular Tags