/[classpath]/gjdoc/src/gnu/classpath/tools/gjdoc/Main.java
ViewVC logotype

Diff of /gjdoc/src/gnu/classpath/tools/gjdoc/Main.java

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

revision 1.69 by julian, Wed May 18 11:52:32 2005 UTC revision 1.70 by julian, Thu May 19 22:53:11 2005 UTC
# Line 240  public final class Main Line 240  public final class Main
240     *     *
241     * @param allOptions List of all command line tokens     * @param allOptions List of all command line tokens
242     */     */
243    private void startDoclet(List allOptions)    private boolean startDoclet(List allOptions)
244    {    {
245    
246      try      try
# Line 360  public final class Main Line 360  public final class Main
360                int ndx = propertyValue.indexOf('=');                int ndx = propertyValue.indexOf('=');
361                if (ndx <= 0) {                if (ndx <= 0) {
362                  reporter.printError("Illegal format in option " + option + ": use -JDproperty=value");                  reporter.printError("Illegal format in option " + option + ": use -JDproperty=value");
363                  shutdown();                  return false;
364                }                }
365                else {                else {
366                  String property = propertyValue.substring(0, ndx);                  String property = propertyValue.substring(0, ndx);
# Line 376  public final class Main Line 376  public final class Main
376                //--- Complain if not found                //--- Complain if not found
377    
378                reporter.printError("Unknown option " + option);                reporter.printError("Unknown option " + option);
379                shutdown();                return false;
380              }              }
381            }            }
382            else            else
# Line 391  public final class Main Line 391  public final class Main
391                if (!it.hasNext())                if (!it.hasNext())
392                {                {
393                  reporter.printError("Missing value for option " + option);                  reporter.printError("Missing value for option " + option);
394                  shutdown();                  return false;
395                }                }
396                else                else
397                {                {
# Line 503  public final class Main Line 503  public final class Main
503          {          {
504            reporter.printError("Class or package " + classOrPackage            reporter.printError("Class or package " + classOrPackage
505                + " not found.");                + " not found.");
506            shutdown();            return false;
507          }          }
508    
509          //--- Complain if both exist: ambigious          //--- Complain if both exist: ambigious
# Line 513  public final class Main Line 513  public final class Main
513            {            {
514              reporter.printError("Ambigious class/package name "              reporter.printError("Ambigious class/package name "
515                  + classOrPackage + ".");                  + classOrPackage + ".");
516              shutdown();              return false;
517            }            }
518    
519            //--- Otherwise, if the package directory exists, it is a package            //--- Otherwise, if the package directory exists, it is a package
# Line 532  public final class Main Line 532  public final class Main
532                }                }
533                if (!packageDirFound) {                if (!packageDirFound) {
534                  reporter.printError("No suitable file or directory found for" + classOrPackage);                  reporter.printError("No suitable file or directory found for" + classOrPackage);
535                  shutdown();                  return false;
536                }                }
537              }              }
538    
# Line 550  public final class Main Line 550  public final class Main
550        {        {
551          reporter.printError("No packages or classes specified.");          reporter.printError("No packages or classes specified.");
552          usage();          usage();
553          shutdown();          return false;
554        }        }
555    
556        //--- Validate custom options passed on command line        //--- Validate custom options passed on command line
# Line 563  public final class Main Line 563  public final class Main
563              { customOptionArr, reporter })).booleanValue())              { customOptionArr, reporter })).booleanValue())
564        {        {
565          // Not ok: shutdown system.          // Not ok: shutdown system.
566          shutdown();          return false;
567        }        }
568    
569        rootDoc.setOptions(customOptionArr);        rootDoc.setOptions(customOptionArr);
# Line 577  public final class Main Line 577  public final class Main
577            && 0 == rootDoc.specifiedClasses().length)            && 0 == rootDoc.specifiedClasses().length)
578        {        {
579          reporter.printError("No packages or classes found(!).");          reporter.printError("No packages or classes found(!).");
580          shutdown();          return false;
581        }        }
582    
583        //--- Our work is done, tidy up memory        //--- Our work is done, tidy up memory
# Line 623  public final class Main Line 623  public final class Main
623        System.gc();        System.gc();
624    
625        //--- Done.        //--- Done.
626          return true;
627      }      }
628      catch (Exception e)      catch (Exception e)
629      {      {
630        e.printStackTrace();        e.printStackTrace();
631          return false;
632      }      }
633    }    }
634    
# Line 856  public final class Main Line 858  public final class Main
858    
859        //--- Handle control to the Singleton instance of this class        //--- Handle control to the Singleton instance of this class
860    
861        instance.start(args);        int result = instance.start(args);
862    
863          if (result < 0) {
864            // fatal error
865            System.exit(5);
866          }
867          else if (result > 0) {
868            // errors encountered
869            System.exit(1);
870          }
871          else {
872            // success
873            System.exit(0);
874          }
875      }      }
876      catch (Exception e)      catch (Exception e)
877      {      {
878          //--- unexpected error
       //--- Report any error  
   
879        e.printStackTrace();        e.printStackTrace();
880        System.exit(1);        System.exit(1);
881      }      }
# Line 878  public final class Main Line 891  public final class Main
891     {     {
892       try       try
893       {       {
894         instance.start(args);         int result = instance.start(args);
895           if (result < 0) {
896             // fatal error
897             return 5;
898           }
899           else if (result > 0) {
900             // errors encountered
901             return 1;
902           }
903           else {
904             // success
905             return 0;
906           }
907       }       }
908       catch (Exception e)       catch (Exception e)
909       {       {
910           // unexpected error
911         return 1;         return 1;
912       }       }
   
      return 0;  
913     }     }
914    
915    /**    /**
# Line 950  public final class Main Line 974  public final class Main
974     *     *
975     * @param args     * @param args
976     *          Command line arguments, as passed to the main() method     *          Command line arguments, as passed to the main() method
977       * @return {@code -1} in case of a fatal error (invalid arguments),
978       * or the number of errors encountered.
979     * @exception ParseException     * @exception ParseException
980     *              FIXME     *              FIXME
981     * @exception IOException     * @exception IOException
982     *              if an IO problem occur     *              if an IO problem occur
983     */     */
984    public void start(String[] args) throws ParseException, IOException    public int start(String[] args) throws ParseException, IOException
985    {    {
986    
987      //--- Collect unparsed arguments in array and resolve references      //--- Collect unparsed arguments in array and resolve references
# Line 1080  public final class Main Line 1106  public final class Main
1106        //--- Show version and exit if requested by user        //--- Show version and exit if requested by user
1107    
1108        if (option_showVersion) {        if (option_showVersion) {
1109          System.err.println("gjdoc " + getGjdocVersion());          System.out.println("gjdoc " + getGjdocVersion());
1110          System.exit(0);          System.exit(0);
1111        }        }
1112    
# Line 1106  public final class Main Line 1132  public final class Main
1132    
1133        //addJavaLangClasses();        //addJavaLangClasses();
1134    
1135        startDoclet(arguments);        if (!startDoclet(arguments)) {
1136            return -1;
1137          }
1138      }      }
1139    
1140      if (reporter.getErrorCount() > 0) {      return reporter.getErrorCount();
       System.exit(1);  
     }  
     else {  
       System.exit(0);  
     }  
1141    }    }
1142    
1143    private void addJavaLangClasses()    private void addJavaLangClasses()
# Line 1632  public final class Main Line 1655  public final class Main
1655    }    }
1656    
1657    /**    /**
    * Shutdown the generator.  
    */  
   public void shutdown()  
   {  
     System.exit(5);  
   }  
   
   /**  
1658     * The root of the gjdoc tool.     * The root of the gjdoc tool.
1659     *     *
1660     * @return all the options of the gjdoc application.     * @return all the options of the gjdoc application.

Legend:
Removed from v.1.69  
changed lines
  Added in v.1.70

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