/[classpath]/cp-tools/src/gnu/localegen/Main.java
ViewVC logotype

Diff of /cp-tools/src/gnu/localegen/Main.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by cbj, Sun Jan 30 01:52:04 2005 UTC revision 1.6 by cbj, Sun Jan 30 02:21:07 2005 UTC
# Line 12  import java.util.List; Line 12  import java.util.List;
12  import java.util.Map;  import java.util.Map;
13  import java.io.IOException;  import java.io.IOException;
14    
15  public class Main {  public class Main
16    {
   
   static void printVersion()  
   {  
     System.out.println(" This is the LDML to GNU Classpath converter");  
     System.out.println("   Copyright (C) 2004 The Free Software Foundation.");  
     System.out.println();  
   }  
   
   static void printUsage()  
   {  
     System.out.println(" Usage: [URLs]");  
     System.out.println();  
     System.out.println("The generator takes only URL on command line. The corresponding files will be retrieved and parsed.");  
     System.out.println("The Java source code for GNU Classpath is generated in gnu/java/locale/LocaleInformation_[name]");  
     System.out.println("where \"name\" is the proper name of the original XML file (atm), i.e. the base file name.");  
     System.exit(1);  
   }  
17    
18    static public void main(String args[]) throws Exception    static public void main(String args[]) throws Exception
19    {    {
   
20      printVersion();      printVersion();
   
21      if (args.length == 0)      if (args.length == 0)
22        {        {
23          System.out.println("Invalid number of arguments.");          System.out.println("Invalid number of arguments.");
24          printUsage();          printUsage();
25          return;          return;
26        }        }
   
27      Map localeAnalyzers = new HashMap();      Map localeAnalyzers = new HashMap();
28      Map collationAnalyzers = new HashMap();      Map collationAnalyzers = new HashMap();
   
29      for (int i = 0; i < args.length; i++)      for (int i = 0; i < args.length; i++)
30        {        {
31          URL u;          URL u;
32          Analyzer a;          Analyzer a;
33            try
34          try            {
           {  
35              try              try
36                {                {
37                  u = new URL(args[i]);                  u = new URL(args[i]);
# Line 65  public class Main { Line 43  public class Main {
43              System.out.println("Parsing/Analyzing initial URL " + u);              System.out.println("Parsing/Analyzing initial URL " + u);
44              a = new Analyzer(u);              a = new Analyzer(u);
45            }            }
46          catch (IOException e)          catch (IOException e)
47            {            {
48              System.out.println("It is impossible to grab the requested file (reason="+ e.getMessage() + ")");              System.out
49              e.printStackTrace();                .println("It is impossible to grab the requested file (reason="
50              System.out.println("Exiting.");                         + e.getMessage() + ")");
51              return;              e.printStackTrace();
52            }              System.out.println("Exiting.");
53                        return;
54                      }
55          a.flattenTree();          a.flattenTree();
56          Collection locales = a.getLocales();          Collection locales = a.getLocales();
57          for (Iterator j = locales.iterator(); j.hasNext(); )          for (Iterator j = locales.iterator(); j.hasNext();)
58            {            {
59              String locale = (String) j.next();              String locale = (String) j.next();
60              if (a.isCollation())              if (a.isCollation())
# Line 89  public class Main { Line 67  public class Main {
67                }                }
68            }            }
69        }        }
70        for (Iterator i = localeAnalyzers.keySet().iterator(); i.hasNext();)
     for (Iterator i = localeAnalyzers.keySet().iterator(); i.hasNext(); )  
71        {        {
72          String locale = (String) i.next();          String locale = (String) i.next();
73          Analyzer a = (Analyzer) localeAnalyzers.get(locale);          Analyzer a = (Analyzer) localeAnalyzers.get(locale);
74          Analyzer ca = (Analyzer) collationAnalyzers.get(locale);          Analyzer ca = (Analyzer) collationAnalyzers.get(locale);
75                    List analyzers = (ca == null) ? Collections.singletonList(a) : Arrays
76          List analyzers = (ca == null) ? Collections.singletonList(a) :            .asList(new Analyzer[] { a, ca });
77              Arrays.asList(new Analyzer[] {a, ca});          System.out.println("Generating Java source code for " + locale
78                                       + " in gnu.java.locale");
79          System.out.println("Generating Java source code for " + locale +          JavaGenerator generator = new JavaGenerator("gnu.java.locale",
                            " in gnu.java.locale");  
         JavaGenerator generator = new JavaGenerator("gnu.java.locale",  
80                                                      analyzers, locale);                                                      analyzers, locale);
81          generator.generate(null);          generator.generate(null);
82        }        }
83    }    }
84    
85  }    static void printUsage()
86      {
87        System.out.println(" Usage: [URLs]");
88        System.out.println();
89        System.out
90          .println("The generator takes only URL on command line. The corresponding files will be retrieved and parsed.");
91        System.out
92          .println("The Java source code for GNU Classpath is generated in gnu/java/locale/LocaleInformation_[name]");
93        System.out
94          .println("where \"name\" is the proper name of the original XML file (atm), i.e. the base file name.");
95        System.exit(1);
96      }
97      static void printVersion()
98      {
99        System.out.println(" This is the LDML to GNU Classpath converter");
100        System.out.println("   Copyright (C) 2004 The Free Software Foundation.");
101        System.out.println();
102      }
103    }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26