01: // $Id: AspectSurrogate.java,v 1.1.1.1 2003/07/02 15:30:52 apopovic Exp $
02: // =====================================================================
03: //
04: // (history at end)
05: //
06:
07: package ch.ethz.prose.query;
08:
09: import ch.ethz.prose.Aspect;
10:
11: /**
12: * Class AspectSurrogate XXX
13: *
14: * @version $Revision: 1.1.1.1 $
15: * @author Andrei Popovici
16: */
17: public class AspectSurrogate implements java.io.Serializable {
18:
19: private static final long serialVersionUID = 3617014135184110134L;
20: private String aspectClassName;
21: private Object associatedObject;
22:
23: public AspectSurrogate(String aspectClassName,
24: Object associatedObject) {
25: this .aspectClassName = aspectClassName;
26: this .associatedObject = associatedObject;
27: }
28:
29: public AspectSurrogate(Aspect asp) {
30: if (asp == null)
31: throw new IllegalArgumentException(
32: "AspectSurrogate.init: null arg");
33: aspectClassName = asp.getClass().getName();
34: associatedObject = asp.getAssociatedObject();
35: }
36:
37: public String getAspectClassName() {
38: return aspectClassName;
39: }
40:
41: public Object getAssociatedObject() {
42: return associatedObject;
43: }
44:
45: /**
46: * Indicates whether some other object is "equal to" this one. The
47: * result is <code>true</code> if and only if <code>obj</code> is
48: * not <code>null</code> and is a instance of
49: * <code>AspectSurrogate</code> and has equal contents as this
50: * object.
51: * @param obj other object with which to compare
52: * @return <code>true</code> iff <code>obj</code> is equal to this
53: * <code>AspectSurrogate</code>
54: */
55: public boolean equals(Object obj) {
56: return obj instanceof AspectSurrogate
57: && associatedObject
58: .equals(((AspectSurrogate) obj).associatedObject);
59: }
60:
61: /**
62: * Returns a hashcode for this object.
63: * @return hashcode value
64: */
65: public int hashCode() {
66: return associatedObject.hashCode();
67: }
68:
69: public String toString() {
70: return aspectClassName + "[" + associatedObject + "]";
71: }
72: }
73:
74: //======================================================================
75: //
76: // $Log: AspectSurrogate.java,v $
77: // Revision 1.1.1.1 2003/07/02 15:30:52 apopovic
78: // Imported from ETH Zurich
79: //
80: // Revision 1.2 2003/05/25 11:37:13 popovici
81: // Redefinitions: Aspects surrogates do not need to have the class to
82: // be recreated; aspects surrogates can now be created without a real aspect
83: //
84: // Revision 1.1 2003/05/20 16:05:06 popovici
85: //
86: // New QueryManager replaces functionality in AspectManager (better Soc)
87: // New 'Surrogate' classes for usage in the QueryManager
88: // The 'RemoteAspectManager' and tools modified to use the Surrogates and the QueryManager
89: //
|