1 22 package org.jboss.aop.pointcut; 23 24 import java.io.StringReader ; 25 import org.jboss.aop.Advisor; 26 import org.jboss.aop.pointcut.ast.ASTStart; 27 import org.jboss.aop.pointcut.ast.ParseException; 28 import org.jboss.aop.pointcut.ast.TypeExpressionParser; 29 import javassist.CtClass; 30 31 32 35 public class TypedefExpression implements Typedef 36 { 37 protected String name; 38 protected String expr; 39 protected ASTStart ast; 40 41 public TypedefExpression(String name, String expr) throws ParseException 42 { 43 this.name = name; 44 this.expr = expr; 45 46 ast = new TypeExpressionParser(new StringReader (expr)).Start(); 47 } 48 49 public String getName() 50 { 51 return name; 52 } 53 54 public String getExpr() 55 { 56 return expr; 57 } 58 59 public boolean matches(Advisor advisor, CtClass clazz) 60 { 61 TypeMatcher matcher = new TypeMatcher(advisor, clazz); 62 return ((Boolean ) ast.jjtAccept(matcher, null)).booleanValue(); 63 } 64 65 public boolean matches(Advisor advisor, Class clazz) 66 { 67 TypeMatcher matcher = new TypeMatcher(advisor, clazz); 68 return ((Boolean ) ast.jjtAccept(matcher, null)).booleanValue(); 69 } 70 71 } 72 | Popular Tags |