1 27 package ch.ethz.prose.query; 28 29 import ch.ethz.jvmai.JVMAspectInterface; 31 import ch.ethz.prose.engine.ExceptionThrowRequest; 32 import ch.ethz.prose.engine.FieldAccessRequest; 33 import ch.ethz.prose.engine.FieldModificationRequest; 34 import ch.ethz.prose.engine.JoinPointRequest; 35 import ch.ethz.prose.engine.MethodEntryRequest; 36 import ch.ethz.prose.engine.MethodExitRequest; 37 import ch.ethz.prose.engine.ExceptionCatchRequest; 38 import ch.ethz.prose.engine.JoinPointManager; 39 import ch.ethz.prose.ProseSystem; 40 import ch.ethz.jvmai.JoinPointKinds; 41 import ch.ethz.jvmai.ClassSpecific; 42 import ch.ethz.jvmai.MethodExitJoinPoint; 43 import ch.ethz.jvmai.FieldAccessJoinPoint; 44 import ch.ethz.jvmai.FieldModificationJoinPoint; 45 import ch.ethz.jvmai.ExceptionJoinPoint; 46 47 48 49 50 56 public 57 class JoinPointRequestSurrogate implements java.io.Serializable { 58 59 private ClassSurrogate declaringClass; 60 private Surrogate member; 61 private String kind; 62 private int hashCode; 63 64 67 public JoinPointRequestSurrogate(JoinPointRequest jpr) 68 { 69 70 71 if (jpr == null) 74 { 75 kind = "null"; 76 member = null; 77 declaringClass = null; 78 return; 79 } 80 81 kind = jpr.getKind(); 82 if (jpr instanceof ClassSpecific) 83 declaringClass = new ClassSurrogate( ((ClassSpecific)jpr).getTargetClass()); 84 85 if ( (jpr.getMask() & JoinPointKinds.MASK_METHOD_ENTRY_JP) != 0) 86 member = new MethodSurrogate(((MethodEntryRequest)jpr).getMethod()); 87 else if ( (jpr.getMask() & JoinPointKinds.MASK_METHOD_EXIT_JP) != 0) 88 member = new MethodSurrogate(((MethodExitRequest)jpr).getMethod()); 89 else if ( (jpr.getMask() & JoinPointKinds.MASK_FIELD_ACCESS_JP) != 0) 90 member = new FieldSurrogate(((FieldAccessRequest)jpr).getField()); 91 else if ( (jpr.getMask() & JoinPointKinds.MASK_FIELD_MODIFICATION_JP) != 0) 92 member = new FieldSurrogate(((FieldModificationRequest)jpr).getField()); 93 else if ( (jpr.getMask() & JoinPointKinds.MASK_EXCEPTION_THROW_ARGS_JP) != 0) 94 { member = new ClassSurrogate(((ExceptionThrowRequest)jpr).getExceptionClass()); 95 declaringClass = (ClassSurrogate)member; 96 } 97 else if ( (jpr.getMask() & JoinPointKinds.MASK_EXCEPTION_CATCH_ARGS_JP) != 0) 98 { member = new ClassSurrogate(((ExceptionCatchRequest)jpr).getExceptionClass()); 99 declaringClass = (ClassSurrogate)member; 100 } 101 102 else 103 throw new ClassCastException ("the JoinPointRequest must have one of the known subtypes"); 104 105 if (jpr != null) 106 hashCode = jpr.hashCode(); 107 108 109 110 } 111 112 116 public String getName() 117 { 118 return toString(); 119 } 120 121 122 127 public String getKind() 128 { 129 return kind; 130 } 131 132 133 public Surrogate getMember() 134 { 135 return member; 136 } 137 138 139 public ClassSurrogate getDeclaringClass() 140 { 141 return declaringClass; 142 } 143 144 145 146 public boolean equals(Object o) 147 { 148 if (!(o instanceof JoinPointRequestSurrogate)) 149 return false; 150 151 JoinPointRequestSurrogate other = (JoinPointRequestSurrogate)o; 152 153 if (kind != other.getKind()) 154 return false; 155 156 if (! member.equals(other.getMember())) 157 return false; 158 159 if (! declaringClass.equals(other.getDeclaringClass())) 160 return false; 161 162 return true; 163 } 164 165 public int hashCode() 166 { 167 return hashCode; 168 } 169 170 171 public String toString() 172 { 173 174 if ((kind.equals(JoinPointKinds.KIND_METHOD_ENTRY_JP)) || (kind.equals(JoinPointKinds.KIND_METHOD_EXIT_JP))) 175 return kind + " on " + declaringClass + "." + member.toString(); 176 177 else if ((kind.equals(JoinPointKinds.KIND_FIELD_ACCESS_JP)) || (kind.equals(JoinPointKinds.KIND_FIELD_MODIFICATION_JP))) 178 return kind + " on " + ((FieldSurrogate)member).getType() + " " + declaringClass + "." + member.getName(); 179 180 else if (kind.equals(JoinPointKinds.KIND_EXCEPTION_THROW_ARGS_JP) || kind.equals (JoinPointKinds.KIND_EXCEPTION_CATCH_ARGS_JP)) 181 return kind + " on " + member.toString(); 182 183 else if (kind.equals("null")) 184 return "#NULL#"; 185 186 return "##ERROR## in toString() of class JoinPointRequestSurrogate"; 187 } 188 } 189 190 191 | Popular Tags |