1 22 package org.jboss.aop.pointcut.ast; 23 24 import java.util.regex.Matcher ; 25 import java.util.regex.Pattern ; 26 27 34 public class IdentifierExpression 35 { 36 private String original; 37 private Pattern namePattern; 38 private boolean isAnnotation; 39 40 private boolean isImplements; 41 private boolean isImplementing; 42 private ClassExpression implementsExpr; 43 44 public IdentifierExpression(String expr) 45 { 46 original = expr; 47 if (expr.startsWith("@")) 48 { 49 isAnnotation = true; 50 } 51 else if (expr.startsWith("$implements{")) 52 { 53 isImplements = true; 54 expr = expr.substring(12, expr.length() - 1); 55 implementsExpr = new ClassExpression(expr.trim()); 56 } 57 else if (expr.startsWith("$implementing{")) 58 { 59 isImplementing = true; 60 expr = expr.substring(14, expr.length() - 1); 61 implementsExpr = new ClassExpression(expr.trim()); 62 } 63 else 64 { 65 expr = expr.replaceAll("\\*", ".*"); 66 namePattern = Pattern.compile(expr); 67 } 68 } 69 70 public boolean matches(String name) 71 { 72 if (isAnnotation) return false; 73 Matcher m = namePattern.matcher(name); 74 return m.matches(); 75 } 76 77 public boolean matchesAnnotation(String annotation) 78 { 79 if (!isAnnotation) return false; 80 Matcher m = namePattern.matcher(annotation); 81 return m.matches(); 82 } 83 84 public String getOriginal() 85 { 86 return original; 87 } 88 89 public boolean isAnnotation() 90 { 91 return this.isAnnotation; 92 } 93 94 public boolean isImplements() 95 { 96 return this.isImplements; 97 } 98 99 public boolean isImplementing() 100 { 101 return this.isImplementing; 102 } 103 104 public ClassExpression getImplementsExpression() 105 { 106 return implementsExpr; 107 } 108 } 109 | Popular Tags |