1 27 package ch.ethz.inf.iks.jvmai.jvmdi; 28 29 import java.lang.reflect.Method ; 30 import java.util.List ; 31 import ch.ethz.jvmai.JoinPointStaticPart; 32 import ch.ethz.jvmai.CodeJoinPoint; 33 import ch.ethz.jvmai.JoinPoint; 34 import ch.ethz.jvmai.Signature; 35 import ch.ethz.jvmai.JoinPointKinds; 36 37 38 public class CodeJoinPointImpl implements CodeJoinPoint, JoinPointStaticPart, JoinPointKinds 39 { 40 protected Signature signature; protected JoinPointContext context; protected Object aopTag; 43 protected ControlFlow cflow; 44 protected Object target; 45 46 protected CodeJoinPointImpl(ControlFlow cflow) 47 { 48 this.context = new JoinPointContext(); 51 this.signature = new CodeSignatureImpl(this); 52 this.target = null; 53 this.cflow = cflow; 54 } 55 56 protected CodeJoinPointImpl(ControlFlow cflow,JoinPointContext ctx) 57 { 58 this.context = ctx; 61 this.signature = new CodeSignatureImpl(this); 62 this.target = null; 63 this.cflow = cflow; 64 } 65 66 public boolean equals(Object other) 67 { 68 69 if (other instanceof CodeJoinPointImpl) 70 return context.location.equals(((CodeJoinPointImpl)other).context.location); 71 else 72 return false; 73 } 74 75 public int hashCode() 76 { 77 return context.location.hashCode(); 78 } 79 80 84 public Method getMethod() 85 { 86 return context.location.executingMethod; 87 } 88 89 91 public int getByteCodeIndex() 92 { 93 return context.location.executingBci; 94 } 95 96 99 public Object [] getArgs() 100 { 101 return context.getArgs(); 102 } 103 104 105 public String getKind() 106 { 107 return CodeJoinPoint.KIND; 108 } 109 110 public int getMask() 111 { 112 return JoinPointKinds.MASK_CODE_JP; 113 } 114 115 118 public Object getThis() 119 { 120 return context.getThis(); 121 } 122 123 125 public Object getTarget() 126 { 127 return target; 128 } 129 130 132 public Signature getSignature() 133 { 134 return signature; 135 } 136 137 138 140 public CodeJoinPoint getEnclosingJoinPoint() 141 { 142 CodeJoinPointImpl result= new CodeJoinPointImpl(cflow,context.callerContext()); 143 result.target = getThis(); 144 return result; 145 } 146 147 public String toShortString() 148 { 149 return getMethod().toString() + "@" + getByteCodeIndex(); 150 } 151 152 public String toLongString() 153 { 154 return getMethod().toString() + "@" + getByteCodeIndex(); 155 } 156 157 public String toString() 158 { 159 return toShortString(); 160 } 161 162 166 public Object getAopTag() 167 { 168 return aopTag; 169 } 170 171 176 public java.util.Collection getCflowTags() 177 { 178 return cflow.getAopTags(this); 179 } 180 181 public JoinPointStaticPart getStaticPart() 182 { 183 return this; 184 } 185 186 } 187 188 | Popular Tags |