home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 81 / IOPROG_81.ISO / soft / Codice / Inspector / codice / src / Test.java < prev    next >
Encoding:
Java Source  |  2004-04-28  |  1.1 KB  |  46 lines

  1. import java.io.*;
  2. import java.util.regex.*;
  3.  
  4. import ji.core.*;
  5.  
  6. public class Test {
  7.     public static void main(String args[]) {
  8.         new Test(args[0]);    
  9.     }    
  10.     
  11.     public Test(String filename) {
  12.         File file = new File(filename);
  13.  
  14.         //ClassAnalyzer an = new ClassAnalyzer(file);
  15.         //final String CLASS_PATTERN = "class ([a-zA-Z]*) (?:extends ([a-zA-Z-//.]*)){0,1}(?: implements ([a-zA-Z-//.]*)(?:,([a-zA-Z-//.]*))*){0,1}";    
  16.         Pattern classPattern = Pattern.compile(FactoryPatterns.INTERFACE_PATTERN);
  17.  
  18.         try {
  19.             BufferedReader in = new BufferedReader(new FileReader(file));
  20.             String line;
  21.             for(;;) {
  22.                 line = in.readLine();
  23.                 
  24.                 if(line == null)
  25.                     break;    
  26.  
  27.                 Matcher matcher = classPattern.matcher(line);
  28.                 if(matcher.find()) {
  29.                     System.out.println("" + line);
  30.                     System.out.println("class name: " + matcher.group(1));
  31.                     System.out.println("extends by: " + matcher.group(2));
  32.                     //if(matcher.groupCount() > 2) 
  33.                         for(int k=2;k<matcher.groupCount();k++) 
  34.                             System.out.println("implements: " + matcher.group(k+1));
  35.                 }
  36.                 
  37.             }
  38.             
  39.             in.close();
  40.         } catch(IOException ie) {
  41.             ie.printStackTrace();
  42.             System.exit(1);
  43.         }
  44.     }
  45. }
  46.