KickJava   Java API By Example, From Geeks To Geeks.

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


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 ASTConstructor extends SimpleNode
28 {
29    public ASTConstructor(int id)
30    {
31       super(id);
32    }
33
34    public ASTConstructor(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    String JavaDoc classExpr;
52    ClassExpression clazz;
53    IdentifierExpression annotation;
54    ArrayList JavaDoc attributes = new ArrayList JavaDoc();
55    ArrayList JavaDoc parameters = new ArrayList JavaDoc();
56    boolean anyParameters = false;
57    boolean hasAnyZeroOrMoreParameters = false;
58    ArrayList JavaDoc exceptions = new ArrayList JavaDoc();
59
60    public void jjtAddChild(Node n, int i)
61    {
62       if (n instanceof ASTAttribute) attributes.add(n);
63       else if (n instanceof ASTException) exceptions.add(n);
64       else if (n instanceof ASTAllParameter) anyParameters = true;
65       else if (n instanceof ASTParameter && !anyParameters)
66       {
67          parameters.add(0,n);
68          if (!hasAnyZeroOrMoreParameters && ((ASTParameter)n).isAnyZeroOrMoreParameters())
69          {
70             hasAnyZeroOrMoreParameters = true;
71          }
72       }
73       else super.jjtAddChild(n, i);
74    }
75    public void setClassExpression(String JavaDoc expression)
76    {
77       classExpr = expression;
78       clazz = new ClassExpression(classExpr);
79    }
80
81    public void setNewExpression(String JavaDoc expr)
82    {
83       if (expr.startsWith("@")) annotation = new IdentifierExpression(expr);
84    }
85
86    public String JavaDoc getClassExpr()
87    {
88       return classExpr;
89    }
90
91    public ArrayList JavaDoc getAttributes()
92    {
93       return attributes;
94    }
95    
96    public ArrayList JavaDoc getExceptions()
97    {
98       return exceptions;
99    }
100
101    public ArrayList JavaDoc getParameters()
102    {
103       return parameters;
104    }
105
106    public boolean isAnyParameters()
107    {
108       return anyParameters;
109    }
110
111    public boolean hasAnyZeroOrMoreParameters()
112    {
113       return hasAnyZeroOrMoreParameters;
114    }
115    
116    public ClassExpression getClazz()
117    {
118       return clazz;
119    }
120
121    /**
122     *
123     * @return NULL if a constructor specific annotation was not defined
124     */

125    public IdentifierExpression getConstructorAnnotation()
126    {
127       return annotation;
128    }
129 }
130
Popular Tags