KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > oocode > MethodGetter


1 package com.oocode;
2 import java.io.*;
3 import java.util.List JavaDoc;
4
5 import org.sablecc.java.lexer.*;
6 import org.sablecc.java.node.Node;
7 import org.sablecc.java.parser.*;
8
9 /**
10 '''
11 COPYRIGHT AND PERMISSION NOTICE
12
13 Copyright (c) 2002 Ivan Moore
14
15 All rights reserved.
16
17 Permission is hereby granted, free of charge, to any person obtaining a copy of this
18 software and associated documentation files (the "Software"), to deal in the Software
19 without restriction, including without limitation the rights to use, copy, modify,
20 merge, publish, distribute, and/or sell copies of the Software, and to permit persons
21 to whom the Software is furnished to do so, provided that the above copyright
22 notice(s) and this permission notice appear in all copies of the Software and that
23 both the above copyright notice(s) and this permission notice appear in supporting
24 documentation.
25
26 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
27 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
28 PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE
29 COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
30 SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM
31 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
32 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
33 SOFTWARE.
34
35 Except as contained in this notice, the name of a copyright holder shall not be used
36 in advertising or otherwise to promote the sale, use or other dealings in this
37 Software without prior written authorization of the copyright holder.
38 ''' */

39 public class MethodGetter {
40     public static List JavaDoc getMethods(Reader sourceReader) throws ParserException, LexerException, IOException {
41         PushbackReader reader = new PushbackReader(new BufferedReader(sourceReader), 1024);
42         Lexer lexer = new Lexer(reader);
43         Parser parser = new Parser(lexer);
44         Node ast = parser.parse();
45
46         MethodGettingWalker walker = new MethodGettingWalker();
47         ast.apply(walker);
48         return walker.getMethods();
49     }
50 }
51
Popular Tags