home *** CD-ROM | disk | FTP | other *** search
Java Source | 2004-04-28 | 1.1 KB | 46 lines |
- import java.io.*;
- import java.util.regex.*;
-
- import ji.core.*;
-
- public class Test {
- public static void main(String args[]) {
- new Test(args[0]);
- }
-
- public Test(String filename) {
- File file = new File(filename);
-
- //ClassAnalyzer an = new ClassAnalyzer(file);
- //final String CLASS_PATTERN = "class ([a-zA-Z]*) (?:extends ([a-zA-Z-//.]*)){0,1}(?: implements ([a-zA-Z-//.]*)(?:,([a-zA-Z-//.]*))*){0,1}";
- Pattern classPattern = Pattern.compile(FactoryPatterns.INTERFACE_PATTERN);
-
- try {
- BufferedReader in = new BufferedReader(new FileReader(file));
- String line;
- for(;;) {
- line = in.readLine();
-
- if(line == null)
- break;
-
- Matcher matcher = classPattern.matcher(line);
- if(matcher.find()) {
- System.out.println("" + line);
- System.out.println("class name: " + matcher.group(1));
- System.out.println("extends by: " + matcher.group(2));
- //if(matcher.groupCount() > 2)
- for(int k=2;k<matcher.groupCount();k++)
- System.out.println("implements: " + matcher.group(k+1));
- }
-
- }
-
- in.close();
- } catch(IOException ie) {
- ie.printStackTrace();
- System.exit(1);
- }
- }
- }
-