001: /*
002: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
003: */
004:
005: /* Generated By:JJTree: Do not edit this line. ASTMethodPattern.java */
006: package com.tc.aspectwerkz.expression.ast;
007:
008: import com.tc.aspectwerkz.expression.regexp.NamePattern;
009: import com.tc.aspectwerkz.expression.regexp.Pattern;
010: import com.tc.aspectwerkz.expression.regexp.TypePattern;
011: import com.tc.aspectwerkz.expression.SubtypePatternType;
012:
013: import java.util.ArrayList;
014: import java.util.List;
015:
016: public class ASTMethodPattern extends SimpleNode {
017: private TypePattern m_returnTypePattern;
018:
019: private TypePattern m_declaringTypePattern;
020:
021: private NamePattern m_methodNamePattern;
022:
023: private List m_modifiers = new ArrayList();
024:
025: public ASTMethodPattern(int id) {
026: super (id);
027: }
028:
029: public ASTMethodPattern(ExpressionParser p, int id) {
030: super (p, id);
031: }
032:
033: public Object jjtAccept(ExpressionParserVisitor visitor, Object data) {
034: return visitor.visit(this , data);
035: }
036:
037: public void addModifier(String modifier) {
038: m_modifiers.add(modifier);
039: }
040:
041: public void setReturnTypePattern(String pattern) {
042: if (pattern.endsWith("+")) {
043: pattern = pattern.substring(0, pattern.length() - 1);
044: m_returnTypePattern = Pattern.compileTypePattern(pattern,
045: SubtypePatternType.MATCH_ON_ALL_METHODS);
046: } else if (pattern.endsWith("#")) {
047: pattern = pattern.substring(0, pattern.length() - 1);
048: m_returnTypePattern = Pattern.compileTypePattern(pattern,
049: SubtypePatternType.MATCH_ON_BASE_TYPE_METHODS_ONLY);
050: } else {
051: m_returnTypePattern = Pattern.compileTypePattern(pattern,
052: SubtypePatternType.NOT_HIERARCHICAL);
053: }
054: }
055:
056: public void setFullNamePattern(final String pattern)
057: throws ParseException {
058: int index = pattern.lastIndexOf('.');
059: String classPattern = null;
060: //Aw-112 support for "method(..)" and "com..*(..)"
061: if (index > 0) {
062: classPattern = pattern.substring(0, index);
063: if (classPattern.endsWith(".")) {
064: classPattern += ".*";
065: }
066: } else {
067: // unspecified classPattern like "method(..)"
068: classPattern = "*..*";
069: }
070: if (classPattern.endsWith("+")) {
071: classPattern = classPattern.substring(0, classPattern
072: .length() - 1);
073: m_declaringTypePattern = Pattern.compileTypePattern(
074: classPattern,
075: SubtypePatternType.MATCH_ON_ALL_METHODS);
076: } else if (classPattern.endsWith("#")) {
077: classPattern = classPattern.substring(0, classPattern
078: .length() - 1);
079: m_declaringTypePattern = Pattern.compileTypePattern(
080: classPattern,
081: SubtypePatternType.MATCH_ON_BASE_TYPE_METHODS_ONLY);
082: } else {
083: m_declaringTypePattern = Pattern.compileTypePattern(
084: classPattern, SubtypePatternType.NOT_HIERARCHICAL);
085: }
086: String methodNamePattern = pattern.substring(index + 1, pattern
087: .length());
088: m_methodNamePattern = Pattern
089: .compileNamePattern(methodNamePattern);
090: if ("new".equals(methodNamePattern)) {
091: throw new ParseException(
092: "Using a constructor pattern with an explicit return type is not allowed");
093: }
094: }
095:
096: public TypePattern getReturnTypePattern() {
097: return m_returnTypePattern;
098: }
099:
100: public TypePattern getDeclaringTypePattern() {
101: return m_declaringTypePattern;
102: }
103:
104: public NamePattern getMethodNamePattern() {
105: return m_methodNamePattern;
106: }
107:
108: public List getModifiers() {
109: return m_modifiers;
110: }
111: }
|