KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > aop > pointcut > ast > ASTMethod


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22
23 package org.jboss.aop.pointcut.ast;
24
25 import java.util.ArrayList JavaDoc;
26
27 public class ASTMethod extends SimpleNode
28 {
29    public ASTMethod(int id)
30    {
31       super(id);
32    }
33
34    public ASTMethod(PointcutExpressionParser p, int id)
35    {
36       super(p, id);
37    }
38
39
40    /** Accept the visitor. **/
41    public Object JavaDoc jjtAccept(PointcutExpressionParserVisitor visitor, Object JavaDoc data)
42    {
43       return visitor.visit(this, data);
44    }
45    /** Accept the visitor. **/
46    public Object JavaDoc jjtAccept(TypeExpressionParserVisitor visitor, Object JavaDoc data)
47    {
48       return visitor.visit(this, data);
49    }
50
51
52    String JavaDoc returnTypeExpr;
53    ClassExpression returnType;
54    String JavaDoc classExpr;
55    ClassExpression clazz;
56    String JavaDoc methodExpr;
57    IdentifierExpression methodIdentifier;
58    boolean anyParameters = false;
59    boolean hasAnyZeroOrMoreParameters = false;
60    ArrayList JavaDoc parameters = new ArrayList JavaDoc();
61    ArrayList JavaDoc attributes = new ArrayList JavaDoc();
62    ArrayList JavaDoc exceptions = new ArrayList JavaDoc();
63
64    public void jjtAddChild(Node n, int i)
65    {
66       if (n instanceof ASTAttribute) attributes.add(n);
67       else if (n instanceof ASTException) exceptions.add(n);
68       else if (n instanceof ASTAllParameter) anyParameters = true;
69       else if (n instanceof ASTParameter && !anyParameters)
70       {
71          parameters.add(0, n);
72          if (!hasAnyZeroOrMoreParameters && ((ASTParameter)n).isAnyZeroOrMoreParameters())
73          {
74             hasAnyZeroOrMoreParameters = true;
75          }
76       }
77       else super.jjtAddChild(n, i);
78    }
79    public void setMethodExpression(String JavaDoc expression)
80    {
81       methodExpr = expression;
82       methodIdentifier = new IdentifierExpression(expression);
83    }
84
85    public void setReturnTypeExpression(String JavaDoc exp)
86    {
87       returnTypeExpr = exp;
88       returnType = new ClassExpression(exp);
89    }
90
91    public void setClassExpression(String JavaDoc exp)
92    {
93       classExpr = exp;
94       clazz = new ClassExpression(exp);
95    }
96
97    public String JavaDoc getReturnTypeExpression()
98    {
99       return returnTypeExpr;
100    }
101
102    public String JavaDoc getClassExpr()
103    {
104       return classExpr;
105    }
106
107    public String JavaDoc getMethodExpr()
108    {
109       return methodExpr;
110    }
111
112    public boolean isAnyParameters()
113    {
114       return anyParameters;
115    }
116
117    public boolean hasAnyZeroOrMoreParameters()
118    {
119       return hasAnyZeroOrMoreParameters;
120    }
121    
122    public ArrayList JavaDoc getParameters()
123    {
124       return parameters;
125    }
126
127    public ArrayList JavaDoc getExceptions()
128    {
129       return exceptions;
130    }
131
132    public ArrayList JavaDoc getAttributes()
133    {
134       return attributes;
135    }
136
137    public ClassExpression getReturnType()
138    {
139       return returnType;
140    }
141
142    public ClassExpression getClazz()
143    {
144       return clazz;
145    }
146
147    public IdentifierExpression getMethodIdentifier()
148    {
149       return methodIdentifier;
150    }
151
152 }
153
Popular Tags