KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > annotation > factory > ast > AnnotationParserTester


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 package org.jboss.annotation.factory.ast;
23
24
25
26 public class AnnotationParserTester implements AnnotationParserVisitor
27 {
28    private int indent = 0;
29
30    private String JavaDoc indentString()
31    {
32       StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
33       for (int i = 0; i < indent; ++i)
34       {
35          sb.append(" ");
36       }
37       return sb.toString();
38    }
39
40    public Object JavaDoc visit(ASTSingleMemberValue node, Object JavaDoc data)
41    {
42       System.out.println(indentString() + node);
43       ++indent;
44       data = node.childrenAccept(this, data);
45       --indent;
46       return data;
47    }
48
49    public Object JavaDoc visit(SimpleNode node, Object JavaDoc data)
50    {
51       System.out.println(indentString() + node +
52               ": acceptor not unimplemented in subclass?");
53       ++indent;
54       data = node.childrenAccept(this, data);
55       --indent;
56       return data;
57    }
58
59    public Object JavaDoc visit(ASTStart node, Object JavaDoc data)
60    {
61       System.out.println(indentString() + node);
62       ++indent;
63       data = node.childrenAccept(this, data);
64       --indent;
65       return data;
66    }
67
68    public Object JavaDoc visit(ASTAnnotation node, Object JavaDoc data)
69    {
70       System.out.println(indentString() + node);
71       ++indent;
72       data = node.childrenAccept(this, data);
73       --indent;
74       return data;
75    }
76
77    public Object JavaDoc visit(ASTMemberValuePairs node, Object JavaDoc data)
78    {
79       System.out.println(indentString() + node);
80       ++indent;
81       data = node.childrenAccept(this, data);
82       --indent;
83       return data;
84    }
85
86    public Object JavaDoc visit(ASTMemberValuePair node, Object JavaDoc data)
87    {
88       System.out.println(indentString() + node);
89       ++indent;
90       data = node.childrenAccept(this, data);
91       --indent;
92       return data;
93    }
94
95    public Object JavaDoc visit(ASTMemberValueArrayInitializer node, Object JavaDoc data)
96    {
97       System.out.println(indentString() + node);
98       ++indent;
99       data = node.childrenAccept(this, data);
100       --indent;
101       return data;
102    }
103
104    public Object JavaDoc visit(ASTIdentifier node, Object JavaDoc data)
105    {
106       System.out.println(indentString() + node);
107       ++indent;
108       data = node.childrenAccept(this, data);
109       --indent;
110       return data;
111    }
112
113    public Object JavaDoc visit(ASTString node, Object JavaDoc data)
114    {
115       System.out.println(indentString() + node);
116       ++indent;
117       data = node.childrenAccept(this, data);
118       --indent;
119       return data;
120    }
121
122    public Object JavaDoc visit(ASTChar node, Object JavaDoc data)
123    {
124       System.out.println(indentString() + node);
125       ++indent;
126       data = node.childrenAccept(this, data);
127       --indent;
128       return data;
129    }
130
131    public static void main(String JavaDoc args[])
132    {
133 // System.out.println("----" + args[0]);
134
// StringReader reader = new StringReader(args[0]);
135
System.out.println("Reading from stdin");
136       AnnotationParser t = new AnnotationParser(System.in);
137       //PointcutExpressionParser t = new PointcutExpressionParser(System.in);
138
try
139       {
140          ASTStart n = t.Start();
141          AnnotationParserVisitor v = new AnnotationParserTester();
142          n.jjtAccept(v, null);
143       }
144       catch (Exception JavaDoc e)
145       {
146          System.out.println("Oops.");
147          System.out.println(e.getMessage());
148          e.printStackTrace();
149       }
150    }
151 }
152
153 /*end*/
154
Popular Tags