import repository from arizona
[raven.git] / 2.0 / python / metadata_ / PackageData.java
1 package metadata_;
2
3 import java.io.File;
4 import java.io.IOException;
5
6 public class PackageData {
7         private static  MetaData reader;
8         
9                 
10         /**
11          * @param filename [provides|requires|files|package]
12          * @throws IOException 
13          */
14         public static void main(String[] args) throws IOException {
15                 boolean works = false;
16                  File dir = new File("metadata_/stubs_");
17                  File[] stubs = dir.listFiles();
18                  for(int x=0; x< stubs.length; x++){
19                          //System.out.println(stubs[x].getCanonicalPath());
20                          if(stubs[x].getName().endsWith("class")){
21                                  try{
22                                          Class c = Class.forName("metadata_.stubs_."+stubs[x].getName().replace(".class", ""));
23                                          reader = (MetaData) c.newInstance();
24                                          if(reader.works(args[0])){
25                                                  reader.setFile(args[0]);
26                                                  works = true;
27                                                  if(args[1].contains("provides")){
28                                                          System.out.println(reader.getProvides());
29                                                  }else if(args[1].contains("requires")){
30                                                          System.out.println(reader.getRequires());
31                                                  }else if(args[1].contains("files")){
32                                                          System.out.println(reader.getFiles());
33                                                  }else if(args[1].contains("package")){
34                                                          System.out.println(reader.getPackageData());
35                                                  }
36                                                  break;
37                                          }
38                                  }catch(ClassNotFoundException e){
39                                          e.printStackTrace();
40                                          System.err.println(e.getLocalizedMessage());
41                                  } catch (InstantiationException e) {
42                                         // TODO Auto-generated catch block
43                                         e.printStackTrace();
44                                          System.err.println(e.getLocalizedMessage());
45
46                                 } catch (IllegalAccessException e) {
47                                         // TODO Auto-generated catch block
48                                         e.printStackTrace();
49                                          System.err.println(e.getLocalizedMessage());
50
51                                 }
52                          }
53                  }
54                  if(!works){
55                         if(args.length == 0)
56                             System.out.println("No file given");
57                         else
58                          System.out.println("No parser for *"+args[0]+" file types"+
59                                            "\nPackages will not be added to repository listing.");
60                  }
61                 
62
63         }
64
65 }