1 22 package org.jboss.aop.pointcut; 23 24 import javassist.CtClass; 25 26 import org.jboss.aop.Advisor; 27 import org.jboss.aop.pointcut.ast.ASTConstructor; 28 import org.jboss.aop.pointcut.ast.ASTField; 29 import org.jboss.aop.pointcut.ast.ASTHas; 30 import org.jboss.aop.pointcut.ast.ASTHasField; 31 import org.jboss.aop.pointcut.ast.ASTMethod; 32 import org.jboss.aop.pointcut.ast.Node; 33 34 42 public class DeclareTypeMatcher extends TypeMatcher 43 { 44 public DeclareTypeMatcher(Advisor advisor, Class clazz) 45 { 46 super(advisor, clazz); 47 } 48 49 public DeclareTypeMatcher(Advisor advisor, CtClass ctClass) 50 { 51 super(advisor, ctClass); 52 } 53 54 public Object visit(ASTHas node, Object data) 55 { 56 Node n = node.jjtGetChild(0); 57 if (n instanceof ASTMethod) 58 { 59 boolean checkSuper = false; 60 if (clazz != null) return new Boolean (Util.has(clazz, (ASTMethod) n, advisor, checkSuper)); 61 if (ctClass != null) return new Boolean (Util.has(ctClass, (ASTMethod) n, advisor, checkSuper)); 62 } 63 else 64 { 65 if (clazz != null) return new Boolean (Util.has(clazz, (ASTConstructor) n, advisor)); 67 if (ctClass != null) return new Boolean (Util.has(ctClass, (ASTConstructor) n, advisor)); 68 } 69 return Boolean.FALSE; 70 } 71 72 public Object visit(ASTHasField node, Object data) 73 { 74 boolean checkSuper = false; 75 ASTField f = (ASTField) node.jjtGetChild(0); 76 if (clazz != null) 77 return new Boolean (Util.has(clazz, f, advisor, checkSuper)); 78 else 79 return new Boolean (Util.has(ctClass, f, advisor, checkSuper)); 80 } 81 82 } 83 | Popular Tags |