KickJava   Java API By Example, From Geeks To Geeks.

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


1 // $Id: CrosscutSurrogate.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 // used packages
10
import java.util.List JavaDoc;
11 import ch.ethz.prose.crosscut.Crosscut;
12
13
14 /**
15  * Class CrosscutSurrogate XXX
16  *
17  * @version $Revision: 1.1.1.1 $
18  * @author Andrei Popovici
19  */

20 public
21 class CrosscutSurrogate implements java.io.Serializable JavaDoc {
22
23   AspectSurrogate ownerSurrogate;
24   int index;
25   String JavaDoc crosscutClassName;
26   String JavaDoc initialToString;
27
28   /**
29    * XXX
30    * @param XXX XXX
31    */

32   public CrosscutSurrogate(AspectSurrogate as, Crosscut crsc)
33   {
34       if (as == null || crsc == null)
35       throw new IllegalArgumentException JavaDoc("CrosscutSurrogate.init: NULL argument");
36
37       ownerSurrogate = as;
38       crosscutClassName = crsc.getClass().getName();
39       try
40       {
41           List JavaDoc crosscuts = crsc.getOwner().getCrosscuts();
42           index = crosscuts.indexOf(crsc);
43       }
44       catch (NullPointerException JavaDoc e)
45       {
46           index = -1;
47       }
48       initialToString = crsc.toString();
49   }
50
51     public AspectSurrogate getOwnerSurrogate()
52     {
53     return ownerSurrogate;
54     }
55
56     public String JavaDoc getCrosscutClassName()
57     {
58     return crosscutClassName;
59     }
60
61     public int getIndex()
62     {
63     return index;
64     }
65
66     /**
67      * Indicates whether some other object is "equal to" this one. The
68      * result is <code>true</code> if and only if <code>obj</code> is
69      * not <code>null</code> and is a instance of
70      * <code>CrosscutSurrogate</code> and has equal contents as this
71      * object.
72      * @param obj other object with which to compare
73      * @return <code>true</code> iff <code>obj</code> is equal to this
74      * <code>CrosscutSurrogate</code>
75      */

76     public
77     boolean equals(Object JavaDoc obj)
78     {
79     return
80       obj instanceof CrosscutSurrogate &&
81         ownerSurrogate.equals(((CrosscutSurrogate) obj).ownerSurrogate) &&
82         index == ((CrosscutSurrogate) obj).index;
83     }
84
85       /**
86        * Returns a hashcode for this object.
87        * @return hashcode value
88        */

89     public
90     int hashCode()
91     {
92     return ownerSurrogate.hashCode() + index;
93     }
94
95     public String JavaDoc toString()
96     {
97     return initialToString;
98     }
99
100
101
102
103
104 }
105
106
107 //======================================================================
108
//
109
// $Log: CrosscutSurrogate.java,v $
110
// Revision 1.1.1.1 2003/07/02 15:30:52 apopovic
111
// Imported from ETH Zurich
112
//
113
// Revision 1.1 2003/05/20 16:05:07 popovici
114
//
115
// New QueryManager replaces functionality in AspectManager (better Soc)
116
// New 'Surrogate' classes for usage in the QueryManager
117
// The 'RemoteAspectManager' and tools modified to use the Surrogates and the QueryManager
118
//
119
Popular Tags