42 import jdk.javadoc.doclet.Reporter; |
42 import jdk.javadoc.doclet.Reporter; |
43 import jdk.javadoc.internal.doclets.toolkit.builders.BuilderFactory; |
43 import jdk.javadoc.internal.doclets.toolkit.builders.BuilderFactory; |
44 import jdk.javadoc.internal.doclets.toolkit.taglets.TagletManager; |
44 import jdk.javadoc.internal.doclets.toolkit.taglets.TagletManager; |
45 import jdk.javadoc.internal.doclets.toolkit.util.DocFile; |
45 import jdk.javadoc.internal.doclets.toolkit.util.DocFile; |
46 import jdk.javadoc.internal.doclets.toolkit.util.DocFileFactory; |
46 import jdk.javadoc.internal.doclets.toolkit.util.DocFileFactory; |
47 import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; |
47 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; |
48 import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; |
48 import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; |
49 import jdk.javadoc.internal.doclets.toolkit.util.Extern; |
49 import jdk.javadoc.internal.doclets.toolkit.util.Extern; |
50 import jdk.javadoc.internal.doclets.toolkit.util.Group; |
50 import jdk.javadoc.internal.doclets.toolkit.util.Group; |
51 import jdk.javadoc.internal.doclets.toolkit.util.MetaKeywords; |
51 import jdk.javadoc.internal.doclets.toolkit.util.MetaKeywords; |
|
52 import jdk.javadoc.internal.doclets.toolkit.util.SimpleDocletException; |
52 import jdk.javadoc.internal.doclets.toolkit.util.TypeElementCatalog; |
53 import jdk.javadoc.internal.doclets.toolkit.util.TypeElementCatalog; |
53 import jdk.javadoc.internal.doclets.toolkit.util.Utils; |
54 import jdk.javadoc.internal.doclets.toolkit.util.Utils; |
54 import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap.GetterSetter; |
55 import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap.GetterSetter; |
55 |
56 |
56 import static javax.tools.Diagnostic.Kind.*; |
57 import static javax.tools.Diagnostic.Kind.*; |
300 public abstract Messages getMessages(); |
286 public abstract Messages getMessages(); |
301 public abstract Resources getResources(); |
287 public abstract Resources getResources(); |
302 |
288 |
303 /** |
289 /** |
304 * Return the build date for the doclet. |
290 * Return the build date for the doclet. |
|
291 * |
|
292 * @return the build date |
305 */ |
293 */ |
306 public abstract String getDocletSpecificBuildDate(); |
294 public abstract String getDocletSpecificBuildDate(); |
307 |
295 |
308 /** |
296 /** |
309 * This method should be defined in all those doclets(configurations), |
297 * This method should be defined in all those doclets (configurations), |
310 * which want to derive themselves from this Configuration. This method |
298 * which want to derive themselves from this Configuration. This method |
311 * can be used to finish up the options setup. |
299 * can be used to finish up the options setup. |
|
300 * |
|
301 * @return true if successful and false otherwise |
312 */ |
302 */ |
313 |
303 |
314 public abstract boolean finishOptionSettings(); |
304 public abstract boolean finishOptionSettings(); |
315 |
305 |
316 public CommentUtils cmtUtils; |
306 public CommentUtils cmtUtils; |
636 |
626 |
637 /* |
627 /* |
638 * when this is called all the option have been set, this method, |
628 * when this is called all the option have been set, this method, |
639 * initializes certain components before anything else is started. |
629 * initializes certain components before anything else is started. |
640 */ |
630 */ |
641 private void finishOptionSettings0() throws Fault { |
631 private void finishOptionSettings0() throws DocletException { |
642 ensureOutputDirExists(); |
632 initDestDirectory(); |
643 if (urlForLink != null && pkglistUrlForLink != null) |
633 if (urlForLink != null && pkglistUrlForLink != null) |
644 extern.link(urlForLink, pkglistUrlForLink, reporter, false); |
634 extern.link(urlForLink, pkglistUrlForLink, reporter, false); |
645 if (urlForLinkOffline != null && pkglistUrlForLinkOffline != null) |
635 if (urlForLinkOffline != null && pkglistUrlForLinkOffline != null) |
646 extern.link(urlForLinkOffline, pkglistUrlForLinkOffline, reporter, true); |
636 extern.link(urlForLinkOffline, pkglistUrlForLinkOffline, reporter, true); |
647 if (docencoding == null) { |
637 if (docencoding == null) { |
656 |
646 |
657 /** |
647 /** |
658 * Set the command line options supported by this configuration. |
648 * Set the command line options supported by this configuration. |
659 * |
649 * |
660 * @return true if the options are set successfully |
650 * @return true if the options are set successfully |
661 * @throws DocletAbortException |
651 * @throws DocletException if there is a problem while setting the options |
662 */ |
652 */ |
663 public boolean setOptions() throws Fault { |
653 public boolean setOptions() throws DocletException { |
664 try { |
654 initPackages(); |
665 initPackages(); |
655 initModules(); |
666 initModules(); |
656 finishOptionSettings0(); |
667 finishOptionSettings0(); |
657 if (!finishOptionSettings()) |
668 if (!finishOptionSettings()) |
658 return false; |
669 return false; |
659 |
670 |
|
671 } catch (Fault f) { |
|
672 throw new DocletAbortException(f.getMessage()); |
|
673 } |
|
674 return true; |
660 return true; |
675 } |
661 } |
676 |
662 |
677 private void ensureOutputDirExists() throws Fault { |
663 private void initDestDirectory() throws DocletException { |
678 DocFile destDir = DocFile.createFileForDirectory(this, destDirName); |
664 if (!destDirName.isEmpty()) { |
679 if (!destDir.exists()) { |
665 DocFile destDir = DocFile.createFileForDirectory(this, destDirName); |
680 //Create the output directory (in case it doesn't exist yet) |
666 if (!destDir.exists()) { |
681 if (!destDirName.isEmpty()) |
667 //Create the output directory (in case it doesn't exist yet) |
682 reporter.print(NOTE, getText("doclet.dest_dir_create", destDirName)); |
668 reporter.print(NOTE, getText("doclet.dest_dir_create", destDirName)); |
683 destDir.mkdirs(); |
669 destDir.mkdirs(); |
684 } else if (!destDir.isDirectory()) { |
670 } else if (!destDir.isDirectory()) { |
685 throw new Fault(getText( |
671 throw new SimpleDocletException(getText( |
686 "doclet.destination_directory_not_directory_0", |
672 "doclet.destination_directory_not_directory_0", |
687 destDir.getPath())); |
673 destDir.getPath())); |
688 } else if (!destDir.canWrite()) { |
674 } else if (!destDir.canWrite()) { |
689 throw new Fault(getText( |
675 throw new SimpleDocletException(getText( |
690 "doclet.destination_directory_not_writable_0", |
676 "doclet.destination_directory_not_writable_0", |
691 destDir.getPath())); |
677 destDir.getPath())); |
692 } |
678 } |
|
679 } |
|
680 DocFileFactory.getFactory(this).setDestDir(destDirName); |
693 } |
681 } |
694 |
682 |
695 /** |
683 /** |
696 * Initialize the taglet manager. The strings to initialize the simple custom tags should |
684 * Initialize the taglet manager. The strings to initialize the simple custom tags should |
697 * be in the following format: "[tag name]:[location str]:[heading]". |
685 * be in the following format: "[tag name]:[location str]:[heading]". |
|
686 * |
698 * @param customTagStrs the set two dimensional arrays of strings. These arrays contain |
687 * @param customTagStrs the set two dimensional arrays of strings. These arrays contain |
699 * either -tag or -taglet arguments. |
688 * either -tag or -taglet arguments. |
700 */ |
689 */ |
701 private void initTagletManager(Set<List<String>> customTagStrs) { |
690 private void initTagletManager(Set<List<String>> customTagStrs) { |
702 tagletManager = tagletManager == null ? |
691 tagletManager = tagletManager == null ? |
856 } |
845 } |
857 |
846 |
858 /** |
847 /** |
859 * Return true if the given doc-file subdirectory should be excluded and |
848 * Return true if the given doc-file subdirectory should be excluded and |
860 * false otherwise. |
849 * false otherwise. |
|
850 * |
861 * @param docfilesubdir the doc-files subdirectory to check. |
851 * @param docfilesubdir the doc-files subdirectory to check. |
862 * @return true if the directory is excluded. |
852 * @return true if the directory is excluded. |
863 */ |
853 */ |
864 public boolean shouldExcludeDocFileDir(String docfilesubdir){ |
854 public boolean shouldExcludeDocFileDir(String docfilesubdir){ |
865 return excludedDocFileDirs.contains(docfilesubdir); |
855 return excludedDocFileDirs.contains(docfilesubdir); |
866 } |
856 } |
867 |
857 |
868 /** |
858 /** |
869 * Return true if the given qualifier should be excluded and false otherwise. |
859 * Return true if the given qualifier should be excluded and false otherwise. |
|
860 * |
870 * @param qualifier the qualifier to check. |
861 * @param qualifier the qualifier to check. |
|
862 * @return true if the qualifier should be excluded |
871 */ |
863 */ |
872 public boolean shouldExcludeQualifier(String qualifier){ |
864 public boolean shouldExcludeQualifier(String qualifier){ |
873 if (excludedQualifiers.contains("all") || |
865 if (excludedQualifiers.contains("all") || |
874 excludedQualifiers.contains(qualifier) || |
866 excludedQualifiers.contains(qualifier) || |
875 excludedQualifiers.contains(qualifier + ".*")) { |
867 excludedQualifiers.contains(qualifier + ".*")) { |
886 } |
878 } |
887 |
879 |
888 /** |
880 /** |
889 * Return the qualified name of the Element if its qualifier is not excluded. |
881 * Return the qualified name of the Element if its qualifier is not excluded. |
890 * Otherwise return the unqualified Element name. |
882 * Otherwise return the unqualified Element name. |
|
883 * |
891 * @param te the TypeElement to check. |
884 * @param te the TypeElement to check. |
892 * @return the class name |
885 * @return the class name |
893 */ |
886 */ |
894 public String getClassName(TypeElement te) { |
887 public String getClassName(TypeElement te) { |
895 PackageElement pkg = utils.containingPackage(te); |
888 PackageElement pkg = utils.containingPackage(te); |
929 |
922 |
930 /** |
923 /** |
931 * Convenience method to obtain a resource from the doclet's |
924 * Convenience method to obtain a resource from the doclet's |
932 * {@link Resources resources}. |
925 * {@link Resources resources}. |
933 * Equivalent to <code>getResources.getText(key);</code>. |
926 * Equivalent to <code>getResources.getText(key);</code>. |
|
927 * |
934 * @param key the key for the desired string |
928 * @param key the key for the desired string |
935 * @return the string for the given key |
929 * @return the string for the given key |
936 * @throws MissingResourceException if the key is not found in either |
930 * @throws MissingResourceException if the key is not found in either |
937 * bundle. |
931 * bundle. |
938 */ |
932 */ |
940 |
934 |
941 /** |
935 /** |
942 * Convenience method to obtain a resource from the doclet's |
936 * Convenience method to obtain a resource from the doclet's |
943 * {@link Resources resources}. |
937 * {@link Resources resources}. |
944 * Equivalent to <code>getResources.getText(key, args);</code>. |
938 * Equivalent to <code>getResources.getText(key, args);</code>. |
|
939 * |
945 * @param key the key for the desired string |
940 * @param key the key for the desired string |
946 * @param args values to be substituted into the resulting string |
941 * @param args values to be substituted into the resulting string |
947 * @return the string for the given key |
942 * @return the string for the given key |
948 * @throws MissingResourceException if the key is not found in either |
943 * @throws MissingResourceException if the key is not found in either |
949 * bundle. |
944 * bundle. |
1007 return !(utils.isDeprecated(te) || utils.isDeprecated(utils.containingPackage(te))); |
1002 return !(utils.isDeprecated(te) || utils.isDeprecated(utils.containingPackage(te))); |
1008 } |
1003 } |
1009 |
1004 |
1010 /** |
1005 /** |
1011 * Return the doclet specific instance of a writer factory. |
1006 * Return the doclet specific instance of a writer factory. |
|
1007 * |
1012 * @return the {@link WriterFactory} for the doclet. |
1008 * @return the {@link WriterFactory} for the doclet. |
1013 */ |
1009 */ |
1014 public abstract WriterFactory getWriterFactory(); |
1010 public abstract WriterFactory getWriterFactory(); |
1015 |
1011 |
1016 /** |
1012 /** |
1017 * Return the input stream to the builder XML. |
1013 * Return the input stream to the builder XML. |
1018 * |
1014 * |
1019 * @return the input steam to the builder XML. |
1015 * @return the input steam to the builder XML. |
1020 * @throws FileNotFoundException when the given XML file cannot be found. |
1016 * @throws DocFileIOException when the given XML file cannot be found or opened. |
1021 */ |
1017 */ |
1022 public InputStream getBuilderXML() throws IOException { |
1018 public InputStream getBuilderXML() throws DocFileIOException { |
1023 return builderXMLPath == null ? |
1019 return builderXMLPath == null ? |
1024 Configuration.class.getResourceAsStream(DEFAULT_BUILDER_XML) : |
1020 Configuration.class.getResourceAsStream(DEFAULT_BUILDER_XML) : |
1025 DocFile.createFileForInput(this, builderXMLPath).openInputStream(); |
1021 DocFile.createFileForInput(this, builderXMLPath).openInputStream(); |
1026 } |
1022 } |
1027 |
1023 |
1028 /** |
1024 /** |
1029 * Return the Locale for this document. |
1025 * Return the Locale for this document. |
|
1026 * |
1030 * @return the current locale |
1027 * @return the current locale |
1031 */ |
1028 */ |
1032 public abstract Locale getLocale(); |
1029 public abstract Locale getLocale(); |
1033 |
1030 |
1034 /** |
1031 /** |