1 4 5 package com.tc.aspectwerkz.expression.ast; 6 7 import com.tc.aspectwerkz.expression.regexp.NamePattern; 8 import com.tc.aspectwerkz.expression.regexp.Pattern; 9 import com.tc.aspectwerkz.expression.regexp.TypePattern; 10 import com.tc.aspectwerkz.expression.SubtypePatternType; 11 12 public class ASTFieldPattern extends SimpleNode { 13 private TypePattern m_fieldTypePattern; 14 15 private TypePattern m_declaringTypePattern; 16 17 private NamePattern m_fieldNamePattern; 18 19 public ASTFieldPattern(int id) { 20 super(id); 21 } 22 23 public ASTFieldPattern(ExpressionParser p, int id) { 24 super(p, id); 25 } 26 27 public Object jjtAccept(ExpressionParserVisitor visitor, Object data) { 28 return visitor.visit(this, data); 29 } 30 31 public void setFieldTypePattern(String pattern) { 32 if (pattern.endsWith("+")) { 33 pattern = pattern.substring(0, pattern.length() - 1); 34 m_fieldTypePattern = Pattern.compileTypePattern(pattern, SubtypePatternType.MATCH_ON_ALL_METHODS); 35 } else if (pattern.endsWith("#")) { 36 pattern = pattern.substring(0, pattern.length() - 1); 37 m_fieldTypePattern = Pattern 38 .compileTypePattern(pattern, SubtypePatternType.MATCH_ON_BASE_TYPE_METHODS_ONLY); 39 } else { 40 m_fieldTypePattern = Pattern.compileTypePattern(pattern, SubtypePatternType.NOT_HIERARCHICAL); 41 } 42 } 43 44 public void setFullNamePattern(final String pattern) { 45 int index = pattern.lastIndexOf('.'); 46 String classPattern = null; 47 if (index > 0) { 49 classPattern = pattern.substring(0, index); 50 if (classPattern.endsWith(".")) { 51 classPattern += ".*"; 52 } 53 } else { 54 classPattern = "*..*"; 56 } 57 if (classPattern.endsWith("+")) { 58 classPattern = classPattern.substring(0, classPattern.length() - 1); 59 m_declaringTypePattern = Pattern.compileTypePattern(classPattern, SubtypePatternType.MATCH_ON_ALL_METHODS); 60 } else if (classPattern.endsWith("#")) { 61 classPattern = classPattern.substring(0, classPattern.length() - 1); 62 m_declaringTypePattern = Pattern.compileTypePattern( 63 classPattern, 64 SubtypePatternType.MATCH_ON_BASE_TYPE_METHODS_ONLY 65 ); 66 } else { 67 m_declaringTypePattern = Pattern.compileTypePattern(classPattern, SubtypePatternType.NOT_HIERARCHICAL); 68 } 69 String namePattern = pattern.substring(index + 1, pattern.length()); 70 m_fieldNamePattern = Pattern.compileNamePattern(namePattern); 71 } 72 73 public TypePattern getFieldTypePattern() { 74 return m_fieldTypePattern; 75 } 76 77 public TypePattern getDeclaringTypePattern() { 78 return m_declaringTypePattern; 79 } 80 81 public NamePattern getFieldNamePattern() { 82 return m_fieldNamePattern; 83 } 84 } | Popular Tags |