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 |
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); |
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 |
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 |
{ |
{ |
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 |
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 |
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 |
|
|
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 |
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); |
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 |
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 |
|
|
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 |
} |
} |
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 |
/** |
/** |
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 |
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 |
|
|
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() |
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. |