diff --git a/langtools/make/tools/genstubs/GenStubs.java b/langtools/make/tools/genstubs/GenStubs.java index ff7cbbbf7df..5ff9f35789b 100644 --- a/langtools/make/tools/genstubs/GenStubs.java +++ b/langtools/make/tools/genstubs/GenStubs.java @@ -35,7 +35,7 @@ import com.sun.source.tree.CompilationUnitTree; import com.sun.source.util.JavacTask; import com.sun.tools.javac.api.JavacTool; import com.sun.tools.javac.code.Flags; -import com.sun.tools.javac.code.TypeTags; +import com.sun.tools.javac.code.TypeTag; import com.sun.tools.javac.tree.JCTree; import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; import com.sun.tools.javac.tree.JCTree.JCFieldAccess; @@ -244,23 +244,23 @@ public class GenStubs { else { String t = tree.vartype.toString(); if (t.equals("boolean")) - tree.init = new JCLiteral(TypeTags.BOOLEAN, 0) { }; + tree.init = new JCLiteral(TypeTag.BOOLEAN, 0) { }; else if (t.equals("byte")) - tree.init = new JCLiteral(TypeTags.BYTE, 0) { }; + tree.init = new JCLiteral(TypeTag.BYTE, 0) { }; else if (t.equals("char")) - tree.init = new JCLiteral(TypeTags.CHAR, 0) { }; + tree.init = new JCLiteral(TypeTag.CHAR, 0) { }; else if (t.equals("double")) - tree.init = new JCLiteral(TypeTags.DOUBLE, 0.d) { }; + tree.init = new JCLiteral(TypeTag.DOUBLE, 0.d) { }; else if (t.equals("float")) - tree.init = new JCLiteral(TypeTags.FLOAT, 0.f) { }; + tree.init = new JCLiteral(TypeTag.FLOAT, 0.f) { }; else if (t.equals("int")) - tree.init = new JCLiteral(TypeTags.INT, 0) { }; + tree.init = new JCLiteral(TypeTag.INT, 0) { }; else if (t.equals("long")) - tree.init = new JCLiteral(TypeTags.LONG, 0) { }; + tree.init = new JCLiteral(TypeTag.LONG, 0) { }; else if (t.equals("short")) - tree.init = new JCLiteral(TypeTags.SHORT, 0) { }; + tree.init = new JCLiteral(TypeTag.SHORT, 0) { }; else - tree.init = new JCLiteral(TypeTags.BOT, null) { }; + tree.init = new JCLiteral(TypeTag.BOT, null) { }; } } result = tree; diff --git a/langtools/src/share/classes/com/sun/javadoc/SerialFieldTag.java b/langtools/src/share/classes/com/sun/javadoc/SerialFieldTag.java index ad32c1a1d43..7f73936588f 100644 --- a/langtools/src/share/classes/com/sun/javadoc/SerialFieldTag.java +++ b/langtools/src/share/classes/com/sun/javadoc/SerialFieldTag.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ package com.sun.javadoc; public interface SerialFieldTag extends Tag, Comparable
* + *This is NOT part of any supported API. + * If you write code that depends on this, you do so at your own risk. + * This code and its internal interfaces are subject to change or + * deletion without notice. + * * @author Robert Field. * @author Atul Dambalkar. * @author Jamie Ho @@ -61,11 +65,6 @@ public class ConfigurationImpl extends Configuration { */ public static final String BUILD_DATE = System.getProperty("java.version"); - /** - * The name of the constant values file. - */ - public static final String CONSTANTS_FILE_NAME = "constant-values.html"; - /** * Argument for command line option "-header". */ @@ -179,7 +178,7 @@ public class ConfigurationImpl extends Configuration { * First file to appear in the right-hand frame in the generated * documentation. */ - public String topFile = ""; + public DocPath topFile = DocPath.empty; /** * The classdoc for the class file getting generated. @@ -367,7 +366,7 @@ public class ConfigurationImpl extends Configuration { "-helpfile")); return false; } - File help = new File(os[1]); + DocFile help = DocFile.createFileForInput(this, os[1]); if (!help.exists()) { reporter.printError(getText("doclet.File_not_found", os[1])); return false; @@ -447,18 +446,17 @@ public class ConfigurationImpl extends Configuration { return; } if (createoverview) { - topFile = "overview-summary.html"; + topFile = DocPaths.OVERVIEW_SUMMARY; } else { if (packages.length == 1 && packages[0].name().equals("")) { if (root.classes().length > 0) { ClassDoc[] classarr = root.classes(); Arrays.sort(classarr); ClassDoc cd = getValidClass(classarr); - topFile = DirectoryManager.getPathToClass(cd); + topFile = DocPath.forClass(cd); } } else { - topFile = DirectoryManager.getPathToPackage(packages[0], - "package-summary.html"); + topFile = DocPath.forPackage(packages[0]).resolve(DocPaths.PACKAGE_SUMMARY); } } } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java index d6902610c02..ec98f180410 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java @@ -69,7 +69,7 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter */ public ConstantsSummaryWriterImpl(ConfigurationImpl configuration) throws IOException { - super(configuration, ConfigurationImpl.CONSTANTS_FILE_NAME); + super(configuration, DocPaths.CONSTANT_VALUES); this.configuration = configuration; constantsTableSummary = configuration.getText("doclet.Constants_Table_Summary", configuration.getText("doclet.Constants_Summary")); @@ -107,13 +107,13 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter //add link to summary Content link; if (packageName.length() == 0) { - link = getHyperLink("#" + DocletConstants.UNNAMED_PACKAGE_ANCHOR, - "", defaultPackageLabel, "", ""); + link = getHyperLink(DocLink.fragment(DocletConstants.UNNAMED_PACKAGE_ANCHOR), + defaultPackageLabel, "", ""); } else { Content packageNameContent = getPackageLabel(parsedPackageName); packageNameContent.addContent(".*"); - link = getHyperLink("#" + parsedPackageName, - "", packageNameContent, "", ""); + link = getHyperLink(DocLink.fragment(parsedPackageName), + packageNameContent, "", ""); printedPackageHeaders.add(parsedPackageName); } contentListTree.addContent(HtmlTree.LI(link)); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java index 22a52a41409..6e2a5ec5284 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java @@ -280,7 +280,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter */ protected Content getNavSummaryLink(ClassDoc cd, boolean link) { if (link) { - return writer.getHyperLink("", "constructor_summary", + return writer.getHyperLink("constructor_summary", writer.getResource("doclet.navConstructor")); } else { return writer.getResource("doclet.navConstructor"); @@ -292,7 +292,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter */ protected void addNavDetailLink(boolean link, Content liNav) { if (link) { - liNav.addContent(writer.getHyperLink("", "constructor_detail", + liNav.addContent(writer.getHyperLink("constructor_detail", writer.getResource("doclet.navConstructor"))); } else { liNav.addContent(writer.getResource("doclet.navConstructor")); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java index 5d852171964..bb989452b85 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java @@ -95,7 +95,7 @@ public class DeprecatedListWriter extends SubWriterHolderWriter { * @param filename the file to be generated. */ public DeprecatedListWriter(ConfigurationImpl configuration, - String filename) throws IOException { + DocPath filename) throws IOException { super(configuration, filename); this.configuration = configuration; NestedClassWriterImpl classW = new NestedClassWriterImpl(this); @@ -116,7 +116,7 @@ public class DeprecatedListWriter extends SubWriterHolderWriter { * @param configuration the current configuration of the doclet. */ public static void generate(ConfigurationImpl configuration) { - String filename = "deprecated-list.html"; + DocPath filename = DocPaths.DEPRECATED_LIST; try { DeprecatedListWriter depr = new DeprecatedListWriter(configuration, filename); @@ -180,7 +180,7 @@ public class DeprecatedListWriter extends SubWriterHolderWriter { private void addIndexLink(DeprecatedAPIListBuilder builder, int type, Content contentTree) { if (builder.hasDocumentation(type)) { - Content li = HtmlTree.LI(getHyperLink("#" + ANCHORS[type], + Content li = HtmlTree.LI(getHyperLink(ANCHORS[type], getResource(HEADING_KEYS[type]))); contentTree.addContent(li); } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java index 7e1a977ddb9..b06255ad9a6 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java @@ -263,7 +263,7 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter */ protected Content getNavSummaryLink(ClassDoc cd, boolean link) { if (link) { - return writer.getHyperLink("", (cd == null)? + return writer.getHyperLink((cd == null)? "enum_constant_summary": "enum_constants_inherited_from_class_" + configuration().getClassName(cd), @@ -278,7 +278,7 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter */ protected void addNavDetailLink(boolean link, Content liNav) { if (link) { - liNav.addContent(writer.getHyperLink("", "enum_constant_detail", + liNav.addContent(writer.getHyperLink("enum_constant_detail", writer.getResource("doclet.navEnum"))); } else { liNav.addContent(writer.getResource("doclet.navEnum")); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java index 3f00063060d..10f076a08af 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java @@ -293,7 +293,7 @@ public class FieldWriterImpl extends AbstractMemberWriter */ protected Content getNavSummaryLink(ClassDoc cd, boolean link) { if (link) { - return writer.getHyperLink("", (cd == null)? + return writer.getHyperLink((cd == null)? "field_summary": "fields_inherited_from_class_" + configuration().getClassName(cd), @@ -308,7 +308,7 @@ public class FieldWriterImpl extends AbstractMemberWriter */ protected void addNavDetailLink(boolean link, Content liNav) { if (link) { - liNav.addContent(writer.getHyperLink("", "field_detail", + liNav.addContent(writer.getHyperLink("field_detail", writer.getResource("doclet.navField"))); } else { liNav.addContent(writer.getResource("doclet.navField")); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java index 006e8e2a1c7..6a39cedee6d 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java @@ -63,7 +63,7 @@ public class FrameOutputWriter extends HtmlDocletWriter { * @param filename File to be generated. */ public FrameOutputWriter(ConfigurationImpl configuration, - String filename) throws IOException { + DocPath filename) throws IOException { super(configuration, filename); noOfPackages = configuration.packages.length; } @@ -77,9 +77,9 @@ public class FrameOutputWriter extends HtmlDocletWriter { */ public static void generate(ConfigurationImpl configuration) { FrameOutputWriter framegen; - String filename = ""; + DocPath filename = DocPath.empty; try { - filename = "index.html"; + filename = DocPaths.INDEX; framegen = new FrameOutputWriter(configuration, filename); framegen.generateFrameFile(); framegen.close(); @@ -92,7 +92,7 @@ public class FrameOutputWriter extends HtmlDocletWriter { } /** - * Generate the contants in the "index.html" file. Print the frame details + * Generate the constants in the "index.html" file. Print the frame details * as well as warning if browser is not supporting the Html frames. */ protected void generateFrameFile() throws IOException { @@ -155,8 +155,8 @@ public class FrameOutputWriter extends HtmlDocletWriter { * @param contentTree the content tree to which the information will be added */ private void addAllPackagesFrameTag(Content contentTree) { - HtmlTree frame = HtmlTree.FRAME("overview-frame.html", "packageListFrame", - configuration.getText("doclet.All_Packages")); + HtmlTree frame = HtmlTree.FRAME(DocPaths.OVERVIEW_FRAME.getPath(), + "packageListFrame", configuration.getText("doclet.All_Packages")); contentTree.addContent(frame); } @@ -166,8 +166,8 @@ public class FrameOutputWriter extends HtmlDocletWriter { * @param contentTree the content tree to which the information will be added */ private void addAllClassesFrameTag(Content contentTree) { - HtmlTree frame = HtmlTree.FRAME("allclasses-frame.html", "packageFrame", - configuration.getText("doclet.All_classes_and_interfaces")); + HtmlTree frame = HtmlTree.FRAME(DocPaths.ALLCLASSES_FRAME.getPath(), + "packageFrame", configuration.getText("doclet.All_classes_and_interfaces")); contentTree.addContent(frame); } @@ -177,7 +177,7 @@ public class FrameOutputWriter extends HtmlDocletWriter { * @param contentTree the content tree to which the information will be added */ private void addClassFrameTag(Content contentTree) { - HtmlTree frame = HtmlTree.FRAME(configuration.topFile, "classFrame", + HtmlTree frame = HtmlTree.FRAME(configuration.topFile.getPath(), "classFrame", configuration.getText("doclet.Package_class_and_interface_descriptions"), SCROLL_YES); contentTree.addContent(frame); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java index b5e6ac3bb2d..9d14671f3d2 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java @@ -49,7 +49,7 @@ public class HelpWriter extends HtmlDocletWriter { * @param filename File to be generated. */ public HelpWriter(ConfigurationImpl configuration, - String filename) throws IOException { + DocPath filename) throws IOException { super(configuration, filename); } @@ -62,9 +62,9 @@ public class HelpWriter extends HtmlDocletWriter { */ public static void generate(ConfigurationImpl configuration) { HelpWriter helpgen; - String filename = ""; + DocPath filename = DocPath.empty; try { - filename = "help-doc.html"; + filename = DocPaths.HELP_DOC; helpgen = new HelpWriter(configuration, filename); helpgen.generateHelpFile(); helpgen.close(); @@ -113,7 +113,7 @@ public class HelpWriter extends HtmlDocletWriter { getResource("doclet.Overview")); Content liOverview = HtmlTree.LI(HtmlStyle.blockList, overviewHeading); Content line3 = getResource("doclet.Help_line_3", - getHyperLinkString("overview-summary.html", + getHyperLinkString(DocPaths.OVERVIEW_SUMMARY, configuration.getText("doclet.Overview"))); Content overviewPara = HtmlTree.P(line3); liOverview.addContent(overviewPara); @@ -234,7 +234,7 @@ public class HelpWriter extends HtmlDocletWriter { getResource("doclet.Help_line_16")); Content liTree = HtmlTree.LI(HtmlStyle.blockList, treeHead); Content line17 = getResource("doclet.Help_line_17_with_tree_link", - getHyperLinkString("overview-tree.html", + getHyperLinkString(DocPaths.OVERVIEW_TREE, configuration.getText("doclet.Class_Hierarchy"))); Content treePara = HtmlTree.P(line17); liTree.addContent(treePara); @@ -252,7 +252,7 @@ public class HelpWriter extends HtmlDocletWriter { getResource("doclet.Deprecated_API")); Content liDeprecated = HtmlTree.LI(HtmlStyle.blockList, dHead); Content line20 = getResource("doclet.Help_line_20_with_deprecated_api_link", - getHyperLinkString("deprecated-list.html", + getHyperLinkString(DocPaths.DEPRECATED_LIST, configuration.getText("doclet.Deprecated_API"))); Content dPara = HtmlTree.P(line20); liDeprecated.addContent(dPara); @@ -261,10 +261,10 @@ public class HelpWriter extends HtmlDocletWriter { if (configuration.createindex) { String indexlink; if (configuration.splitindex) { - indexlink = getHyperLinkString("index-files/index-1.html", + indexlink = getHyperLinkString(DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1)), configuration.getText("doclet.Index")); } else { - indexlink = getHyperLinkString("index-all.html", + indexlink = getHyperLinkString(DocPaths.INDEX_ALL, configuration.getText("doclet.Index")); } Content indexHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, @@ -293,7 +293,7 @@ public class HelpWriter extends HtmlDocletWriter { getResource("doclet.All_Classes")); Content liAllClasses = HtmlTree.LI(HtmlStyle.blockList, allclassesHead); Content line27 = getResource("doclet.Help_line_27", - getHyperLinkString("allclasses-noframe.html", + getHyperLinkString(DocPaths.ALLCLASSES_NOFRAME, configuration.getText("doclet.All_Classes"))); Content allclassesPara = HtmlTree.P(line27); liAllClasses.addContent(allclassesPara); @@ -309,7 +309,7 @@ public class HelpWriter extends HtmlDocletWriter { getResource("doclet.Constants_Summary")); Content liConst = HtmlTree.LI(HtmlStyle.blockList, constHead); Content line29 = getResource("doclet.Help_line_29", - getHyperLinkString("constant-values.html", + getHyperLinkString(DocPaths.CONSTANT_VALUES, configuration.getText("doclet.Constants_Summary"))); Content constPara = HtmlTree.P(line29); liConst.addContent(constPara); @@ -325,6 +325,7 @@ public class HelpWriter extends HtmlDocletWriter { * * @return a content tree for the help label */ + @Override protected Content getNavLinkHelp() { Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, helpLabel); return li; diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java index ef5bb2477de..6a9f691cedd 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java @@ -94,31 +94,22 @@ public class HtmlDoclet extends AbstractDoclet { throws Exception { super.generateOtherFiles(root, classtree); if (configuration.linksource) { - if (configuration.destDirName.length() > 0) { - SourceToHTMLConverter.convertRoot(configuration, - root, configuration.destDirName + File.separator - + DocletConstants.SOURCE_OUTPUT_DIR_NAME); - } else { - SourceToHTMLConverter.convertRoot(configuration, - root, DocletConstants.SOURCE_OUTPUT_DIR_NAME); - } + SourceToHTMLConverter.convertRoot(configuration, + root, DocPaths.SOURCE_OUTPUT); } - if (configuration.topFile.length() == 0) { + if (configuration.topFile.isEmpty()) { configuration.standardmessage. error("doclet.No_Non_Deprecated_Classes_To_Document"); return; } boolean nodeprecated = configuration.nodeprecated; - String configdestdir = configuration.destDirName; - String confighelpfile = configuration.helpfile; - String configstylefile = configuration.stylesheetfile; - performCopy(configdestdir, confighelpfile); - performCopy(configdestdir, configstylefile); - Util.copyResourceFile(configuration, "background.gif", false); - Util.copyResourceFile(configuration, "tab.gif", false); - Util.copyResourceFile(configuration, "titlebar.gif", false); - Util.copyResourceFile(configuration, "titlebar_end.gif", false); + performCopy(configuration.helpfile); + performCopy(configuration.stylesheetfile); + copyResourceFile("background.gif"); + copyResourceFile("tab.gif"); + copyResourceFile("titlebar.gif"); + copyResourceFile("titlebar_end.gif"); // do early to reduce memory footprint if (configuration.classuse) { ClassUseWriter.generate(configuration, classtree); @@ -155,9 +146,8 @@ public class HtmlDoclet extends AbstractDoclet { // If a stylesheet file is not specified, copy the default stylesheet // and replace newline with platform-specific newline. if (configuration.stylesheetfile.length() == 0) { - Util.copyFile(configuration, "stylesheet.css", Util.RESOURCESDIR, - (configdestdir.isEmpty()) ? - System.getProperty("user.dir") : configdestdir, false, true); + DocFile f = DocFile.createFileForOutput(configuration, DocPaths.STYLESHEET); + f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.STYLESHEET), false, true); } } @@ -258,29 +248,33 @@ public class HtmlDoclet extends AbstractDoclet { return (ConfigurationImpl.getInstance()).validOptions(options, reporter); } - private void performCopy(String configdestdir, String filename) { + /** + * Copy a file in the resources directory to the destination directory. + * @param resource The name of the resource file to copy + */ + private void copyResourceFile(String resource) { + DocPath p = DocPaths.RESOURCES.resolve(resource); + DocFile f = DocFile.createFileForOutput(configuration, p); + f.copyResource(p, false, false); + } + + private void performCopy(String filename) { + if (filename.isEmpty()) + return; + try { - String destdir = (configdestdir.length() > 0) ? - configdestdir + File.separatorChar: ""; - if (filename.length() > 0) { - File helpstylefile = new File(filename); - String parent = helpstylefile.getParent(); - String helpstylefilename = (parent == null)? - filename: - filename.substring(parent.length() + 1); - File desthelpfile = new File(destdir + helpstylefilename); - if (!desthelpfile.getCanonicalPath().equals( - helpstylefile.getCanonicalPath())) { - configuration.message. - notice((SourcePosition) null, - "doclet.Copying_File_0_To_File_1", - helpstylefile.toString(), desthelpfile.toString()); - Util.copyFile(desthelpfile, helpstylefile); - } - } + DocFile fromfile = DocFile.createFileForInput(configuration, filename); + DocPath path = DocPath.create(fromfile.getName()); + DocFile toFile = DocFile.createFileForOutput(configuration, path); + if (toFile.isSameFile(fromfile)) + return; + + configuration.message.notice((SourcePosition) null, + "doclet.Copying_File_0_To_File_1", + fromfile.toString(), path.getPath()); + toFile.copyFile(fromfile); } catch (IOException exc) { - configuration.message. - error((SourcePosition) null, + configuration.message.error((SourcePosition) null, "doclet.perform_copy_exception_encountered", exc.toString()); throw new DocletAbortException(); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java index c5bd281e82f..0531db15abd 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java @@ -55,32 +55,24 @@ public class HtmlDocletWriter extends HtmlDocWriter { /** * Relative path from the file getting generated to the destination * directory. For example, if the file getting generated is - * "java/lang/Object.html", then the relative path string is "../../". + * "java/lang/Object.html", then the path to the root is "../..". * This string can be empty if the file getting generated is in * the destination directory. */ - public String relativePath = ""; + public final DocPath pathToRoot; /** - * Same as relativepath, but normalized to never be empty or - * end with a slash. - */ - public String relativepathNoSlash = ""; - - /** - * Platform-dependent directory path from the current or the + * Platform-independent path from the current or the * destination directory to the file getting generated. * Used when creating the file. - * For example, if the file getting generated is - * "java/lang/Object.html", then the path string is "java/lang". */ - public String path = ""; + public final DocPath path; /** * Name of the file getting generated. If the file getting generated is * "java/lang/Object.html", then the filename is "Object.html". */ - public String filename = ""; + public final DocPath filename; /** * The display length used for indentation while generating the class page. @@ -100,33 +92,15 @@ public class HtmlDocletWriter extends HtmlDocWriter { /** * Constructor to construct the HtmlStandardWriter object. * - * @param filename File to be generated. + * @param path File to be generated. */ - public HtmlDocletWriter(ConfigurationImpl configuration, - String filename) throws IOException { - super(configuration, filename); - this.configuration = configuration; - this.filename = filename; - } - - /** - * Constructor to construct the HtmlStandardWriter object. - * - * @param path Platform-dependent {@link #path} used when - * creating file. - * @param filename Name of file to be generated. - * @param relativePath Value for the variable {@link #relativePath}. - */ - public HtmlDocletWriter(ConfigurationImpl configuration, - String path, String filename, - String relativePath) throws IOException { - super(configuration, path, filename); + public HtmlDocletWriter(ConfigurationImpl configuration, DocPath path) + throws IOException { + super(configuration, path); this.configuration = configuration; this.path = path; - this.relativePath = relativePath; - this.relativepathNoSlash = - DirectoryManager.getPathNoTrailingSlash(this.relativePath); - this.filename = filename; + this.pathToRoot = path.parent().invert(); + this.filename = path.basename(); } /** @@ -165,8 +139,9 @@ public class HtmlDocletWriter extends HtmlDocWriter { int previndex = 0; while (true) { if (configuration.docrootparent.length() > 0) { + final String docroot_parent = "{@docroot}/.."; // Search for lowercase version of {@docRoot}/.. - index = lowerHtml.indexOf("{@docroot}/..", previndex); + index = lowerHtml.indexOf(docroot_parent, previndex); // If next {@docRoot}/.. pattern not found, append rest of htmlstr and exit loop if (index < 0) { buf.append(htmlstr.substring(previndex)); @@ -174,17 +149,18 @@ public class HtmlDocletWriter extends HtmlDocWriter { } // If next {@docroot}/.. pattern found, append htmlstr up to start of tag buf.append(htmlstr.substring(previndex, index)); - previndex = index + 13; // length for {@docroot}/.. string + previndex = index + docroot_parent.length(); // Insert docrootparent absolute path where {@docRoot}/.. was located buf.append(configuration.docrootparent); // Append slash if next character is not a slash if (previndex < htmlstr.length() && htmlstr.charAt(previndex) != '/') { - buf.append(DirectoryManager.URL_FILE_SEPARATOR); + buf.append('/'); } } else { + final String docroot = "{@docroot}"; // Search for lowercase version of {@docRoot} - index = lowerHtml.indexOf("{@docroot}", previndex); + index = lowerHtml.indexOf(docroot, previndex); // If next {@docRoot} tag not found, append rest of htmlstr and exit loop if (index < 0) { buf.append(htmlstr.substring(previndex)); @@ -192,13 +168,12 @@ public class HtmlDocletWriter extends HtmlDocWriter { } // If next {@docroot} tag found, append htmlstr up to start of tag buf.append(htmlstr.substring(previndex, index)); - previndex = index + 10; // length for {@docroot} string + previndex = index + docroot.length(); // Insert relative path where {@docRoot} was located - buf.append(relativepathNoSlash); + buf.append(pathToRoot.isEmpty() ? "." : pathToRoot.getPath()); // Append slash if next character is not a slash - if (relativepathNoSlash.length() > 0 && previndex < htmlstr.length() && - htmlstr.charAt(previndex) != '/') { - buf.append(DirectoryManager.URL_FILE_SEPARATOR); + if (previndex < htmlstr.length() && htmlstr.charAt(previndex) != '/') { + buf.append('/'); } } } @@ -312,7 +287,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { */ public Content getTargetPackageLink(PackageDoc pd, String target, Content label) { - return getHyperLink(pathString(pd, "package-summary.html"), "", label, "", target); + return getHyperLink(pathString(pd, DocPaths.PACKAGE_SUMMARY), label, "", target); } /** @@ -432,9 +407,10 @@ public class HtmlDocletWriter extends HtmlDocWriter { allClassesId += "navbar_top"; Content a = getMarkerAnchor("navbar_top"); navDiv.addContent(a); - Content skipLinkContent = getHyperLink("", - "skip-navbar_top", HtmlTree.EMPTY, configuration.getText( - "doclet.Skip_navigation_links"), ""); + Content skipLinkContent = getHyperLink(DocLink.fragment("skip-navbar_top"), + HtmlTree.EMPTY, + configuration.getText("doclet.Skip_navigation_links"), + ""); navDiv.addContent(skipLinkContent); } else { body.addContent(HtmlConstants.START_OF_BOTTOM_NAVBAR); @@ -442,9 +418,10 @@ public class HtmlDocletWriter extends HtmlDocWriter { allClassesId += "navbar_bottom"; Content a = getMarkerAnchor("navbar_bottom"); navDiv.addContent(a); - Content skipLinkContent = getHyperLink("", - "skip-navbar_bottom", HtmlTree.EMPTY, configuration.getText( - "doclet.Skip_navigation_links"), ""); + Content skipLinkContent = getHyperLink(DocLink.fragment("skip-navbar_bottom"), + HtmlTree.EMPTY, + configuration.getText("doclet.Skip_navigation_links"), + ""); navDiv.addContent(skipLinkContent); } if (header) { @@ -539,8 +516,8 @@ public class HtmlDocletWriter extends HtmlDocWriter { * @return a content tree for the link */ protected Content getNavLinkContents() { - Content linkContent = getHyperLink(relativePath + - "overview-summary.html", "", overviewLabel, "", ""); + Content linkContent = getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_SUMMARY), + overviewLabel, "", ""); Content li = HtmlTree.LI(linkContent); return li; } @@ -584,10 +561,10 @@ public class HtmlDocletWriter extends HtmlDocWriter { * @param prev File name for the prev link * @return a content tree for the link */ - public Content getNavLinkPrevious(String prev) { + public Content getNavLinkPrevious(DocPath prev) { Content li; if (prev != null) { - li = HtmlTree.LI(getHyperLink(prev, "", prevLabel, "", "")); + li = HtmlTree.LI(getHyperLink(prev, prevLabel, "", "")); } else li = HtmlTree.LI(prevLabel); @@ -601,10 +578,10 @@ public class HtmlDocletWriter extends HtmlDocWriter { * @param next File name for the next link * @return a content tree for the link */ - public Content getNavLinkNext(String next) { + public Content getNavLinkNext(DocPath next) { Content li; if (next != null) { - li = HtmlTree.LI(getHyperLink(next, "", nextLabel, "", "")); + li = HtmlTree.LI(getHyperLink(next, nextLabel, "", "")); } else li = HtmlTree.LI(nextLabel); @@ -617,9 +594,9 @@ public class HtmlDocletWriter extends HtmlDocWriter { * @param link File to be linked, "index.html" * @return a content tree for the link */ - protected Content getNavShowLists(String link) { - Content framesContent = getHyperLink(link + "?" + path + - filename, "", framesLabel, "", "_top"); + protected Content getNavShowLists(DocPath link) { + DocLink dl = new DocLink(link, path.getPath(), null); + Content framesContent = getHyperLink(dl, framesLabel, "", "_top"); Content li = HtmlTree.LI(framesContent); return li; } @@ -630,7 +607,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { * @return a content tree for the link */ protected Content getNavShowLists() { - return getNavShowLists(relativePath + "index.html"); + return getNavShowLists(pathToRoot.resolve(DocPaths.INDEX)); } /** @@ -639,8 +616,8 @@ public class HtmlDocletWriter extends HtmlDocWriter { * @param link File to be linked * @return a content tree for the link */ - protected Content getNavHideLists(String link) { - Content noFramesContent = getHyperLink(link, "", noframesLabel, "", "_top"); + protected Content getNavHideLists(DocPath link) { + Content noFramesContent = getHyperLink(link, noframesLabel, "", "_top"); Content li = HtmlTree.LI(noFramesContent); return li; } @@ -658,11 +635,11 @@ public class HtmlDocletWriter extends HtmlDocWriter { PackageDoc[] packages = configuration.root.specifiedPackages(); if (packages.length == 1 && configuration.root.specifiedClasses().length == 0) { treeLinkContent = getHyperLink(pathString(packages[0], - "package-tree.html"), "", treeLabel, + DocPaths.PACKAGE_TREE), treeLabel, "", ""); } else { - treeLinkContent = getHyperLink(relativePath + "overview-tree.html", - "", treeLabel, "", ""); + treeLinkContent = getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), + treeLabel, "", ""); } Content li = HtmlTree.LI(treeLinkContent); return li; @@ -675,7 +652,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { * @return a content tree for the link */ protected Content getNavLinkMainTree(String label) { - Content mainTreeContent = getHyperLink(relativePath + "overview-tree.html", + Content mainTreeContent = getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), new StringContent(label)); Content li = HtmlTree.LI(mainTreeContent); return li; @@ -697,8 +674,8 @@ public class HtmlDocletWriter extends HtmlDocWriter { * @return a content tree for the link */ protected Content getNavLinkDeprecated() { - Content linkContent = getHyperLink(relativePath + - "deprecated-list.html", "", deprecatedLabel, "", ""); + Content linkContent = getHyperLink(pathToRoot.resolve(DocPaths.DEPRECATED_LIST), + deprecatedLabel, "", ""); Content li = HtmlTree.LI(linkContent); return li; } @@ -711,8 +688,8 @@ public class HtmlDocletWriter extends HtmlDocWriter { * @return a content tree for the link */ protected Content getNavLinkClassIndex() { - Content allClassesContent = getHyperLink(relativePath + - AllClassesFrameWriter.OUTPUT_FILE_NAME_NOFRAMES, "", + Content allClassesContent = getHyperLink(pathToRoot.resolve( + DocPaths.ALLCLASSES_NOFRAME), allclassesLabel, "", ""); Content li = HtmlTree.LI(allClassesContent); return li; @@ -724,9 +701,10 @@ public class HtmlDocletWriter extends HtmlDocWriter { * @return a content tree for the link */ protected Content getNavLinkIndex() { - Content linkContent = getHyperLink(relativePath +(configuration.splitindex? - DirectoryManager.getPath("index-files") + fileseparator: "") + - (configuration.splitindex?"index-1.html" : "index-all.html"), "", + Content linkContent = getHyperLink(pathToRoot.resolve( + (configuration.splitindex + ? DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1)) + : DocPaths.INDEX_ALL)), indexLabel, "", ""); Content li = HtmlTree.LI(linkContent); return li; @@ -740,16 +718,15 @@ public class HtmlDocletWriter extends HtmlDocWriter { * @return a content tree for the link */ protected Content getNavLinkHelp() { - String helpfilenm = configuration.helpfile; - if (helpfilenm.equals("")) { - helpfilenm = "help-doc.html"; + String helpfile = configuration.helpfile; + DocPath helpfilenm; + if (helpfile.isEmpty()) { + helpfilenm = DocPaths.HELP_DOC; } else { - int lastsep; - if ((lastsep = helpfilenm.lastIndexOf(File.separatorChar)) != -1) { - helpfilenm = helpfilenm.substring(lastsep + 1); - } + DocFile file = DocFile.createFileForInput(configuration, helpfile); + helpfilenm = DocPath.create(file.getName()); } - Content linkContent = getHyperLink(relativePath + helpfilenm, "", + Content linkContent = getHyperLink(pathToRoot.resolve(helpfilenm), helpLabel, "", ""); Content li = HtmlTree.LI(linkContent); return li; @@ -884,25 +861,12 @@ public class HtmlDocletWriter extends HtmlDocWriter { } /** - * Return path to the class page for a classdoc. For example, the class - * name is "java.lang.Object" and if the current file getting generated is - * "java/io/File.html", then the path string to the class, returned is - * "../../java/lang.Object.html". - * - * @param cd Class to which the path is requested. - */ - protected String pathToClass(ClassDoc cd) { - return pathString(cd.containingPackage(), cd.name() + ".html"); - } - - /** - * Return the path to the class page for a classdoc. Works same as - * {@link #pathToClass(ClassDoc)}. + * Return the path to the class page for a classdoc. * * @param cd Class to which the path is requested. * @param name Name of the file(doesn't include path). */ - protected String pathString(ClassDoc cd, String name) { + protected DocPath pathString(ClassDoc cd, DocPath name) { return pathString(cd.containingPackage(), name); } @@ -915,10 +879,8 @@ public class HtmlDocletWriter extends HtmlDocWriter { * @param pd Package in which the file name is assumed to be. * @param name File name, to which path string is. */ - protected String pathString(PackageDoc pd, String name) { - StringBuilder buf = new StringBuilder(relativePath); - buf.append(DirectoryManager.getPathToPackage(pd, name)); - return buf.toString(); + protected DocPath pathString(PackageDoc pd, DocPath name) { + return pathToRoot.resolve(DocPath.forPackage(pd).resolve(name)); } /** @@ -956,12 +918,12 @@ public class HtmlDocletWriter extends HtmlDocWriter { } } if (included || pkg == null) { - return getHyperLinkString(pathString(pkg, "package-summary.html"), - "", label, isStrong, style); + return getHyperLinkString(pathString(pkg, DocPaths.PACKAGE_SUMMARY), + label, isStrong, style); } else { - String crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg)); + DocLink crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg)); if (crossPkgLink != null) { - return getHyperLinkString(crossPkgLink, "", label, isStrong, style); + return getHyperLinkString(crossPkgLink, label, isStrong, style); } else { return label; } @@ -987,12 +949,12 @@ public class HtmlDocletWriter extends HtmlDocWriter { } } if (included || pkg == null) { - return getHyperLink(pathString(pkg, "package-summary.html"), - "", label); + return getHyperLink(pathString(pkg, DocPaths.PACKAGE_SUMMARY), + label); } else { - String crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg)); + DocLink crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg)); if (crossPkgLink != null) { - return getHyperLink(crossPkgLink, "", label); + return getHyperLink(crossPkgLink, label); } else { return label; } @@ -1020,10 +982,10 @@ public class HtmlDocletWriter extends HtmlDocWriter { //d must be a class doc since in has no containing class. cd = (ClassDoc) doc; } - String href = relativePath + DocletConstants.SOURCE_OUTPUT_DIR_NAME - + DirectoryManager.getDirectoryPath(cd.containingPackage()) - + cd.name() + ".html#" + SourceToHTMLConverter.getAnchorName(doc); - Content linkContent = getHyperLink(href, "", label, "", ""); + DocPath href = pathToRoot + .resolve(DocPaths.SOURCE_OUTPUT) + .resolve(DocPath.forClass(cd)); + Content linkContent = getHyperLink(href.fragment(SourceToHTMLConverter.getAnchorName(doc)), label, "", ""); htmltree.addContent(linkContent); } @@ -1036,7 +998,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { */ public String getLink(LinkInfoImpl linkInfo) { LinkFactoryImpl factory = new LinkFactoryImpl(this); - String link = ((LinkOutputImpl) factory.getLinkOutput(linkInfo)).toString(); + String link = factory.getLinkOutput(linkInfo).toString(); displayLength += linkInfo.displayLength; return link; } @@ -1049,8 +1011,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { */ public String getTypeParameterLinks(LinkInfoImpl linkInfo) { LinkFactoryImpl factory = new LinkFactoryImpl(this); - return ((LinkOutputImpl) - factory.getTypeParameterLinks(linkInfo, false)).toString(); + return factory.getTypeParameterLinks(linkInfo, false).toString(); } /************************************************************* @@ -1070,10 +1031,10 @@ public class HtmlDocletWriter extends HtmlDocWriter { public String getCrossClassLink(String qualifiedClassName, String refMemName, String label, boolean strong, String style, boolean code) { - String className = "", - packageName = qualifiedClassName == null ? "" : qualifiedClassName; + String className = ""; + String packageName = qualifiedClassName == null ? "" : qualifiedClassName; int periodIndex; - while((periodIndex = packageName.lastIndexOf('.')) != -1) { + while ((periodIndex = packageName.lastIndexOf('.')) != -1) { className = packageName.substring(periodIndex + 1, packageName.length()) + (className.length() > 0 ? "." + className : ""); String defaultLabel = code ? codeText(className) : className; @@ -1084,11 +1045,12 @@ public class HtmlDocletWriter extends HtmlDocWriter { //the -link option. There are ways to determine if an external package //exists, but no way to determine if the external class exists. We just //have to assume that it does. - return getHyperLinkString( - configuration.extern.getExternalLink(packageName, relativePath, - className + ".html?is-external=true"), - refMemName == null ? "" : refMemName, - label == null || label.length() == 0 ? defaultLabel : label, + DocLink link = configuration.extern.getExternalLink(packageName, pathToRoot, + className + ".html", refMemName); + return getHyperLinkString(link, + (label == null) || label.length() == 0 ? defaultLabel : label, + + strong, style, configuration.getText("doclet.Href_Class_Or_Interface_Title", packageName), ""); @@ -1104,9 +1066,9 @@ public class HtmlDocletWriter extends HtmlDocWriter { return configuration.extern.isExternal(cd); } - public String getCrossPackageLink(String pkgName) { - return configuration.extern.getExternalLink(pkgName, relativePath, - "package-summary.html?is-external=true"); + public DocLink getCrossPackageLink(String pkgName) { + return configuration.extern.getExternalLink(pkgName, pathToRoot, + DocPaths.PACKAGE_SUMMARY.getPath()); } /** @@ -1134,7 +1096,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { /** * Retrieve the class link with the package portion of the label in - * plain text. If the qualifier is excluded, it willnot be included in the + * plain text. If the qualifier is excluded, it will not be included in the * link label. * * @param cd the class to link to. @@ -1318,10 +1280,11 @@ public class HtmlDocletWriter extends HtmlDocWriter { return getPackageLinkString(refPackage, label, false); } else { //@see is not referencing an included class or package. Check for cross links. - String classCrossLink, packageCrossLink = getCrossPackageLink(refClassName); + String classCrossLink; + DocLink packageCrossLink = getCrossPackageLink(refClassName); if (packageCrossLink != null) { //Package cross link found - return getHyperLinkString(packageCrossLink, "", + return getHyperLinkString(packageCrossLink, (label.isEmpty() ? text : label), false); } else if ((classCrossLink = getCrossClassLink(refClassName, refMemName, label, false, "", !plain)) != null) { @@ -1450,7 +1413,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { * @param doc the doc for which the comment tags will be generated * @param tags the first sentence tags for the doc * @param depr true if it is deprecated - * @param first true if the first sentenge tags should be added + * @param first true if the first sentence tags should be added * @param htmltree the documentation tree to which the comment tags will be added */ private void addCommentTags(Doc doc, Tag[] tags, boolean depr, @@ -1561,7 +1524,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { /** * Suppose a piece of documentation has a relative link. When you copy - * that documetation to another place such as the index or class-use page, + * that documentation to another place such as the index or class-use page, * that relative link will no longer work. We should redirect those links * so that they will work again. *
@@ -1587,21 +1550,17 @@ public class HtmlDocletWriter extends HtmlDocWriter {
return text;
}
- String redirectPathFromRoot;
+ DocPath redirectPathFromRoot;
if (doc instanceof ClassDoc) {
- redirectPathFromRoot = DirectoryManager.getDirectoryPath(((ClassDoc) doc).containingPackage());
+ redirectPathFromRoot = DocPath.forPackage(((ClassDoc) doc).containingPackage());
} else if (doc instanceof MemberDoc) {
- redirectPathFromRoot = DirectoryManager.getDirectoryPath(((MemberDoc) doc).containingPackage());
+ redirectPathFromRoot = DocPath.forPackage(((MemberDoc) doc).containingPackage());
} else if (doc instanceof PackageDoc) {
- redirectPathFromRoot = DirectoryManager.getDirectoryPath((PackageDoc) doc);
+ redirectPathFromRoot = DocPath.forPackage((PackageDoc) doc);
} else {
return text;
}
- if (! redirectPathFromRoot.endsWith(DirectoryManager.URL_FILE_SEPARATOR)) {
- redirectPathFromRoot += DirectoryManager.URL_FILE_SEPARATOR;
- }
-
//Redirect all relative links.
int end, begin = text.toLowerCase().indexOf("= 0){
@@ -1627,22 +1586,21 @@ public class HtmlDocletWriter extends HtmlDocWriter {
//might be missing '>' character because the href has an inline tag.
break;
}
- if(textBuff.substring(begin, end).indexOf("\"") != -1){
+ if (textBuff.substring(begin, end).indexOf("\"") != -1){
begin = textBuff.indexOf("\"", begin) + 1;
end = textBuff.indexOf("\"", begin +1);
- if(begin == 0 || end == -1){
+ if (begin == 0 || end == -1){
//Link is missing a quote.
break;
}
}
String relativeLink = textBuff.substring(begin, end);
- if(!(relativeLink.toLowerCase().startsWith("mailto:") ||
- relativeLink.toLowerCase().startsWith("http:") ||
- relativeLink.toLowerCase().startsWith("https:") ||
- relativeLink.toLowerCase().startsWith("file:"))){
- relativeLink = "{@"+(new DocRootTaglet()).getName() + "}"
- + redirectPathFromRoot
- + relativeLink;
+ if (!(relativeLink.toLowerCase().startsWith("mailto:") ||
+ relativeLink.toLowerCase().startsWith("http:") ||
+ relativeLink.toLowerCase().startsWith("https:") ||
+ relativeLink.toLowerCase().startsWith("file:"))) {
+ relativeLink = "{@"+(new DocRootTaglet()).getName() + "}/"
+ + redirectPathFromRoot.resolve(relativeLink).getPath();
textBuff.replace(begin, end, relativeLink);
}
begin = textBuff.toString().toLowerCase().indexOf(" 0) {
- File stylefile = new File(filename);
- String parent = stylefile.getParent();
- filename = (parent == null)?
- filename:
- filename.substring(parent.length() + 1);
+ String stylesheetfile = configuration.stylesheetfile;
+ DocPath stylesheet;
+ if (stylesheetfile.isEmpty()) {
+ stylesheet = DocPaths.STYLESHEET;
} else {
- filename = "stylesheet.css";
+ DocFile file = DocFile.createFileForInput(configuration, stylesheetfile);
+ stylesheet = DocPath.create(file.getName());
}
- filename = relativePath + filename;
- HtmlTree link = HtmlTree.LINK("stylesheet", "text/css", filename, "Style");
+ HtmlTree link = HtmlTree.LINK("stylesheet", "text/css",
+ pathToRoot.resolve(stylesheet).getPath(),
+ "Style");
return link;
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java
index dac765d925c..f0d0707be0d 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java
@@ -78,11 +78,12 @@ public class LinkFactoryImpl extends LinkFactory {
LinkOutputImpl linkOutput = new LinkOutputImpl();
if (classDoc.isIncluded()) {
if (configuration.isGeneratedDoc(classDoc)) {
- String filename = pathString(classLinkInfo);
+ DocPath filename = getPath(classLinkInfo);
if (linkInfo.linkToSelf ||
- !(linkInfo.classDoc.name() + ".html").equals(m_writer.filename)) {
- linkOutput.append(m_writer.getHyperLinkString(filename,
- classLinkInfo.where, label.toString(),
+ !(DocPath.forName(classDoc)).equals(m_writer.filename)) {
+ linkOutput.append(m_writer.getHyperLinkString(
+ filename.fragment(classLinkInfo.where),
+ label.toString(),
classLinkInfo.isStrong, classLinkInfo.styleName,
title, classLinkInfo.target));
if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
@@ -161,16 +162,12 @@ public class LinkFactoryImpl extends LinkFactory {
*
* @param linkInfo the information about the link.
*/
- private String pathString(LinkInfoImpl linkInfo) {
+ private DocPath getPath(LinkInfoImpl linkInfo) {
if (linkInfo.context == LinkInfoImpl.PACKAGE_FRAME) {
//Not really necessary to do this but we want to be consistent
//with 1.4.2 output.
- return linkInfo.classDoc.name() + ".html";
+ return DocPath.forName(linkInfo.classDoc);
}
- StringBuilder buf = new StringBuilder(m_writer.relativePath);
- buf.append(DirectoryManager.getPathToPackage(
- linkInfo.classDoc.containingPackage(),
- linkInfo.classDoc.name() + ".html"));
- return buf.toString();
+ return m_writer.pathToRoot.resolve(DocPath.forClass(linkInfo.classDoc));
}
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
index 467859d740b..6b9ff239511 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
@@ -400,7 +400,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
*/
protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
if (link) {
- return writer.getHyperLink("", (cd == null)?
+ return writer.getHyperLink((cd == null)?
"method_summary":
"methods_inherited_from_class_" +
configuration().getClassName(cd),
@@ -415,7 +415,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
*/
protected void addNavDetailLink(boolean link, Content liNav) {
if (link) {
- liNav.addContent(writer.getHyperLink("", "method_detail",
+ liNav.addContent(writer.getHyperLink("method_detail",
writer.getResource("doclet.navMethod")));
} else {
liNav.addContent(writer.getResource("doclet.navMethod"));
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
index ec9a50f52fa..5b9cda91b33 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
@@ -203,9 +203,8 @@ public class NestedClassWriterImpl extends AbstractMemberWriter
*/
protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
if (link) {
- return writer.getHyperLink("", (cd == null) ? "nested_class_summary":
- "nested_classes_inherited_from_class_" +
- cd.qualifiedName(),
+ return writer.getHyperLink((cd == null) ? "nested_class_summary":
+ "nested_classes_inherited_from_class_" + cd.qualifiedName(),
writer.getResource("doclet.navNested"));
} else {
return writer.getResource("doclet.navNested");
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java
index 6c9f3770b00..e218a273d47 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java
@@ -59,18 +59,13 @@ public class PackageFrameWriter extends HtmlDocletWriter {
*/
private Set This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
@@ -73,7 +73,7 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter {
* @see Group
*/
public PackageIndexWriter(ConfigurationImpl configuration,
- String filename)
+ DocPath filename)
throws IOException {
super(configuration, filename);
this.root = configuration.root;
@@ -88,7 +88,7 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter {
*/
public static void generate(ConfigurationImpl configuration) {
PackageIndexWriter packgen;
- String filename = "overview-summary.html";
+ DocPath filename = DocPaths.OVERVIEW_SUMMARY;
try {
packgen = new PackageIndexWriter(configuration, filename);
packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", true);
@@ -178,7 +178,7 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter {
Content see = seeLabel;
see.addContent(" ");
Content descPara = HtmlTree.P(see);
- Content descLink = getHyperLink("", "overview_description",
+ Content descLink = getHyperLink(DocLink.fragment("overview_description"),
descriptionLabel, "", "");
descPara.addContent(descLink);
div.addContent(descPara);
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java
index 5895015f210..e95c370502c 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java
@@ -67,15 +67,14 @@ public class PackageTreeWriter extends AbstractTreeWriter {
* @throws DocletAbortException
*/
public PackageTreeWriter(ConfigurationImpl configuration,
- String path, String filename,
+ DocPath path,
PackageDoc packagedoc,
PackageDoc prev, PackageDoc next)
throws IOException {
- super(configuration, path, filename,
+ super(configuration, path,
new ClassTree(
configuration.classDocCatalog.allClasses(packagedoc),
- configuration),
- packagedoc);
+ configuration));
this.packagedoc = packagedoc;
this.prev = prev;
this.next = next;
@@ -96,17 +95,16 @@ public class PackageTreeWriter extends AbstractTreeWriter {
PackageDoc pkg, PackageDoc prev,
PackageDoc next, boolean noDeprecated) {
PackageTreeWriter packgen;
- String path = DirectoryManager.getDirectoryPath(pkg);
- String filename = "package-tree.html";
+ DocPath path = DocPath.forPackage(pkg).resolve(DocPaths.PACKAGE_TREE);
try {
- packgen = new PackageTreeWriter(configuration, path, filename, pkg,
+ packgen = new PackageTreeWriter(configuration, path, pkg,
prev, next);
packgen.generatePackageTreeFile();
packgen.close();
} catch (IOException exc) {
configuration.standardmessage.error(
"doclet.exception_encountered",
- exc.toString(), filename);
+ exc.toString(), path.getPath());
throw new DocletAbortException();
}
}
@@ -175,9 +173,8 @@ public class PackageTreeWriter extends AbstractTreeWriter {
if (prev == null) {
return getNavLinkPrevious(null);
} else {
- String path = DirectoryManager.getRelativePath(packagedoc.name(),
- prev.name());
- return getNavLinkPrevious(path + "package-tree.html");
+ DocPath path = DocPath.relativePath(packagedoc, prev);
+ return getNavLinkPrevious(path.resolve(DocPaths.PACKAGE_TREE));
}
}
@@ -190,9 +187,8 @@ public class PackageTreeWriter extends AbstractTreeWriter {
if (next == null) {
return getNavLinkNext(null);
} else {
- String path = DirectoryManager.getRelativePath(packagedoc.name(),
- next.name());
- return getNavLinkNext(path + "package-tree.html");
+ DocPath path = DocPath.relativePath(packagedoc, next);
+ return getNavLinkNext(path.resolve(DocPaths.PACKAGE_TREE));
}
}
@@ -202,7 +198,7 @@ public class PackageTreeWriter extends AbstractTreeWriter {
* @return a content tree for the package link
*/
protected Content getNavLinkPackage() {
- Content linkContent = getHyperLink("package-summary.html", "",
+ Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY,
packageLabel);
Content li = HtmlTree.LI(linkContent);
return li;
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java
index 1bf61a55ca8..4545484e451 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java
@@ -57,11 +57,9 @@ public class PackageUseWriter extends SubWriterHolderWriter {
* @throws DocletAbortException
*/
public PackageUseWriter(ConfigurationImpl configuration,
- ClassUseMapper mapper, String filename,
+ ClassUseMapper mapper, DocPath filename,
PackageDoc pkgdoc) throws IOException {
- super(configuration, DirectoryManager.getDirectoryPath(pkgdoc),
- filename,
- DirectoryManager.getRelativePath(pkgdoc.name()));
+ super(configuration, DocPath.forPackage(pkgdoc).resolve(filename));
this.pkgdoc = pkgdoc;
// by examining all classes in this package, find what packages
@@ -98,7 +96,7 @@ public class PackageUseWriter extends SubWriterHolderWriter {
public static void generate(ConfigurationImpl configuration,
ClassUseMapper mapper, PackageDoc pkgdoc) {
PackageUseWriter pkgusegen;
- String filename = "package-use.html";
+ DocPath filename = DocPaths.PACKAGE_USE;
try {
pkgusegen = new PackageUseWriter(configuration,
mapper, filename, pkgdoc);
@@ -232,10 +230,10 @@ public class PackageUseWriter extends SubWriterHolderWriter {
*/
protected void addClassRow(ClassDoc usedClass, String packageName,
Content contentTree) {
- String path = pathString(usedClass,
- "class-use/" + usedClass.name() + ".html");
+ DocPath dp = pathString(usedClass,
+ DocPaths.CLASS_USE.resolve(DocPath.forName(usedClass)));
Content td = HtmlTree.TD(HtmlStyle.colOne,
- getHyperLink(path, packageName, new StringContent(usedClass.name())));
+ getHyperLink(dp.fragment(packageName), new StringContent(usedClass.name())));
addIndexComment(usedClass, td);
contentTree.addContent(td);
}
@@ -248,7 +246,7 @@ public class PackageUseWriter extends SubWriterHolderWriter {
*/
protected void addPackageUse(PackageDoc pkg, Content contentTree) throws IOException {
Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst,
- getHyperLink("", Util.getPackageName(pkg),
+ getHyperLink(Util.getPackageName(pkg),
new RawHtml(Util.getPackageName(pkg))));
contentTree.addContent(tdFirst);
HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
@@ -288,7 +286,7 @@ public class PackageUseWriter extends SubWriterHolderWriter {
* @return a content tree for the package link
*/
protected Content getNavLinkPackage() {
- Content linkContent = getHyperLink("package-summary.html", "",
+ Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY,
packageLabel);
Content li = HtmlTree.LI(linkContent);
return li;
@@ -310,7 +308,7 @@ public class PackageUseWriter extends SubWriterHolderWriter {
* @return a content tree for the tree link
*/
protected Content getNavLinkTree() {
- Content linkContent = getHyperLink("package-tree.html", "",
+ Content linkContent = getHyperLink(DocPaths.PACKAGE_TREE,
treeLabel);
Content li = HtmlTree.LI(linkContent);
return li;
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java
index c91bf4d016c..64f367e62e3 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java
@@ -64,18 +64,13 @@ public class PackageWriterImpl extends HtmlDocletWriter
*/
protected PackageDoc packageDoc;
- /**
- * The name of the output file.
- */
- private static final String OUTPUT_FILE_NAME = "package-summary.html";
-
/**
* Constructor to construct PackageWriter object and to generate
* "package-summary.html" file in the respective package directory.
* For example for package "java.lang" this will generate file
* "package-summary.html" file in the "java/lang" directory. It will also
* create "java/lang" directory in the current or the destination directory
- * if it doesen't exist.
+ * if it doesn't exist.
*
* @param configuration the configuration of the doclet.
* @param packageDoc PackageDoc under consideration.
@@ -83,24 +78,14 @@ public class PackageWriterImpl extends HtmlDocletWriter
* @param next Next package in the sorted array.
*/
public PackageWriterImpl(ConfigurationImpl configuration,
- PackageDoc packageDoc, PackageDoc prev, PackageDoc next)
- throws IOException {
- super(configuration, DirectoryManager.getDirectoryPath(packageDoc), OUTPUT_FILE_NAME,
- DirectoryManager.getRelativePath(packageDoc.name()));
+ PackageDoc packageDoc, PackageDoc prev, PackageDoc next)
+ throws IOException {
+ super(configuration, DocPath.forPackage(packageDoc).resolve(DocPaths.PACKAGE_SUMMARY));
this.prev = prev;
this.next = next;
this.packageDoc = packageDoc;
}
- /**
- * Return the name of the output file.
- *
- * @return the name of the output file.
- */
- public String getOutputFileName() {
- return OUTPUT_FILE_NAME;
- }
-
/**
* {@inheritDoc}
*/
@@ -127,7 +112,7 @@ public class PackageWriterImpl extends HtmlDocletWriter
addSummaryComment(packageDoc, docSummaryDiv);
div.addContent(docSummaryDiv);
Content space = getSpace();
- Content descLink = getHyperLink("", "package_description",
+ Content descLink = getHyperLink(DocLink.fragment("package_description"),
descriptionLabel, "", "");
Content descPara = new HtmlTree(HtmlTag.P, seeLabel, space, descLink);
div.addContent(descPara);
@@ -265,7 +250,7 @@ public class PackageWriterImpl extends HtmlDocletWriter
* @return a content tree for the class use link
*/
protected Content getNavLinkClassUse() {
- Content useLink = getHyperLink("package-use.html", "",
+ Content useLink = getHyperLink(DocPaths.PACKAGE_USE,
useLabel, "", "");
Content li = HtmlTree.LI(useLink);
return li;
@@ -281,9 +266,8 @@ public class PackageWriterImpl extends HtmlDocletWriter
if (prev == null) {
li = HtmlTree.LI(prevpackageLabel);
} else {
- String path = DirectoryManager.getRelativePath(packageDoc.name(),
- prev.name());
- li = HtmlTree.LI(getHyperLink(path + "package-summary.html", "",
+ DocPath path = DocPath.relativePath(packageDoc, prev);
+ li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.PACKAGE_SUMMARY),
prevpackageLabel, "", ""));
}
return li;
@@ -299,9 +283,8 @@ public class PackageWriterImpl extends HtmlDocletWriter
if (next == null) {
li = HtmlTree.LI(nextpackageLabel);
} else {
- String path = DirectoryManager.getRelativePath(packageDoc.name(),
- next.name());
- li = HtmlTree.LI(getHyperLink(path + "package-summary.html", "",
+ DocPath path = DocPath.relativePath(packageDoc, next);
+ li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.PACKAGE_SUMMARY),
nextpackageLabel, "", ""));
}
return li;
@@ -314,7 +297,7 @@ public class PackageWriterImpl extends HtmlDocletWriter
* @return a content tree for the tree link
*/
protected Content getNavLinkTree() {
- Content useLink = getHyperLink("package-tree.html", "",
+ Content useLink = getHyperLink(DocPaths.PACKAGE_TREE,
treeLabel, "", "");
Content li = HtmlTree.LI(useLink);
return li;
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java
index f7cb4feff81..c1df94a8728 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java
@@ -29,6 +29,7 @@ import java.io.*;
import com.sun.javadoc.*;
import com.sun.tools.doclets.formats.html.markup.*;
import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.DocPaths;
import com.sun.tools.doclets.internal.toolkit.util.DocletAbortException;
/**
@@ -44,14 +45,12 @@ import com.sun.tools.doclets.internal.toolkit.util.DocletAbortException;
public class SerializedFormWriterImpl extends SubWriterHolderWriter
implements SerializedFormWriter {
- private static final String FILE_NAME = "serialized-form.html";
-
/**
* @throws IOException
* @throws DocletAbortException
*/
public SerializedFormWriterImpl() throws IOException {
- super(ConfigurationImpl.getInstance(), FILE_NAME);
+ super(ConfigurationImpl.getInstance(), DocPaths.SERIALIZED_FORM);
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SingleIndexWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SingleIndexWriter.java
index a0ce80f928b..924557c95df 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SingleIndexWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SingleIndexWriter.java
@@ -55,11 +55,9 @@ public class SingleIndexWriter extends AbstractIndexWriter {
* @param indexbuilder Unicode based Index from {@link IndexBuilder}
*/
public SingleIndexWriter(ConfigurationImpl configuration,
- String filename,
+ DocPath filename,
IndexBuilder indexbuilder) throws IOException {
super(configuration, filename, indexbuilder);
- relativepathNoSlash = ".";
- relativePath = "./";
}
/**
@@ -71,7 +69,7 @@ public class SingleIndexWriter extends AbstractIndexWriter {
public static void generate(ConfigurationImpl configuration,
IndexBuilder indexbuilder) {
SingleIndexWriter indexgen;
- String filename = "index-all.html";
+ DocPath filename = DocPaths.INDEX_ALL;
try {
indexgen = new SingleIndexWriter(configuration,
filename, indexbuilder);
@@ -117,7 +115,7 @@ public class SingleIndexWriter extends AbstractIndexWriter {
for (int i = 0; i < indexbuilder.elements().length; i++) {
String unicode = (indexbuilder.elements())[i].toString();
contentTree.addContent(
- getHyperLink("#_" + unicode + "_", new StringContent(unicode)));
+ getHyperLink("_" + unicode + "_", new StringContent(unicode)));
contentTree.addContent(getSpace());
}
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java
index c560bb8711c..299f4f53313 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java
@@ -26,11 +26,13 @@
package com.sun.tools.doclets.formats.html;
import java.io.*;
+
import javax.tools.FileObject;
+
import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.*;
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.formats.html.markup.*;
/**
* Converts Java Source Code to HTML.
@@ -62,7 +64,7 @@ public class SourceToHTMLConverter {
* Relative path from the documentation root to the file that is being
* generated.
*/
- private static String relativePath = "";
+ private static DocPath relativePath = DocPath.empty;
/**
* Source is converted to HTML using static methods below.
@@ -77,7 +79,7 @@ public class SourceToHTMLConverter {
* @param outputdir the name of the directory to output to.
*/
public static void convertRoot(ConfigurationImpl configuration, RootDoc rd,
- String outputdir) {
+ DocPath outputdir) {
if (rd == null || outputdir == null) {
return;
}
@@ -95,8 +97,7 @@ public class SourceToHTMLConverter {
// package files to HTML.
if (!(configuration.nodeprecated &&
(Util.isDeprecated(cds[i]) || Util.isDeprecated(cds[i].containingPackage()))))
- convertClass(configuration, cds[i],
- getPackageOutputDir(outputdir, cds[i].containingPackage()));
+ convertClass(configuration, cds[i], outputdir);
}
}
@@ -108,11 +109,10 @@ public class SourceToHTMLConverter {
* @param outputdir the name of the directory to output to.
*/
public static void convertPackage(ConfigurationImpl configuration, PackageDoc pd,
- String outputdir) {
- if (pd == null || outputdir == null) {
+ DocPath outputdir) {
+ if (pd == null) {
return;
}
- String classOutputdir = getPackageOutputDir(outputdir, pd);
ClassDoc[] cds = pd.allClasses();
for (int i = 0; i < cds.length; i++) {
// If -nodeprecated option is set and the class is marked as deprecated,
@@ -120,22 +120,10 @@ public class SourceToHTMLConverter {
// containing package deprecation since it is already check in
// the calling method above.
if (!(configuration.nodeprecated && Util.isDeprecated(cds[i])))
- convertClass(configuration, cds[i], classOutputdir);
+ convertClass(configuration, cds[i], outputdir);
}
}
- /**
- * Return the directory write output to for the given package.
- *
- * @param outputDir the directory to output to.
- * @param pd the Package to generate output for.
- * @return the package output directory as a String.
- */
- private static String getPackageOutputDir(String outputDir, PackageDoc pd) {
- return outputDir + File.separator +
- DirectoryManager.getDirectoryPath(pd) + File.separator;
- }
-
/**
* Convert the given Class to an HTML.
*
@@ -144,8 +132,8 @@ public class SourceToHTMLConverter {
* @param outputdir the name of the directory to output to.
*/
public static void convertClass(ConfigurationImpl configuration, ClassDoc cd,
- String outputdir) {
- if (cd == null || outputdir == null) {
+ DocPath outputdir) {
+ if (cd == null) {
return;
}
try {
@@ -168,8 +156,9 @@ public class SourceToHTMLConverter {
LineNumberReader reader = new LineNumberReader(r);
int lineno = 1;
String line;
- relativePath = DirectoryManager.getRelativePath(DocletConstants.SOURCE_OUTPUT_DIR_NAME) +
- DirectoryManager.getRelativePath(cd.containingPackage());
+ relativePath = DocPaths.SOURCE_OUTPUT
+ .resolve(DocPath.forPackage(cd))
+ .invert();
Content body = getHeader();
Content pre = new HtmlTree(HtmlTag.PRE);
try {
@@ -184,8 +173,8 @@ public class SourceToHTMLConverter {
addBlankLines(pre);
Content div = HtmlTree.DIV(HtmlStyle.sourceContainer, pre);
body.addContent(div);
- writeToFile(body, outputdir, cd.name(), configuration);
- } catch (Exception e){
+ writeToFile(body, outputdir.resolve(DocPath.forClass(cd)), configuration);
+ } catch (IOException e) {
e.printStackTrace();
}
}
@@ -194,12 +183,11 @@ public class SourceToHTMLConverter {
* Write the output to the file.
*
* @param body the documentation content to be written to the file.
- * @param outputDir the directory to output to.
- * @param className the name of the class that I am converting to HTML.
+ * @param path the path for the file.
* @param configuration the Doclet configuration to pass notices to.
*/
- private static void writeToFile(Content body, String outputDir,
- String className, ConfigurationImpl configuration) throws IOException {
+ private static void writeToFile(Content body, DocPath path,
+ ConfigurationImpl configuration) throws IOException {
Content htmlDocType = DocType.Transitional();
Content head = new HtmlTree(HtmlTag.HEAD);
head.addContent(HtmlTree.TITLE(new StringContent(
@@ -208,15 +196,15 @@ public class SourceToHTMLConverter {
Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
head, body);
Content htmlDocument = new HtmlDocument(htmlDocType, htmlTree);
- File dir = new File(outputDir);
- dir.mkdirs();
- File newFile = new File(dir, className + ".html");
- configuration.message.notice("doclet.Generating_0", newFile.getPath());
- FileOutputStream fout = new FileOutputStream(newFile);
- BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fout));
- bw.write(htmlDocument.toString());
- bw.close();
- fout.close();
+ configuration.message.notice("doclet.Generating_0", path.getPath());
+ DocFile df = DocFile.createFileForOutput(configuration, path);
+ Writer w = df.openWriter();
+ try {
+ htmlDocument.write(w, true);
+ } finally {
+ w.close();
+ }
+
}
/**
@@ -227,17 +215,15 @@ public class SourceToHTMLConverter {
*/
public static HtmlTree getStyleSheetProperties(ConfigurationImpl configuration) {
String filename = configuration.stylesheetfile;
+ DocPath stylesheet;
if (filename.length() > 0) {
- File stylefile = new File(filename);
- String parent = stylefile.getParent();
- filename = (parent == null)?
- filename:
- filename.substring(parent.length() + 1);
+ DocFile file = DocFile.createFileForInput(configuration, filename);
+ stylesheet = DocPath.create(file.getName());
} else {
- filename = "stylesheet.css";
+ stylesheet = DocPaths.STYLESHEET;
}
- filename = relativePath + filename;
- HtmlTree link = HtmlTree.LINK("stylesheet", "text/css", filename, "Style");
+ DocPath p = relativePath.resolve(stylesheet);
+ HtmlTree link = HtmlTree.LINK("stylesheet", "text/css", p.getPath(), "Style");
return link;
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SplitIndexWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SplitIndexWriter.java
index e6249f29ddb..69f273e7f69 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SplitIndexWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SplitIndexWriter.java
@@ -62,15 +62,13 @@ public class SplitIndexWriter extends AbstractIndexWriter {
* from this file.
*
* @param path Path to the file which is getting generated.
- * @param filename Name of the file which is getting genrated.
- * @param relpath Relative path from this file to the current directory.
* @param indexbuilder Unicode based Index from {@link IndexBuilder}
*/
public SplitIndexWriter(ConfigurationImpl configuration,
- String path, String filename,
- String relpath, IndexBuilder indexbuilder,
+ DocPath path,
+ IndexBuilder indexbuilder,
int prev, int next) throws IOException {
- super(configuration, path, filename, relpath, indexbuilder);
+ super(configuration, path, indexbuilder);
this.prev = prev;
this.next = next;
}
@@ -85,17 +83,16 @@ public class SplitIndexWriter extends AbstractIndexWriter {
public static void generate(ConfigurationImpl configuration,
IndexBuilder indexbuilder) {
SplitIndexWriter indexgen;
- String filename = "";
- String path = DirectoryManager.getPath("index-files");
- String relpath = DirectoryManager.getRelativePath("index-files");
+ DocPath filename = DocPath.empty;
+ DocPath path = DocPaths.INDEX_FILES;
try {
for (int i = 0; i < indexbuilder.elements().length; i++) {
int j = i + 1;
int prev = (j == 1)? -1: i;
int next = (j == indexbuilder.elements().length)? -1: j + 1;
- filename = "index-" + j +".html";
+ filename = DocPaths.indexN(j);
indexgen = new SplitIndexWriter(configuration,
- path, filename, relpath,
+ path.resolve(filename),
indexbuilder, prev, next);
indexgen.generateIndexFile((Character)indexbuilder.
elements()[i]);
@@ -104,7 +101,7 @@ public class SplitIndexWriter extends AbstractIndexWriter {
} catch (IOException exc) {
configuration.standardmessage.error(
"doclet.exception_encountered",
- exc.toString(), filename);
+ exc.toString(), filename.getPath());
throw new DocletAbortException();
}
}
@@ -142,7 +139,7 @@ public class SplitIndexWriter extends AbstractIndexWriter {
Object[] unicodeChars = indexbuilder.elements();
for (int i = 0; i < unicodeChars.length; i++) {
int j = i + 1;
- contentTree.addContent(getHyperLink("index-" + j + ".html",
+ contentTree.addContent(getHyperLink(DocPaths.indexN(j),
new StringContent(unicodeChars[i].toString())));
contentTree.addContent(getSpace());
}
@@ -159,7 +156,7 @@ public class SplitIndexWriter extends AbstractIndexWriter {
return HtmlTree.LI(prevletterLabel);
}
else {
- Content prevLink = getHyperLink("index-" + prev + ".html", "",
+ Content prevLink = getHyperLink(DocPaths.indexN(prev),
prevletterLabel);
return HtmlTree.LI(prevLink);
}
@@ -176,7 +173,7 @@ public class SplitIndexWriter extends AbstractIndexWriter {
return HtmlTree.LI(nextletterLabel);
}
else {
- Content nextLink = getHyperLink("index-" + next + ".html","",
+ Content nextLink = getHyperLink(DocPaths.indexN(next),
nextletterLabel);
return HtmlTree.LI(nextLink);
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
index 424c55dfd8f..8f00a359a83 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
@@ -54,18 +54,11 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
*/
public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
- public SubWriterHolderWriter(ConfigurationImpl configuration,
- String filename) throws IOException {
+ public SubWriterHolderWriter(ConfigurationImpl configuration, DocPath filename)
+ throws IOException {
super(configuration, filename);
}
-
- public SubWriterHolderWriter(ConfigurationImpl configuration,
- String path, String filename, String relpath)
- throws IOException {
- super(configuration, path, filename, relpath);
- }
-
/**
* Add the summary header.
*
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
index 92478e2f6ce..ce158d443d0 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
@@ -66,8 +66,10 @@ public class TagletWriterImpl extends TagletWriter {
public TagletOutput getDocRootOutput() {
if (htmlWriter.configuration.docrootparent.length() > 0)
return new TagletOutputImpl(htmlWriter.configuration.docrootparent);
+ else if (htmlWriter.pathToRoot.isEmpty())
+ return new TagletOutputImpl(".");
else
- return new TagletOutputImpl(htmlWriter.relativepathNoSlash);
+ return new TagletOutputImpl(htmlWriter.pathToRoot.getPath());
}
/**
@@ -170,19 +172,24 @@ public class TagletWriterImpl extends TagletWriter {
htmlWriter instanceof ClassWriterImpl) {
//Automatically add link to constant values page for constant fields.
result = addSeeHeader(result);
- result += htmlWriter.getHyperLinkString(htmlWriter.relativePath +
- ConfigurationImpl.CONSTANTS_FILE_NAME
- + "#" + ((ClassWriterImpl) htmlWriter).getClassDoc().qualifiedName()
- + "." + ((FieldDoc) holder).name(),
- htmlWriter.configuration.getText("doclet.Constants_Summary"));
+ DocPath constantsPath =
+ htmlWriter.pathToRoot.resolve(DocPaths.CONSTANT_VALUES);
+ String whichConstant =
+ ((ClassWriterImpl) htmlWriter).getClassDoc().qualifiedName() + "." + ((FieldDoc) holder).name();
+ DocLink link = constantsPath.fragment(whichConstant);
+ result += htmlWriter.getHyperLinkString(link,
+ htmlWriter.configuration.getText("doclet.Constants_Summary"),
+ false);
}
if (holder.isClass() && ((ClassDoc)holder).isSerializable()) {
//Automatically add link to serialized form page for serializable classes.
if ((SerializedFormBuilder.serialInclude(holder) &&
SerializedFormBuilder.serialInclude(((ClassDoc)holder).containingPackage()))) {
result = addSeeHeader(result);
- result += htmlWriter.getHyperLinkString(htmlWriter.relativePath + "serialized-form.html",
- ((ClassDoc)holder).qualifiedName(), htmlWriter.configuration.getText("doclet.Serialized_Form"), false);
+ DocPath serialPath = htmlWriter.pathToRoot.resolve(DocPaths.SERIALIZED_FORM);
+ DocLink link = serialPath.fragment(((ClassDoc)holder).qualifiedName());
+ result += htmlWriter.getHyperLinkString(link,
+ htmlWriter.configuration.getText("doclet.Serialized_Form"), false);
}
}
return result.equals("") ? null : new TagletOutputImpl(result + "");
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java
index 7dab45c6cb0..f51a834db81 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java
@@ -67,7 +67,7 @@ public class TreeWriter extends AbstractTreeWriter {
* @param classtree the tree being built.
*/
public TreeWriter(ConfigurationImpl configuration,
- String filename, ClassTree classtree)
+ DocPath filename, ClassTree classtree)
throws IOException {
super(configuration, filename, classtree);
packages = configuration.packages;
@@ -84,7 +84,7 @@ public class TreeWriter extends AbstractTreeWriter {
public static void generate(ConfigurationImpl configuration,
ClassTree classtree) {
TreeWriter treegen;
- String filename = "overview-tree.html";
+ DocPath filename = DocPaths.OVERVIEW_TREE;
try {
treegen = new TreeWriter(configuration, filename, classtree);
treegen.generateTreeFile();
@@ -144,9 +144,9 @@ public class TreeWriter extends AbstractTreeWriter {
(configuration.nodeprecated && Util.isDeprecated(packages[i]))) {
continue;
}
- String link = pathString(packages[i], "package-tree.html");
+ DocPath link = pathString(packages[i], DocPaths.PACKAGE_TREE);
Content li = HtmlTree.LI(getHyperLink(
- link, "", new StringContent(packages[i].name())));
+ link, new StringContent(packages[i].name())));
if (i < packages.length - 1) {
li.addContent(", ");
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java
index 4af650d601a..376bfdcfeb2 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java
@@ -31,6 +31,9 @@ import java.util.*;
import com.sun.javadoc.*;
import com.sun.tools.doclets.formats.html.ConfigurationImpl;
import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.DocLink;
+import com.sun.tools.doclets.internal.toolkit.util.DocPath;
+import com.sun.tools.doclets.internal.toolkit.util.DocPaths;
/**
@@ -56,25 +59,11 @@ public abstract class HtmlDocWriter extends HtmlWriter {
*
* @param filename String file name.
*/
- public HtmlDocWriter(Configuration configuration,
- String filename) throws IOException {
- super(configuration,
- null, configuration.destDirName + filename,
- configuration.docencoding);
- // use File to normalize file separators
+ public HtmlDocWriter(Configuration configuration, DocPath filename)
+ throws IOException {
+ super(configuration, filename);
configuration.message.notice("doclet.Generating_0",
- new File(configuration.destDirName, filename));
- }
-
- public HtmlDocWriter(Configuration configuration,
- String path, String filename) throws IOException {
- super(configuration,
- configuration.destDirName + path, filename,
- configuration.docencoding);
- // use File to normalize file separators
- configuration.message.notice("doclet.Generating_0",
- new File(configuration.destDirName,
- ((path.length() > 0)? path + File.separator: "") + filename));
+ filename.resolveAgainst(configuration.destDirName));
}
/**
@@ -86,77 +75,99 @@ public abstract class HtmlDocWriter extends HtmlWriter {
* Return Html Hyper Link string.
*
* @param link String name of the file.
- * @param where Position of the link in the file. Character '#' is not
- * needed.
* @param label Tag for the link.
* @param strong Boolean that sets label to strong.
* @return String Hyper Link.
*/
- public String getHyperLinkString(String link, String where,
+ public String getHyperLinkString(DocPath link,
String label, boolean strong) {
- return getHyperLinkString(link, where, label, strong, "", "", "");
+ return getHyperLinkString(link, label, strong, "", "", "");
+ }
+
+ public String getHyperLinkString(DocLink link,
+ String label, boolean strong) {
+ return getHyperLinkString(link, label, strong, "", "", "");
}
/**
* Get Html Hyper Link string.
*
* @param link String name of the file.
- * @param where Position of the link in the file. Character '#' is not
- * needed.
* @param label Tag for the link.
* @param strong Boolean that sets label to strong.
* @param stylename String style of text defined in style sheet.
* @return String Hyper Link.
*/
- public String getHyperLinkString(String link, String where,
+ public String getHyperLinkString(DocPath link,
String label, boolean strong,
String stylename) {
- return getHyperLinkString(link, where, label, strong, stylename, "", "");
+ return getHyperLinkString(link, label, strong, stylename, "", "");
+ }
+
+ public String getHyperLinkString(DocLink link,
+ String label, boolean strong,
+ String stylename) {
+ return getHyperLinkString(link, label, strong, stylename, "", "");
}
/**
* Get Html Hyper Link string.
*
- * @param link String name of the file.
* @param where Position of the link in the file. Character '#' is not
* needed.
* @param label Tag for the link.
* @return a content tree for the hyper link
*/
- public Content getHyperLink(String link, String where,
+ public Content getHyperLink(String where,
Content label) {
- return getHyperLink(link, where, label, "", "");
+ return getHyperLink(DocLink.fragment(where), label, "", "");
+ }
+
+ /**
+ * Get Html Hyper Link string.
+ *
+ * @param link String name of the file.
+ * @param label Tag for the link.
+ * @return a content tree for the hyper link
+ */
+ public Content getHyperLink(DocPath link,
+ Content label) {
+ return getHyperLink(link, label, "", "");
+ }
+
+ public Content getHyperLink(DocLink link,
+ Content label) {
+ return getHyperLink(link, label, "", "");
}
/**
* Get Html Hyper Link string.
*
* @param link String name of the file.
- * @param where Position of the link in the file. Character '#' is not
- * needed.
* @param label Tag for the link.
* @param strong Boolean that sets label to strong.
* @param stylename String style of text defined in style sheet.
- * @param title String that describes the link's content for accessibility.
+ * @param title String that describes the links content for accessibility.
* @param target Target frame.
* @return String Hyper Link.
*/
- public String getHyperLinkString(String link, String where,
+ public String getHyperLinkString(DocPath link,
+ String label, boolean strong,
+ String stylename, String title, String target) {
+ return getHyperLinkString(new DocLink(link), label, strong,
+ stylename, title, target);
+ }
+
+ public String getHyperLinkString(DocLink link,
String label, boolean strong,
String stylename, String title, String target) {
StringBuilder retlink = new StringBuilder();
- retlink.append("");
if (stylename != null && stylename.length() != 0) {
@@ -182,19 +193,19 @@ public abstract class HtmlDocWriter extends HtmlWriter {
* Get Html Hyper Link.
*
* @param link String name of the file.
- * @param where Position of the link in the file. Character '#' is not
- * needed.
* @param label Tag for the link.
* @param title String that describes the link's content for accessibility.
* @param target Target frame.
* @return a content tree for the hyper link.
*/
- public Content getHyperLink(String link, String where,
+ public Content getHyperLink(DocPath link,
Content label, String title, String target) {
- if (where != null && where.length() != 0) {
- link += "#" + where;
- }
- HtmlTree anchor = HtmlTree.A(link, label);
+ return getHyperLink(new DocLink(link), label, title, target);
+ }
+
+ public Content getHyperLink(DocLink link,
+ Content label, String title, String target) {
+ HtmlTree anchor = HtmlTree.A(link.toString(), label);
if (title != null && title.length() != 0) {
anchor.addAttr(HtmlAttr.TITLE, title);
}
@@ -204,17 +215,6 @@ public abstract class HtmlDocWriter extends HtmlWriter {
return anchor;
}
- /**
- * Get a hyperlink to a file.
- *
- * @param link String name of the file
- * @param label Label for the link
- * @return a content for the hyperlink to the file
- */
- public Content getHyperLink(String link, Content label) {
- return getHyperLink(link, "", label);
- }
-
/**
* Get link string without positioning in the file.
*
@@ -222,8 +222,8 @@ public abstract class HtmlDocWriter extends HtmlWriter {
* @param label Tag for the link.
* @return Strign Hyper link.
*/
- public String getHyperLinkString(String link, String label) {
- return getHyperLinkString(link, "", label, false);
+ public String getHyperLinkString(DocPath link, String label) {
+ return getHyperLinkString(link, label, false);
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
index 64ea8760612..bd6be7a5c36 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
@@ -46,22 +46,11 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
*/
public class HtmlWriter {
- /**
- * Name of the file, to which this writer is writing to.
- */
- protected final String htmlFilename;
-
/**
* The window title of this file
*/
protected String winTitle;
- /**
- * URL file separator string("/").
- */
- public static final String fileseparator =
- DirectoryManager.URL_FILE_SEPARATOR;
-
/**
* The configuration
*/
@@ -160,20 +149,15 @@ public class HtmlWriter {
*
* @param path The directory path to be created for this file
* or null if none to be created.
- * @param filename File Name to which the PrintWriter will
- * do the Output.
- * @param docencoding Encoding to be used for this file.
* @exception IOException Exception raised by the FileWriter is passed on
* to next level.
* @exception UnsupportedEncodingException Exception raised by the
* OutputStreamWriter is passed on to next level.
*/
- public HtmlWriter(Configuration configuration,
- String path, String filename, String docencoding)
- throws IOException, UnsupportedEncodingException {
- writer = Util.genWriter(configuration, path, filename, docencoding);
+ public HtmlWriter(Configuration configuration, DocPath path)
+ throws IOException, UnsupportedEncodingException {
+ writer = DocFile.createFileForOutput(configuration, path).openWriter();
this.configuration = configuration;
- htmlFilename = filename;
this.memberDetailsListPrinted = false;
packageTableHeader = new String[] {
configuration.getText("doclet.Package"),
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java
index 7f38f38564c..4ae4cce1722 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java
@@ -106,7 +106,7 @@ public abstract class AbstractDoclet {
/**
* Start the generation of files. Call generate methods in the individual
- * writers, which will in turn genrate the documentation files. Call the
+ * writers, which will in turn generate the documentation files. Call the
* TreeWriter generation first to ensure the Class Hierarchy is built
* first and then can be used in the later generation.
*
@@ -124,17 +124,7 @@ public abstract class AbstractDoclet {
ClassTree classtree = new ClassTree(configuration, configuration.nodeprecated);
generateClassFiles(root, classtree);
- if (configuration.sourcepath != null && configuration.sourcepath.length() > 0) {
- StringTokenizer pathTokens = new StringTokenizer(configuration.sourcepath,
- String.valueOf(File.pathSeparatorChar));
- boolean first = true;
- while(pathTokens.hasMoreTokens()){
- Util.copyDocFiles(configuration,
- pathTokens.nextToken() + File.separator,
- DocletConstants.DOC_FILES_DIR_NAME, first);
- first = false;
- }
- }
+ Util.copyDocFiles(configuration, DocPaths.DOC_FILES);
PackageListWriter.generate(configuration);
generatePackageFiles(classtree);
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java
index d3cf97c5c4e..d94b7bef826 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java
@@ -408,11 +408,11 @@ public abstract class Configuration {
group.checkPackageGroups(os[1], os[2]);
} else if (opt.equals("-link")) {
String url = os[1];
- extern.url(url, url, root, false);
+ extern.link(url, url, root, false);
} else if (opt.equals("-linkoffline")) {
String url = os[1];
String pkglisturl = os[2];
- extern.url(url, pkglisturl, root, true);
+ extern.link(url, pkglisturl, root, true);
}
}
if (sourcepath.length() == 0) {
@@ -456,7 +456,7 @@ public abstract class Configuration {
tagletManager.addCustomTag(args[1], tagletpath);
continue;
}
- String[] tokens = Util.tokenize(args[1],
+ String[] tokens = tokenize(args[1],
TagletManager.SIMPLE_TAGLET_OPT_SEPERATOR, 3);
if (tokens.length == 1) {
String tagName = args[1];
@@ -480,6 +480,47 @@ public abstract class Configuration {
}
}
+ /**
+ * Given a string, return an array of tokens. The separator can be escaped
+ * with the '\' character. The '\' character may also be escaped by the
+ * '\' character.
+ *
+ * @param s the string to tokenize.
+ * @param separator the separator char.
+ * @param maxTokens the maximum number of tokens returned. If the
+ * max is reached, the remaining part of s is appended
+ * to the end of the last token.
+ *
+ * @return an array of tokens.
+ */
+ private String[] tokenize(String s, char separator, int maxTokens) {
+ List
- * Also see getPath for the URL separator version of this method
- * that takes a string instead of a PackageDoc.
- *
- * @param pd the PackageDoc
- * @return the platform-dependent directory path for the package
- */
- public static String getDirectoryPath(PackageDoc pd) {
- return pd == null || pd.name().length() == 0 ? "" : getDirectoryPath(pd.name());
- }
-
- /**
- * Given a package name, return the corresponding directory name
- * with the platform-dependent file separator between subdirectory names.
- * For example, if name of the package is "java.lang" , then it
- * returns "java/lang" on Unix and "java\lang" on Windows.
- * If name of the package contains no dot, then the value
- * will be returned unchanged. Because package names cannot
- * end in a dot, the return value will never end with a slash.
- *
- * Also see getPath for the URL separator version of this method
- * that takes a string instead of a PackageDoc.
- *
- * @param packageName the name of the package
- * @return the platform-dependent directory path for the package
- */
- public static String getDirectoryPath(String packageName) {
- if (packageName == null || packageName.length() == 0) {
- return "";
- }
- StringBuilder pathstr = new StringBuilder();
- for (int i = 0; i < packageName.length(); i++) {
- char ch = packageName.charAt(i);
- if (ch == '.') {
- pathstr.append(URL_FILE_SEPARATOR);
- } else {
- pathstr.append(ch);
- }
- }
- if (pathstr.length() > 0 && ! pathstr.toString().endsWith(URL_FILE_SEPARATOR)) {
- pathstr.append(URL_FILE_SEPARATOR);
- }
- return pathstr.toString();
- }
-
- /**
- * Given a package name (a string), return the path string,
- * with the URL separator "/" separating the subdirectory names.
- * If name of the package contains no dot, then the value
- * will be returned unchanged. Because package names cannot
- * end in a dot, the return value will never end with a slash.
- *
- * For example if the string is "com.sun.javadoc" then the URL
- * path string will be "com/sun/javadoc".
- *
- * @param name the package name as a String
- * @return the String URL path
- */
- public static String getPath(String name) {
- if (name == null || name.length() == 0) {
- return "";
- }
- StringBuilder pathstr = new StringBuilder();
- for (int i = 0; i < name.length(); i++) {
- char ch = name.charAt(i);
- if (ch == '.') {
- pathstr.append(URL_FILE_SEPARATOR);
- } else {
- pathstr.append(ch);
- }
- }
- return pathstr.toString();
- }
-
- /**
- * Given two package names as strings, return the relative path
- * from the package directory corresponding to the first string
- * to the package directory corresponding to the second string,
- * with the URL file separator "/" separating subdirectory names.
- *
- * For example, if the parameter "from" is "java.lang"
- * and parameter "to" is "java.applet", return string
- * "../../java/applet".
- *
- * @param from the package name from which path is calculated
- * @param to the package name to which path is calculated
- * @return relative path between "from" and "to" with URL
- * separators
- * @see #getRelativePath(String)
- * @see #getPath(String)
- */
- public static String getRelativePath(String from, String to) {
- StringBuilder pathstr = new StringBuilder();
- pathstr.append(getRelativePath(from));
- pathstr.append(getPath(to));
- pathstr.append(URL_FILE_SEPARATOR);
- return pathstr.toString();
- }
-
- /**
- * Given a package name as a string, return relative path string
- * from the corresponding package directory to the root of
- * the documentation, using the URL separator "/" between
- * subdirectory names.
- *
- * For example, if the string "from" is "java.lang",
- * return "../../"
- *
- * @param from the package
- * @return String relative path from "from".
- * @see #getRelativePath(String, String)
- */
- public static String getRelativePath(PackageDoc from) {
- return from == null || from.name().length() == 0 ? "" : getRelativePath(from.name());
- }
-
- /**
- * Given a package name as a string, return relative path string
- * from the corresponding package directory to the root of
- * the documentation, using the URL separator "/" between
- * subdirectory names.
- *
- * For example, if the string "from" is "java.lang",
- * return "../../"
- *
- * @param from the package name
- * @return String relative path from "from".
- * @see #getRelativePath(String, String)
- */
- public static String getRelativePath(String from) {
- if (from == null || from.length() == 0) {
- return "";
- }
- StringBuilder pathstr = new StringBuilder();
- for (int i = 0; i < from.length(); i++) {
- char ch = from.charAt(i);
- if (ch == '.') {
- pathstr.append(".." + URL_FILE_SEPARATOR);
- }
- }
- pathstr.append(".." + URL_FILE_SEPARATOR);
- return pathstr.toString();
- }
-
- /**
- * Given a relative or absolute path that might be empty,
- * convert it to a path that does not end with a
- * URL separator "/". Used for converting
- * HtmlStandardWriter.relativepath when replacing {@docRoot}.
- *
- * @param path the path to convert. An empty path represents
- * the current directory.
- */
- public static String getPathNoTrailingSlash(String path) {
- if ( path.equals("") ) {
- return ".";
- }
- if ( path.equals("/") ) {
- return "/.";
- }
- if ( path.endsWith("/") ) {
- // Remove trailing slash
- path = path.substring(0, path.length() -1);
- }
- return path;
- }
-
- /**
- * Given a path string create all the directories in the path. For example,
- * if the path string is "java/applet", the method will create directory
- * "java" and then "java/applet" if they don't exist. The file separator
- * string "/" is platform dependent system property.
- *
- * @param path Directory path string.
- */
- public static void createDirectory(Configuration configuration,
- String path) {
- if (path == null || path.length() == 0) {
- return;
- }
- File dir = new File(path);
- if (dir.exists()) {
- return;
- } else {
- if (dir.mkdirs()) {
- return;
- } else {
- configuration.message.error(
- "doclet.Unable_to_create_directory_0", path);
- throw new DocletAbortException();
- }
- }
- }
-
- /**
- * Given a package name and a file name, return the full path to that file.
- * For example, if PackageDoc passed is for "java.lang" and the filename
- * passed is "package-summary.html", then the string returned is
- * "java/lang/package-summary.html".
- *
- * @param pd PackageDoc.
- * @param filename File name to be appended to the path of the package.
- */
- public static String getPathToPackage(PackageDoc pd, String filename) {
- StringBuilder buf = new StringBuilder();
- String pathstr = createPathString(pd);
- if (pathstr.length() > 0) {
- buf.append(pathstr);
- buf.append(URL_FILE_SEPARATOR);
- }
- buf.append(filename);
- return buf.toString();
- }
-
- /**
- * Given a class name return the full path to the class file.
- * For example, if ClassDoc passed is for "java.lang.Object" then the
- * string returned is "java/lang/Object.html".
- *
- * @param cd ClassDoc.
- */
- public static String getPathToClass(ClassDoc cd) {
- return getPathToPackage(cd.containingPackage(), cd.name() + ".html");
- }
-
-}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFile.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFile.java
new file mode 100644
index 00000000000..33781c73174
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFile.java
@@ -0,0 +1,399 @@
+/*
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.doclets.internal.toolkit.util;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.tools.JavaFileManager.Location;
+import javax.tools.StandardLocation;
+
+import com.sun.tools.doclets.internal.toolkit.Configuration;
+
+/**
+ * Abstraction for handling files, which may be specified directly
+ * (e.g. via a path on the command line) or relative to a Location.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @since 8
+ */
+public class DocFile {
+
+ /**
+ * The doclet configuration.
+ * Provides access to options such as docencoding, output directory, etc.
+ */
+ private final Configuration configuration;
+
+ /**
+ * The location for this file. Maybe null if the file was created without
+ * a location or path.
+ */
+ private final Location location;
+
+ /**
+ * The path relative to the (output) location. Maybe null if the file was
+ * created without a location or path.
+ */
+ private final DocPath path;
+
+ /**
+ * The file object itself.
+ * This is temporary, until we create different subtypes of DocFile.
+ */
+ private final File file;
+
+ /** Create a DocFile for a directory. */
+ public static DocFile createFileForDirectory(Configuration configuration, String file) {
+ return new DocFile(configuration, new File(file));
+ }
+
+ /** Create a DocFile for a file that will be opened for reading. */
+ public static DocFile createFileForInput(Configuration configuration, String file) {
+ return new DocFile(configuration, new File(file));
+ }
+
+ /** Create a DocFile for a file that will be opened for writing. */
+ public static DocFile createFileForOutput(Configuration configuration, DocPath path) {
+ return new DocFile(configuration, StandardLocation.CLASS_OUTPUT, path);
+ }
+
+ /**
+ * List the directories and files found in subdirectories along the
+ * elements of the given location.
+ * @param configuration the doclet configuration
+ * @param location currently, only {@link StandardLocation#SOURCE_PATH} is supported.
+ * @param path the subdirectory of the directories of the location for which to
+ * list files
+ */
+ public static Iterable This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ */
+public class DocLink {
+ final String path;
+ final String query;
+ final String fragment;
+
+ /** Create a DocLink representing the URI {@code #fragment}. */
+ public static DocLink fragment(String fragment) {
+ return new DocLink((String) null, (String) null, fragment);
+ }
+
+ /** Create a DocLink representing the URI {@code path}. */
+ public DocLink(DocPath path) {
+ this(path.getPath(), null, null);
+ }
+
+ /**
+ * Create a DocLink representing the URI {@code path?query#fragment}.
+ * query and fragment may be null.
+ */
+ public DocLink(DocPath path, String query, String fragment) {
+ this(path.getPath(), query, fragment);
+ }
+
+ /**
+ * Create a DocLink representing the URI {@code path?query#fragment}.
+ * Any of the component parts may be null.
+ */
+ public DocLink(String path, String query, String fragment) {
+ this.path = path;
+ this.query = query;
+ this.fragment = fragment;
+ }
+
+ /**
+ * Return the link in the form "path?query#fragment", omitting any empty
+ * components.
+ */
+ @Override
+ public String toString() {
+ // common fast path
+ if (path != null && isEmpty(query) && isEmpty(fragment))
+ return path;
+
+ StringBuilder sb = new StringBuilder();
+ if (path != null)
+ sb.append(path);
+ if (!isEmpty(query))
+ sb.append("?").append(query);
+ if (!isEmpty(fragment))
+ sb.append("#").append(fragment);
+ return sb.toString();
+ }
+
+ private static boolean isEmpty(String s) {
+ return (s == null) || s.isEmpty();
+ }
+}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPath.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPath.java
new file mode 100644
index 00000000000..fb7d1fa96d7
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPath.java
@@ -0,0 +1,201 @@
+/*
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.doclets.internal.toolkit.util;
+
+import com.sun.javadoc.ClassDoc;
+import com.sun.javadoc.PackageDoc;
+import java.io.File;
+
+/**
+ * Abstraction for immutable relative paths.
+ * Paths always use '/' as a separator, and never begin or end with '/'.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ */
+public class DocPath {
+ private final String path;
+
+ /** The empty path. */
+ public static final DocPath empty = new DocPath("");
+
+ /** The empty path. */
+ public static final DocPath parent = new DocPath("..");
+
+ /**
+ * Create a path from a string.
+ */
+ public static DocPath create(String p) {
+ return (p == null) || p.isEmpty() ? empty : new DocPath(p);
+ }
+
+ /**
+ * Return the path for a class.
+ * For example, if the class is java.lang.Object,
+ * the path is java/lang/Object.html.
+ */
+ public static DocPath forClass(ClassDoc cd) {
+ return (cd == null) ? empty :
+ forPackage(cd.containingPackage()).resolve(forName(cd));
+ }
+
+ /**
+ * Return the path for the simple name of the class.
+ * For example, if the class is java.lang.Object,
+ * the path is Object.html.
+ */
+ public static DocPath forName(ClassDoc cd) {
+ return (cd == null) ? empty : new DocPath(cd.name() + ".html");
+ }
+
+ /**
+ * Return the path for the package of a class.
+ * For example, if the class is java.lang.Object,
+ * the path is java/lang.
+ */
+ public static DocPath forPackage(ClassDoc cd) {
+ return (cd == null) ? empty : forPackage(cd.containingPackage());
+ }
+
+ /**
+ * Return the path for a package.
+ * For example, if the package is java.lang,
+ * the path is java/lang.
+ */
+ public static DocPath forPackage(PackageDoc pd) {
+ return (pd == null) ? empty : DocPath.create(pd.name().replace('.', '/'));
+ }
+
+ /**
+ * Return the inverse path for a package.
+ * For example, if the package is java.lang,
+ * the inverse path is ../...
+ */
+ public static DocPath forRoot(PackageDoc pd) {
+ String name = (pd == null) ? "" : pd.name();
+ if (name.isEmpty())
+ return empty;
+ return new DocPath(name.replace('.', '/').replaceAll("[^/]+", ".."));
+ }
+
+ /**
+ * Return the relative path from one package to another.
+ */
+ public static DocPath relativePath(PackageDoc from, PackageDoc to) {
+ return forRoot(from).resolve(forPackage(to));
+ }
+
+ protected DocPath(String p) {
+ path = (p.endsWith("/") ? p.substring(0, p.length() - 1) : p);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean equals(Object other) {
+ return (other instanceof DocPath) && path.equals(((DocPath)other).path);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public int hashCode() {
+ return path.hashCode();
+ }
+
+ public DocPath basename() {
+ int sep = path.lastIndexOf("/");
+ return (sep == -1) ? this : new DocPath(path.substring(sep + 1));
+ }
+
+ public DocPath parent() {
+ int sep = path.lastIndexOf("/");
+ return (sep == -1) ? empty : new DocPath(path.substring(0, sep));
+ }
+
+ /**
+ * Return the path formed by appending the specified string to the current path.
+ */
+ public DocPath resolve(String p) {
+ if (p == null || p.isEmpty())
+ return this;
+ if (path.isEmpty())
+ return new DocPath(p);
+ return new DocPath(path + "/" + p);
+ }
+
+ /**
+ * Return the path by appending the specified path to the current path.
+ */
+ public DocPath resolve(DocPath p) {
+ if (p == null || p.isEmpty())
+ return this;
+ if (path.isEmpty())
+ return p;
+ return new DocPath(path + "/" + p.getPath());
+ }
+
+ /**
+ * Get the file created by evaluating the path against a specified directory.
+ */
+ // Temporary: this signature should not use String for dir.
+ // Eventually, this should involve javax.tools.Location.
+ public File resolveAgainst(String dir) {
+ return dir.isEmpty() ? new File(path) : new File(dir, path);
+ }
+
+ /**
+ * Return the inverse path for this path.
+ * For example, if the path is a/b/c, the inverse path is ../../..
+ */
+ public DocPath invert() {
+ return new DocPath(path.replaceAll("[^/]+", ".."));
+ }
+
+ /**
+ * Return true if this path is empty.
+ */
+ public boolean isEmpty() {
+ return path.isEmpty();
+ }
+
+ public DocLink fragment(String fragment) {
+ return new DocLink(path, null, fragment);
+ }
+
+ public DocLink query(String query) {
+ return new DocLink(path, query, null);
+ }
+
+ /**
+ * Return this path as a string.
+ */
+ // This is provided instead of using toString() to help catch
+ // unintended use of toString() in string concatenation sequences.
+ public String getPath() {
+ return path;
+ }
+}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPaths.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPaths.java
new file mode 100644
index 00000000000..9625be7b346
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPaths.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.doclets.internal.toolkit.util;
+
+/**
+ * Standard DocPath objects.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @since 8
+ */
+public class DocPaths {
+
+ /** The name of the file for all classes, using frames. */
+ public static final DocPath ALLCLASSES_FRAME = DocPath.create("allclasses-frame.html");
+
+ /** The name of the file for all classes, without using frames. */
+ public static final DocPath ALLCLASSES_NOFRAME = DocPath.create("allclasses-noframe.html");
+
+ /** The name of the sub-directory for storing class usage info. */
+ public static final DocPath CLASS_USE = DocPath.create("class-use");
+
+ /** The name of the file for constant values. */
+ public static final DocPath CONSTANT_VALUES = DocPath.create("constant-values.html");
+
+ /** The name of the fie for deprecated elements. */
+ public static final DocPath DEPRECATED_LIST = DocPath.create("deprecated-list.html");
+
+ /** The name of the subdirectory for user-provided additional documentation files. */
+ public static final DocPath DOC_FILES = DocPath.create("doc-files");
+
+ /** The name of the file for help info. */
+ public static final DocPath HELP_DOC = DocPath.create("help-doc.html");
+
+ /** The name of the main index file. */
+ public static final DocPath INDEX = DocPath.create("index.html");
+
+ /** The name of the single index file for all classes. */
+ public static final DocPath INDEX_ALL = DocPath.create("index-all.html");
+
+ /** The name of the directory for the split index files. */
+ public static final DocPath INDEX_FILES = DocPath.create("index-files");
+
+ /** Generate the name of one of the files in the split index. */
+ public static final DocPath indexN(int n) {
+ return DocPath.create("index-" + n + ".html");
+ }
+
+ /** The name of the file for the overview frame. */
+ public static final DocPath OVERVIEW_FRAME = DocPath.create("overview-frame.html");
+
+ /** The name of the file for the overview summary. */
+ public static final DocPath OVERVIEW_SUMMARY = DocPath.create("overview-summary.html");
+
+ /** The name of the file for the overview tree. */
+ public static final DocPath OVERVIEW_TREE = DocPath.create("overview-tree.html");
+
+ /** The name of the file for the package frame. */
+ public static final DocPath PACKAGE_FRAME = DocPath.create("package-frame.html");
+
+ /** The name of the file for the package list. */
+ public static final DocPath PACKAGE_LIST = DocPath.create("package-list");
+
+ /** The name of the file for the package summary. */
+ public static final DocPath PACKAGE_SUMMARY = DocPath.create("package-summary.html");
+
+ /** The name of the file for the package tree. */
+ public static final DocPath PACKAGE_TREE = DocPath.create("package-tree.html");
+
+ /** The name of the file for the package usage info. */
+ public static final DocPath PACKAGE_USE = DocPath.create("package-use.html");
+
+ /** The name of the directory in which resources are generated.
+ * Also the name of the sub-package from which resources are read.
+ */
+ public static final DocPath RESOURCES = DocPath.create("resources");
+
+ /** The name of the file for the serialized form info. */
+ public static final DocPath SERIALIZED_FORM = DocPath.create("serialized-form.html");
+
+ /** The name of the directory in which HTML versions of the source code
+ * are generated.
+ */
+ public static final DocPath SOURCE_OUTPUT = DocPath.create("src-html");
+
+ /** The name of the default stylesheet. */
+ public static final DocPath STYLESHEET = DocPath.create("stylesheet.css");
+
+}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletConstants.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletConstants.java
index 8f0fd4c446e..878a06bcb3c 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletConstants.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletConstants.java
@@ -39,6 +39,16 @@ package com.sun.tools.doclets.internal.toolkit.util;
*/
public class DocletConstants {
+ /**
+ * The default amount of space between tab stops.
+ */
+ public static final int DEFAULT_TAB_STOP_LENGTH = 8;
+
+ /**
+ * The line separator for the current operating system.
+ */
+ public static final String NL = System.getProperty("line.separator");
+
/**
* The default package name.
*/
@@ -53,34 +63,4 @@ public class DocletConstants {
* The anchor for the default package.
*/
public static final String UNNAMED_PACKAGE_ANCHOR = "unnamed_package";
-
- /**
- * The name of the doc files directory.
- */
- public static final String DOC_FILES_DIR_NAME = "doc-files";
-
- /**
- * The default amount of space between tab stops.
- */
- public static final int DEFAULT_TAB_STOP_LENGTH = 8;
-
- /**
- * The name of the directory where we will copy resource files to.
- */
- public static final String RESOURE_DIR_NAME = "resources";
-
- /**
- * The source output directory name
- */
- public static final String SOURCE_OUTPUT_DIR_NAME = "src-html/";
-
- /**
- * The name of the package list file.
- */
- public static final String PACKAGE_LIST_FILE_NAME = "package-list";
-
- /**
- * The line seperator for the current operating system.
- */
- public static final String NL = System.getProperty("line.separator");
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java
index 5c1cf1bec24..5aa768876d7 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java
@@ -30,6 +30,8 @@ import java.net.*;
import java.util.HashMap;
import java.util.Map;
+import javax.tools.StandardLocation;
+
import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.*;
@@ -138,21 +140,25 @@ public class Extern {
*
* @param pkgName The package name.
* @param relativepath The relative path.
- * @param link The link to convert.
+ * @param filename The link to convert.
* @return if external return converted link else return null
*/
- public String getExternalLink(String pkgName,
- String relativepath, String link) {
+ public DocLink getExternalLink(String pkgName,
+ DocPath relativepath, String filename) {
+ return getExternalLink(pkgName, relativepath, filename, null);
+ }
+
+ public DocLink getExternalLink(String pkgName,
+ DocPath relativepath, String filename, String memberName) {
Item fnd = findPackageItem(pkgName);
- if (fnd != null) {
- String externlink = fnd.path + link;
- if (fnd.relative) { // it's a relative path.
- return relativepath + externlink;
- } else {
- return externlink;
- }
- }
- return null;
+ if (fnd == null)
+ return null;
+
+ DocPath p = fnd.relative ?
+ relativepath.resolve(fnd.path).resolve(filename) :
+ DocPath.create(fnd.path).resolve(filename);
+
+ return new DocLink(p, "is-external=true", memberName);
}
/**
@@ -163,17 +169,38 @@ public class Extern {
* @param pkglisturl This can be another URL for "package-list" or ordinary
* file.
* @param reporter The This is NOT part of any supported API.
diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java b/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java
index d1601572998..8c9d9000af4 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java
@@ -258,6 +258,12 @@ public class Flags {
*/
public static final long DEFAULT = 1L<<43;
+ /**
+ * Flag that marks class as auxiliary, ie a non-public class following
+ * the public class in a source file, that could block implicit compilation.
+ */
+ public static final long AUXILIARY = 1L<<43;
+
/** Modifier masks.
*/
public static final int
diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Kinds.java b/langtools/src/share/classes/com/sun/tools/javac/code/Kinds.java
index dc0d52f34b6..12d3703d1fd 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Kinds.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Kinds.java
@@ -32,7 +32,9 @@ import com.sun.source.tree.MemberReferenceTree;
import com.sun.tools.javac.api.Formattable;
import com.sun.tools.javac.api.Messages;
import static com.sun.tools.javac.code.Flags.*;
-import static com.sun.tools.javac.code.TypeTags.*;
+import static com.sun.tools.javac.code.TypeTag.CLASS;
+import static com.sun.tools.javac.code.TypeTag.PACKAGE;
+import static com.sun.tools.javac.code.TypeTag.TYPEVAR;
/** Internal symbol kinds, which distinguish between elements of
* different subclasses of Symbol. Symbol kinds are organized so they can be
diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Lint.java b/langtools/src/share/classes/com/sun/tools/javac/code/Lint.java
index e3ed0f35983..88573c593ca 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Lint.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Lint.java
@@ -128,6 +128,13 @@ public class Lint
* Categories of warnings that can be generated by the compiler.
*/
public enum LintCategory {
+ /**
+ * Warn when code refers to a auxiliary class that is hidden in a source file (ie source file name is
+ * different from the class name, and the type is not properly nested) and the referring code
+ * is not located in the same source file.
+ */
+ AUXILIARYCLASS("auxiliaryclass"),
+
/**
* Warn about use of unnecessary casts.
*/
diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java b/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java
index 5d7e430ffeb..3e6b15998c3 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java
@@ -32,9 +32,12 @@ import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.code.Type.*;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.ListBuffer;
+
import static com.sun.tools.javac.code.BoundKind.*;
import static com.sun.tools.javac.code.Flags.*;
-import static com.sun.tools.javac.code.TypeTags.*;
+import static com.sun.tools.javac.code.TypeTag.ARRAY;
+import static com.sun.tools.javac.code.TypeTag.CLASS;
+import static com.sun.tools.javac.code.TypeTag.FORALL;
/**
* A combined type/symbol visitor for generating non-trivial localized string
diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java
index 328cfcf6bfe..3c2dce90873 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java
@@ -42,7 +42,9 @@ import com.sun.tools.javac.util.*;
import com.sun.tools.javac.util.Name;
import static com.sun.tools.javac.code.Flags.*;
import static com.sun.tools.javac.code.Kinds.*;
-import static com.sun.tools.javac.code.TypeTags.*;
+import static com.sun.tools.javac.code.TypeTag.CLASS;
+import static com.sun.tools.javac.code.TypeTag.FORALL;
+import static com.sun.tools.javac.code.TypeTag.TYPEVAR;
/** Root class for Java symbols. It contains subclasses
* for specific sorts of symbols, such as variables, methods and operators,
@@ -161,7 +163,7 @@ public abstract class Symbol implements Element {
if (owner.name == null || owner.name.isEmpty()) {
return location();
}
- if (owner.type.tag == CLASS) {
+ if (owner.type.hasTag(CLASS)) {
Type ownertype = types.asOuterSuper(site, owner);
if (ownertype != null) return ownertype.tsym;
}
@@ -256,7 +258,7 @@ public abstract class Symbol implements Element {
/** A class is an inner class if it it has an enclosing instance class.
*/
public boolean isInner() {
- return type.getEnclosingType().tag == CLASS;
+ return type.getEnclosingType().hasTag(CLASS);
}
/** An inner class has an outer instance if it is not an interface
@@ -269,7 +271,7 @@ public abstract class Symbol implements Element {
*/
public boolean hasOuterInstance() {
return
- type.getEnclosingType().tag == CLASS && (flags() & (INTERFACE | NOOUTERTHIS)) == 0;
+ type.getEnclosingType().hasTag(CLASS) && (flags() & (INTERFACE | NOOUTERTHIS)) == 0;
}
/** The closest enclosing class of this symbol's declaration.
@@ -277,7 +279,7 @@ public abstract class Symbol implements Element {
public ClassSymbol enclClass() {
Symbol c = this;
while (c != null &&
- ((c.kind & TYP) == 0 || c.type.tag != CLASS)) {
+ ((c.kind & TYP) == 0 || !c.type.hasTag(CLASS))) {
c = c.owner;
}
return (ClassSymbol)c;
@@ -346,7 +348,7 @@ public abstract class Symbol implements Element {
e = e.next();
}
Type superType = types.supertype(clazz.type);
- if (superType.tag != TypeTags.CLASS) return false;
+ if (!superType.hasTag(CLASS)) return false;
clazz = (ClassSymbol)superType.tsym;
}
}
@@ -373,7 +375,7 @@ public abstract class Symbol implements Element {
for (Symbol sup = clazz;
sup != null && sup != this.owner;
sup = types.supertype(sup.type).tsym) {
- while (sup.type.tag == TYPEVAR)
+ while (sup.type.hasTag(TYPEVAR))
sup = sup.type.getUpperBound().tsym;
if (sup.type.isErroneous())
return true; // error recovery
@@ -520,7 +522,7 @@ public abstract class Symbol implements Element {
if (owner == null) return name;
if (((owner.kind != ERR)) &&
((owner.kind & (VAR | MTH)) != 0
- || (owner.kind == TYP && owner.type.tag == TYPEVAR)
+ || (owner.kind == TYP && owner.type.hasTag(TYPEVAR))
)) return name;
Name prefix = owner.getQualifiedName();
if (prefix == null || prefix == prefix.table.names.empty)
@@ -534,7 +536,7 @@ public abstract class Symbol implements Element {
static public Name formFlatName(Name name, Symbol owner) {
if (owner == null ||
(owner.kind & (VAR | MTH)) != 0
- || (owner.kind == TYP && owner.type.tag == TYPEVAR)
+ || (owner.kind == TYP && owner.type.hasTag(TYPEVAR))
) return name;
char sep = owner.kind == TYP ? '$' : '.';
Name prefix = owner.flatName();
@@ -553,16 +555,16 @@ public abstract class Symbol implements Element {
if (this == that)
return false;
if (this.type.tag == that.type.tag) {
- if (this.type.tag == CLASS) {
+ if (this.type.hasTag(CLASS)) {
return
types.rank(that.type) < types.rank(this.type) ||
types.rank(that.type) == types.rank(this.type) &&
that.getQualifiedName().compareTo(this.getQualifiedName()) < 0;
- } else if (this.type.tag == TYPEVAR) {
+ } else if (this.type.hasTag(TYPEVAR)) {
return types.isSubtype(this.type, that.type);
}
}
- return this.type.tag == TYPEVAR;
+ return this.type.hasTag(TYPEVAR);
}
// For type params; overridden in subclasses.
@@ -572,7 +574,7 @@ public abstract class Symbol implements Element {
public java.util.List This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ */
+public enum TypeTag {
+ /** The tag of the basic type `byte'.
+ */
+ BYTE(1),
+
+ /** The tag of the basic type `char'.
+ */
+ CHAR(2),
+
+ /** The tag of the basic type `short'.
+ */
+ SHORT(3),
+
+ /** The tag of the basic type `int'.
+ */
+ INT(4),
+
+ /** The tag of the basic type `long'.
+ */
+ LONG(5),
+
+ /** The tag of the basic type `float'.
+ */
+ FLOAT(6),
+
+ /** The tag of the basic type `double'.
+ */
+ DOUBLE(7),
+
+ /** The tag of the basic type `boolean'.
+ */
+ BOOLEAN,
+
+ /** The tag of the type `void'.
+ */
+ VOID,
+
+ /** The tag of all class and interface types.
+ */
+ CLASS,
+
+ /** The tag of all array types.
+ */
+ ARRAY,
+
+ /** The tag of all (monomorphic) method types.
+ */
+ METHOD,
+
+ /** The tag of all package "types".
+ */
+ PACKAGE,
+
+ /** The tag of all (source-level) type variables.
+ */
+ TYPEVAR,
+
+ /** The tag of all type arguments.
+ */
+ WILDCARD,
+
+ /** The tag of all polymorphic (method-) types.
+ */
+ FORALL,
+
+ /** The tag of deferred expression types in method context
+ */
+ DEFERRED,
+
+ /** The tag of the bottom type {@code This is NOT part of any supported API.
- * If you write code that depends on this, you do so at your own risk.
- * This code and its internal interfaces are subject to change or
- * deletion without notice.
- */
-public class TypeTags {
-
- private TypeTags() {} // uninstantiable
-
- /** The tag of the basic type `byte'.
- */
- public static final int BYTE = 1;
-
- /** The tag of the basic type `char'.
- */
- public static final int CHAR = BYTE+1;
-
- /** The tag of the basic type `short'.
- */
- public static final int SHORT = CHAR+1;
-
- /** The tag of the basic type `int'.
- */
- public static final int INT = SHORT+1;
-
- /** The tag of the basic type `long'.
- */
- public static final int LONG = INT+1;
-
- /** The tag of the basic type `float'.
- */
- public static final int FLOAT = LONG+1;
-
- /** The tag of the basic type `double'.
- */
- public static final int DOUBLE = FLOAT+1;
-
- /** The tag of the basic type `boolean'.
- */
- public static final int BOOLEAN = DOUBLE+1;
-
- /** The tag of the type `void'.
- */
- public static final int VOID = BOOLEAN+1;
-
- /** The tag of all class and interface types.
- */
- public static final int CLASS = VOID+1;
-
- /** The tag of all array types.
- */
- public static final int ARRAY = CLASS+1;
-
- /** The tag of all (monomorphic) method types.
- */
- public static final int METHOD = ARRAY+1;
-
- /** The tag of all package "types".
- */
- public static final int PACKAGE = METHOD+1;
-
- /** The tag of all (source-level) type variables.
- */
- public static final int TYPEVAR = PACKAGE+1;
-
- /** The tag of all type arguments.
- */
- public static final int WILDCARD = TYPEVAR+1;
-
- /** The tag of all polymorphic (method-) types.
- */
- public static final int FORALL = WILDCARD+1;
-
- /** The tag of deferred expression types in method context
- */
- public static final int DEFERRED = FORALL+1;
-
- /** The tag of the bottom type {@code In the first phase, all class symbols are intered into their
+ * In the first phase, all class symbols are entered into their
* enclosing scope, descending recursively down the tree for classes
* which are members of other classes. The class symbols are given a
* MemberEnter object as completer.
diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java
index e616097e4f0..3ea31c9b9e8 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java
@@ -40,7 +40,8 @@ import com.sun.tools.javac.tree.JCTree.*;
import static com.sun.tools.javac.code.Flags.*;
import static com.sun.tools.javac.code.Flags.BLOCK;
import static com.sun.tools.javac.code.Kinds.*;
-import static com.sun.tools.javac.code.TypeTags.*;
+import static com.sun.tools.javac.code.TypeTag.BOOLEAN;
+import static com.sun.tools.javac.code.TypeTag.VOID;
import static com.sun.tools.javac.tree.JCTree.Tag.*;
/** This pass implements dataflow analysis for Java programs though
@@ -473,7 +474,7 @@ public class Flow {
alive = true;
scanStat(tree.body);
- if (alive && tree.sym.type.getReturnType().tag != VOID)
+ if (alive && !tree.sym.type.getReturnType().hasTag(VOID))
log.error(TreeInfo.diagEndPos(tree.body), "missing.ret.stmt");
List This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ */
+public class LambdaToMethod extends TreeTranslator {
+
+ private Names names;
+ private Symtab syms;
+ private Resolve rs;
+ private TreeMaker make;
+ private Types types;
+ private TransTypes transTypes;
+ private Env This is NOT part of any supported API.
@@ -57,7 +57,7 @@ public class TypeMaker {
if (env.legacyDoclet) {
t = env.types.erasure(t);
}
- switch (t.tag) {
+ switch (t.getTag()) {
case CLASS:
if (ClassDocImpl.isGeneric((ClassSymbol)t.tsym)) {
return env.getParameterizedType((ClassType)t);
@@ -107,10 +107,10 @@ public class TypeMaker {
}
public static String getTypeName(Type t, boolean full) {
- switch (t.tag) {
+ switch (t.getTag()) {
case ARRAY:
StringBuilder s = new StringBuilder();
- while (t.tag == ARRAY) {
+ while (t.hasTag(ARRAY)) {
s.append("[]");
t = ((ArrayType)t).elemtype;
}
@@ -129,10 +129,10 @@ public class TypeMaker {
* Class names are qualified if "full" is true.
*/
static String getTypeString(DocEnv env, Type t, boolean full) {
- switch (t.tag) {
+ switch (t.getTag()) {
case ARRAY:
StringBuilder s = new StringBuilder();
- while (t.tag == ARRAY) {
+ while (t.hasTag(ARRAY)) {
s.append("[]");
t = env.types.elemtype(t);
}
@@ -203,7 +203,7 @@ public class TypeMaker {
private com.sun.javadoc.Type skipArrays() {
if (skipArraysCache == null) {
Type t;
- for (t = arrayType; t.tag == ARRAY; t = env.types.elemtype(t)) { }
+ for (t = arrayType; t.hasTag(ARRAY); t = env.types.elemtype(t)) { }
skipArraysCache = TypeMaker.getType(env, t);
}
return skipArraysCache;
@@ -216,7 +216,7 @@ public class TypeMaker {
*/
public String dimension() {
StringBuilder dimension = new StringBuilder();
- for (Type t = arrayType; t.tag == ARRAY; t = env.types.elemtype(t)) {
+ for (Type t = arrayType; t.hasTag(ARRAY); t = env.types.elemtype(t)) {
dimension.append("[]");
}
return dimension.toString();
diff --git a/langtools/src/share/classes/com/sun/tools/javah/JavahFileManager.java b/langtools/src/share/classes/com/sun/tools/javah/JavahFileManager.java
index 72160c59992..e27eff2fdc9 100644
--- a/langtools/src/share/classes/com/sun/tools/javah/JavahFileManager.java
+++ b/langtools/src/share/classes/com/sun/tools/javah/JavahFileManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -44,7 +44,7 @@ import com.sun.tools.javac.util.Context;
class JavahFileManager extends JavacFileManager {
private JavahFileManager(Context context, Charset charset) {
super(context, true, charset);
- setIgnoreSymbolFile(true);
+ setSymbolFileEnabled(false);
}
static JavahFileManager create(final DiagnosticListener super JavaFileObject> dl, PrintWriter log) {
@@ -56,8 +56,4 @@ class JavahFileManager extends JavacFileManager {
return new JavahFileManager(javac_context, null);
}
-
- void setIgnoreSymbolFile(boolean b) {
- ignoreSymbolFile = b;
- }
}
diff --git a/langtools/src/share/classes/com/sun/tools/javah/JavahTask.java b/langtools/src/share/classes/com/sun/tools/javah/JavahTask.java
index 16c3be898aa..6b8abf9d6d1 100644
--- a/langtools/src/share/classes/com/sun/tools/javah/JavahTask.java
+++ b/langtools/src/share/classes/com/sun/tools/javah/JavahTask.java
@@ -500,7 +500,7 @@ public class JavahTask implements NativeHeaderTool.NativeHeaderTask {
g.setForce(force);
if (fileManager instanceof JavahFileManager)
- ((JavahFileManager) fileManager).setIgnoreSymbolFile(true);
+ ((JavahFileManager) fileManager).setSymbolFileEnabled(false);
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
ListDocErrorReporter used to report errors.
- * @param linkoffline True if -linkoffline isused and false if -link is used.
+ * @param linkoffline True if -linkoffline is used and false if -link is used.
*/
- public boolean url(String url, String pkglisturl,
+ public boolean link(String url, String pkglisturl,
DocErrorReporter reporter, boolean linkoffline) {
this.linkoffline = linkoffline;
- String errMsg = composeExternPackageList(url, pkglisturl);
- if (errMsg != null) {
- reporter.printWarning(errMsg);
- return false;
- } else {
+ try {
+ url = adjustEndFileSeparator(url);
+ if (isUrl(pkglisturl)) {
+ readPackageListFromURL(url, toURL(pkglisturl));
+ } else {
+ readPackageListFromFile(url, DocFile.createFileForInput(configuration, pkglisturl));
+ }
return true;
+ } catch (Fault f) {
+ reporter.printWarning(f.getMessage());
+ return false;
+ }
+ }
+
+ private URL toURL(String url) throws Fault {
+ try {
+ return new URL(url);
+ } catch (MalformedURLException e) {
+ throw new Fault(configuration.getText("doclet.MalformedURL", url), e);
+ }
+ }
+
+ private class Fault extends Exception {
+ private static final long serialVersionUID = 0;
+
+ Fault(String msg, Exception cause) {
+ super(msg, cause);
}
}
@@ -189,32 +216,11 @@ public class Extern {
return packageToItemMap.get(pkgName);
}
- /**
- * Adjusts the end file separator if it is missing from the URL or the
- * directory path and depending upon the URL or file path, fetch or
- * read the "package-list" file.
- *
- * @param urlOrDirPath URL or the directory path.
- * @param pkgListUrlOrDirPath URL or directory path for the "package-list" file or the "package-list"
- * file itself.
- */
- private String composeExternPackageList(String urlOrDirPath, String pkgListUrlOrDirPath) {
- urlOrDirPath = adjustEndFileSeparator(urlOrDirPath);
- pkgListUrlOrDirPath = adjustEndFileSeparator(pkgListUrlOrDirPath);
- return isUrl(pkgListUrlOrDirPath) ?
- fetchURLComposeExternPackageList(urlOrDirPath, pkgListUrlOrDirPath) :
- readFileComposeExternPackageList(urlOrDirPath, pkgListUrlOrDirPath);
- }
-
/**
* If the URL or Directory path is missing end file separator, add that.
*/
private String adjustEndFileSeparator(String url) {
- String filesep = "/";
- if (!url.endsWith(filesep)) {
- url += filesep;
- }
- return url;
+ return url.endsWith("/") ? url : url + '/';
}
/**
@@ -223,17 +229,18 @@ public class Extern {
* @param urlpath Path to the packages.
* @param pkglisturlpath URL or the path to the "package-list" file.
*/
- private String fetchURLComposeExternPackageList(String urlpath,
- String pkglisturlpath) {
- String link = pkglisturlpath + "package-list";
+ private void readPackageListFromURL(String urlpath, URL pkglisturlpath)
+ throws Fault {
try {
- readPackageList((new URL(link)).openStream(), urlpath, false);
+ URL link = pkglisturlpath.toURI().resolve(DocPaths.PACKAGE_LIST.getPath()).toURL();
+ readPackageList(link.openStream(), urlpath, false);
+ } catch (URISyntaxException exc) {
+ throw new Fault(configuration.getText("doclet.MalformedURL", pkglisturlpath.toString()), exc);
} catch (MalformedURLException exc) {
- return configuration.getText("doclet.MalformedURL", link);
+ throw new Fault(configuration.getText("doclet.MalformedURL", pkglisturlpath.toString()), exc);
} catch (IOException exc) {
- return configuration.getText("doclet.URL_error", link);
+ throw new Fault(configuration.getText("doclet.URL_error", pkglisturlpath.toString()), exc);
}
- return null;
}
/**
@@ -242,27 +249,24 @@ public class Extern {
* @param path URL or directory path to the packages.
* @param pkgListPath Path to the local "package-list" file.
*/
- private String readFileComposeExternPackageList(String path,
- String pkgListPath) {
-
- String link = pkgListPath + "package-list";
- if (! ((new File(pkgListPath)).isAbsolute() || linkoffline)){
- link = configuration.destDirName + link;
+ private void readPackageListFromFile(String path, DocFile pkgListPath)
+ throws Fault {
+ DocFile file = pkgListPath.resolve(DocPaths.PACKAGE_LIST);
+ if (! (file.isAbsolute() || linkoffline)){
+ file = file.resolveAgainst(StandardLocation.CLASS_OUTPUT);
}
try {
- File file = new File(link);
if (file.exists() && file.canRead()) {
- readPackageList(new FileInputStream(file), path,
- ! ((new File(path)).isAbsolute() || isUrl(path)));
+ boolean pathIsRelative =
+ !DocFile.createFileForInput(configuration, path).isAbsolute()
+ && !isUrl(path);
+ readPackageList(file.openInputStream(), path, pathIsRelative);
} else {
- return configuration.getText("doclet.File_error", link);
+ throw new Fault(configuration.getText("doclet.File_error", file.getPath()), null);
}
- } catch (FileNotFoundException exc) {
- return configuration.getText("doclet.File_error", link);
} catch (IOException exc) {
- return configuration.getText("doclet.File_error", link);
+ throw new Fault(configuration.getText("doclet.File_error", file.getPath()), exc);
}
- return null;
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PackageListWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PackageListWriter.java
index 4586deea9ce..0d1b63e5679 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PackageListWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PackageListWriter.java
@@ -52,8 +52,7 @@ public class PackageListWriter extends PrintWriter {
* @param configuration the current configuration of the doclet.
*/
public PackageListWriter(Configuration configuration) throws IOException {
- super(Util.genWriter(configuration, configuration.destDirName,
- DocletConstants.PACKAGE_LIST_FILE_NAME, configuration.docencoding));
+ super(DocFile.createFileForOutput(configuration, DocPaths.PACKAGE_LIST).openWriter());
this.configuration = configuration;
}
@@ -71,7 +70,7 @@ public class PackageListWriter extends PrintWriter {
packgen.close();
} catch (IOException exc) {
configuration.message.error("doclet.exception_encountered",
- exc.toString(), DocletConstants.PACKAGE_LIST_FILE_NAME);
+ exc.toString(), DocPaths.PACKAGE_LIST);
throw new DocletAbortException();
}
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourcePath.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourcePath.java
deleted file mode 100644
index 64c9d7e5fd5..00000000000
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourcePath.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.doclets.internal.toolkit.util;
-
-import java.io.File;
-
-/**
- * This class is used to represent a source path which can contain only
- * directories no zip files. If a zip file is specified in the command line it
- * will not get reflected in the SourcePath.
- *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
- *
- * @author Atul M Dambalkar
- */
-public
- class SourcePath {
- private final char dirSeparator = File.pathSeparatorChar;
-
- /**
- * The original class path string
- */
- private String pathstr;
-
- /**
- * List of source path entries. Each entry is a directory.
- */
- private File[] sourcePath;
-
-
- /**
- * Build a source path from the specified path string on the command line.
- */
- public SourcePath(String pathstr) {
- init(pathstr);
- }
-
- /**
- * Build a default source path from the path strings specified by
- * the properties env.class.path.
- */
- public SourcePath() {
- init(System.getProperty("env.class.path"));
- }
-
- /**
- * Initialize the SourcePath File array, which will contain only the
- * directory names from the given path string.
- *
- * @param pathstr Path String.
- */
- private void init(String pathstr) {
- if (pathstr == null || pathstr.length() == 0) {
- pathstr = ".";
- }
-
- int noOfFileSep = 0;
- int index = 0;
- this.pathstr = pathstr; // Save original class path string
-
- // Count the number of path separators
- while ((index = pathstr.indexOf(dirSeparator, index)) != -1) {
- noOfFileSep++;
- index++;
- }
- // Build the source path
- File[] tempPath = new File[noOfFileSep + 1];
- int tempPathIndex = 0;
- int len = pathstr.length();
- int sepPos = 0;
- for (index = 0; index < len; index = sepPos + 1) {
- sepPos = pathstr.indexOf(dirSeparator, index);
- if (sepPos < 0) {
- sepPos = len;
- }
- File file = new File(pathstr.substring(index, sepPos));
- if (file.isDirectory()) {
- tempPath[tempPathIndex++] = file;
- } // if it is really a file, ignore it.
- }
- sourcePath = new File[tempPathIndex];
- System.arraycopy((Object)tempPath, 0, (Object)sourcePath,
- 0, tempPathIndex);
- }
-
- /**
- * Find the specified directory in the source path.
- *
- * @param name Name of the directory to be searched for in the source path.
- * @return File Return the directory if found else return null.
- */
- public File getDirectory(String name) {
- for (int i = 0; i < sourcePath.length; i++) {
- File directoryNeeded = new File(sourcePath[i], name);
- if (directoryNeeded.isDirectory()) {
- return directoryNeeded;
- }
- }
- return null;
- }
-
- /**
- * Return original source path string.
- */
- public String toString() {
- return pathstr;
- }
-}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java
index c01ac3e58f5..1e8da4906d8 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java
@@ -30,6 +30,7 @@ import java.util.*;
import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.*;
+import javax.tools.StandardLocation;
/**
* Utilities Class for Doclets.
@@ -51,11 +52,6 @@ public class Util {
public static final String[][] HTML_ESCAPE_CHARS =
{{"&", "&"}, {"<", "<"}, {">", ">"}};
- /**
- * Name of the resource directory.
- */
- public static final String RESOURCESDIR = "resources";
-
/**
* Return array of class members whose documentation is to be generated.
* If the member is deprecated do not include such a member in the
@@ -196,32 +192,6 @@ public class Util {
}
}
- /**
- * Copy source file to destination file.
- *
- * @throws SecurityException
- * @throws IOException
- */
- public static void copyFile(File destfile, File srcfile)
- throws IOException {
- byte[] bytearr = new byte[512];
- int len = 0;
- FileInputStream input = new FileInputStream(srcfile);
- File destDir = destfile.getParentFile();
- destDir.mkdirs();
- FileOutputStream output = new FileOutputStream(destfile);
- try {
- while ((len = input.read(bytearr)) != -1) {
- output.write(bytearr, 0, len);
- }
- } catch (FileNotFoundException exc) {
- } catch (SecurityException exc) {
- } finally {
- input.close();
- output.close();
- }
- }
-
/**
* Copy the given directory contents from the source package directory
* to the generated documentation directory. For example for a package
@@ -235,45 +205,45 @@ public class Util {
* @param dir The original directory name to copy from.
* @param overwrite Overwrite files if true.
*/
- public static void copyDocFiles(Configuration configuration,
- String path, String dir, boolean overwrite) {
- if (checkCopyDocFilesErrors(configuration, path, dir)) {
- return;
- }
- String destname = configuration.docFileDestDirName;
- File srcdir = new File(path + dir);
- if (destname.length() > 0 && !destname.endsWith(
- DirectoryManager.URL_FILE_SEPARATOR)) {
- destname += DirectoryManager.URL_FILE_SEPARATOR;
- }
- String dest = destname + dir;
+ public static void copyDocFiles(Configuration configuration, PackageDoc pd) {
+ copyDocFiles(configuration, DocPath.forPackage(pd).resolve(DocPaths.DOC_FILES));
+ }
+
+ public static void copyDocFiles(Configuration configuration, DocPath dir) {
try {
- File destdir = new File(dest);
- DirectoryManager.createDirectory(configuration, dest);
- String[] files = srcdir.list();
- for (int i = 0; i < files.length; i++) {
- File srcfile = new File(srcdir, files[i]);
- File destfile = new File(destdir, files[i]);
- if (srcfile.isFile()) {
- if(destfile.exists() && ! overwrite) {
- configuration.message.warning((SourcePosition) null,
- "doclet.Copy_Overwrite_warning",
- srcfile.toString(), destdir.toString());
- } else {
- configuration.message.notice(
- "doclet.Copying_File_0_To_Dir_1",
- srcfile.toString(), destdir.toString());
- Util.copyFile(destfile, srcfile);
- }
- } else if(srcfile.isDirectory()) {
- if(configuration.copydocfilesubdirs
- && ! configuration.shouldExcludeDocFileDir(
- srcfile.getName())){
- copyDocFiles(configuration, path, dir +
- DirectoryManager.URL_FILE_SEPARATOR + srcfile.getName(),
- overwrite);
+ boolean first = true;
+ for (DocFile f : DocFile.list(configuration, StandardLocation.SOURCE_PATH, dir)) {
+ if (!f.isDirectory()) {
+ continue;
+ }
+ DocFile srcdir = f;
+ DocFile destdir = DocFile.createFileForOutput(configuration, dir);
+ if (srcdir.isSameFile(destdir)) {
+ continue;
+ }
+
+ for (DocFile srcfile: srcdir.list()) {
+ DocFile destfile = destdir.resolve(srcfile.getName());
+ if (srcfile.isFile()) {
+ if (destfile.exists() && !first) {
+ configuration.message.warning((SourcePosition) null,
+ "doclet.Copy_Overwrite_warning",
+ srcfile.getPath(), destdir.getPath());
+ } else {
+ configuration.message.notice(
+ "doclet.Copying_File_0_To_Dir_1",
+ srcfile.getPath(), destdir.getPath());
+ destfile.copyFile(srcfile);
+ }
+ } else if (srcfile.isDirectory()) {
+ if (configuration.copydocfilesubdirs
+ && !configuration.shouldExcludeDocFileDir(srcfile.getName())) {
+ copyDocFiles(configuration, dir.resolve(srcfile.getName()));
+ }
}
}
+
+ first = false;
}
} catch (SecurityException exc) {
throw new DocletAbortException();
@@ -282,142 +252,6 @@ public class Util {
}
}
- /**
- * Given the parameters for copying doc-files, check for errors.
- *
- * @param configuration The configuration of the current doclet.
- * @param path The relative path to the directory to be copied.
- * @param dirName The original directory name to copy from.
- */
- private static boolean checkCopyDocFilesErrors (Configuration configuration,
- String path, String dirName) {
- if ((configuration.sourcepath == null || configuration.sourcepath.length() == 0) &&
- (configuration.destDirName == null || configuration.destDirName.length() == 0)) {
- //The destination path and source path are definitely equal.
- return true;
- }
- File sourcePath, destPath = new File(configuration.destDirName);
- StringTokenizer pathTokens = new StringTokenizer(
- configuration.sourcepath == null ? "" : configuration.sourcepath,
- File.pathSeparator);
- //Check if the destination path is equal to the source path. If yes,
- //do not copy doc-file directories.
- while(pathTokens.hasMoreTokens()){
- sourcePath = new File(pathTokens.nextToken());
- if(destPath.equals(sourcePath)){
- return true;
- }
- }
- //Make sure the doc-file being copied exists.
- File srcdir = new File(path + dirName);
- if (! srcdir.exists()) {
- return true;
- }
- return false;
- }
-
- /**
- * Copy a file in the resources directory to the destination
- * directory (if it is not there already). If
- * overwrite is true and the destination file
- * already exists, overwrite it.
- *
- * @param configuration Holds the destination directory and error message
- * @param resourcefile The name of the resource file to copy
- * @param overwrite A flag to indicate whether the file in the
- * destination directory will be overwritten if
- * it already exists.
- */
- public static void copyResourceFile(Configuration configuration,
- String resourcefile, boolean overwrite) {
- String destresourcesdir = configuration.destDirName + RESOURCESDIR;
- copyFile(configuration, resourcefile, RESOURCESDIR, destresourcesdir,
- overwrite, false);
- }
-
- /**
- * Copy a file from a source directory to a destination directory
- * (if it is not there already). If overwrite is true and
- * the destination file already exists, overwrite it.
- *
- * @param configuration Holds the error message
- * @param file The name of the file to copy
- * @param source The source directory
- * @param destination The destination directory where the file needs to be copied
- * @param overwrite A flag to indicate whether the file in the
- * destination directory will be overwritten if
- * it already exists.
- * @param replaceNewLine true if the newline needs to be replaced with platform-
- * specific newline.
- */
- public static void copyFile(Configuration configuration, String file, String source,
- String destination, boolean overwrite, boolean replaceNewLine) {
- DirectoryManager.createDirectory(configuration, destination);
- File destfile = new File(destination, file);
- if(destfile.exists() && (! overwrite)) return;
- try {
- InputStream in = Configuration.class.getResourceAsStream(
- source + DirectoryManager.URL_FILE_SEPARATOR + file);
- if(in==null) return;
- OutputStream out = new FileOutputStream(destfile);
- try {
- if (!replaceNewLine) {
- byte[] buf = new byte[2048];
- int n;
- while((n = in.read(buf))>0) out.write(buf,0,n);
- } else {
- BufferedReader reader = new BufferedReader(new InputStreamReader(in));
- BufferedWriter writer;
- if (configuration.docencoding == null) {
- writer = new BufferedWriter(new OutputStreamWriter(out));
- } else {
- writer = new BufferedWriter(new OutputStreamWriter(out,
- configuration.docencoding));
- }
- try {
- String line;
- while ((line = reader.readLine()) != null) {
- writer.write(line);
- writer.write(DocletConstants.NL);
- }
- } finally {
- reader.close();
- writer.close();
- }
- }
- } finally {
- in.close();
- out.close();
- }
- } catch (IOException ie) {
- ie.printStackTrace(System.err);
- throw new DocletAbortException();
- }
- }
-
- /**
- * Given a PackageDoc, return the source path for that package.
- * @param configuration The Configuration for the current Doclet.
- * @param pkgDoc The package to seach the path for.
- * @return A string representing the path to the given package.
- */
- public static String getPackageSourcePath(Configuration configuration,
- PackageDoc pkgDoc){
- try{
- String pkgPath = DirectoryManager.getDirectoryPath(pkgDoc);
- String completePath = new SourcePath(configuration.sourcepath).
- getDirectory(pkgPath) + DirectoryManager.URL_FILE_SEPARATOR;
- //Make sure that both paths are using the same separators.
- completePath = Util.replaceText(completePath, File.separator,
- DirectoryManager.URL_FILE_SEPARATOR);
- pkgPath = Util.replaceText(pkgPath, File.separator,
- DirectoryManager.URL_FILE_SEPARATOR);
- return completePath.substring(0, completePath.lastIndexOf(pkgPath));
- } catch (Exception e){
- return "";
- }
- }
-
/**
* We want the list of types in alphabetical order. However, types are not
* comparable. We need a comparator for now.
@@ -552,7 +386,7 @@ public class Util {
}
/**
- * Given a package, return it's name.
+ * Given a package, return its name.
* @param packageDoc the package to check.
* @return the name of the given package.
*/
@@ -562,7 +396,7 @@ public class Util {
}
/**
- * Given a package, return it's file name without the extension.
+ * Given a package, return its file name without the extension.
* @param packageDoc the package to check.
* @return the file name of the given package.
*/
@@ -572,7 +406,7 @@ public class Util {
}
/**
- * Given a string, replace all occurraces of 'newStr' with 'oldStr'.
+ * Given a string, replace all occurrences of 'newStr' with 'oldStr'.
* @param originalStr the string to modify.
* @param oldStr the string to replace.
* @param newStr the string to insert in place of the old string.
@@ -622,40 +456,6 @@ public class Util {
return rawString.trim();
}
- /**
- * Create the directory path for the file to be generated, construct
- * FileOutputStream and OutputStreamWriter depending upon docencoding.
- *
- * @param path The directory path to be created for this file.
- * @param filename File Name to which the PrintWriter will do the Output.
- * @param docencoding Encoding to be used for this file.
- * @exception IOException Exception raised by the FileWriter is passed on
- * to next level.
- * @exception UnsupportedEncodingException Exception raised by the
- * OutputStreamWriter is passed on to next level.
- * @return Writer Writer for the file getting generated.
- * @see java.io.FileOutputStream
- * @see java.io.OutputStreamWriter
- */
- public static Writer genWriter(Configuration configuration,
- String path, String filename,
- String docencoding)
- throws IOException, UnsupportedEncodingException {
- FileOutputStream fos;
- if (path != null) {
- DirectoryManager.createDirectory(configuration, path);
- fos = new FileOutputStream(((path.length() > 0)?
- path + File.separator: "") + filename);
- } else {
- fos = new FileOutputStream(filename);
- }
- if (docencoding == null) {
- return new BufferedWriter(new OutputStreamWriter(fos));
- } else {
- return new BufferedWriter(new OutputStreamWriter(fos, docencoding));
- }
- }
-
/**
* Given an annotation, return true if it should be documented and false
* otherwise.
@@ -675,47 +475,6 @@ public class Util {
return false;
}
- /**
- * Given a string, return an array of tokens. The separator can be escaped
- * with the '\' character. The '\' character may also be escaped by the
- * '\' character.
- *
- * @param s the string to tokenize.
- * @param separator the separator char.
- * @param maxTokens the maxmimum number of tokens returned. If the
- * max is reached, the remaining part of s is appended
- * to the end of the last token.
- *
- * @return an array of tokens.
- */
- public static String[] tokenize(String s, char separator, int maxTokens) {
- List" + NL + "
"},
};
private static final String[][] NEGATED_TEST = NO_TEST;
diff --git a/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java b/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java
index 059393768a2..0ad0d86e84e 100644
--- a/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java
+++ b/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -663,14 +663,14 @@ public class TestNewLanguageFeatures extends JavadocTester {
// TYPE PARAMETER IN INDEX
//=================================
{BUG_ID + FS + "index-all.html",
- "" +
+ "" +
"method(Vector<Object>)"
},
//=================================
// TYPE PARAMETER IN INDEX
//=================================
{BUG_ID + FS + "index-all.html",
- "" +
+ "" +
"method(Vector<Object>)"
},
};
diff --git a/langtools/test/com/sun/javadoc/testPackagePage/TestPackagePage.java b/langtools/test/com/sun/javadoc/testPackagePage/TestPackagePage.java
index da0a87f72c5..06cb6eefba9 100644
--- a/langtools/test/com/sun/javadoc/testPackagePage/TestPackagePage.java
+++ b/langtools/test/com/sun/javadoc/testPackagePage/TestPackagePage.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -52,7 +52,7 @@ public class TestPackagePage extends JavadocTester {
"