8000741: refactor javadoc to use abstraction to handle relative paths

Tue, 23 Oct 2012 13:20:37 -0700

author
jjg
date
Tue, 23 Oct 2012 13:20:37 -0700
changeset 1372
78962d89f283
parent 1366
12cf6bfd8c05
child 1373
4a1c57a1c410

8000741: refactor javadoc to use abstraction to handle relative paths
Reviewed-by: darcy

src/share/classes/com/sun/javadoc/SerialFieldTag.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/SingleIndexWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/SplitIndexWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/internal/toolkit/PackageSummaryWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DirectoryManager.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPath.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPaths.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletConstants.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PackageListWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourcePath.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/SerializedForm.java file | annotate | diff | comparison | revisions
test/com/sun/javadoc/testIndex/TestIndex.java file | annotate | diff | comparison | revisions
test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java file | annotate | diff | comparison | revisions
test/com/sun/javadoc/testPackagePage/TestPackagePage.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/javadoc/SerialFieldTag.java	Wed Oct 17 16:43:26 2012 +0100
     1.2 +++ b/src/share/classes/com/sun/javadoc/SerialFieldTag.java	Tue Oct 23 13:20:37 2012 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -46,7 +46,7 @@
    1.11  public interface SerialFieldTag extends Tag, Comparable<Object> {
    1.12  
    1.13      /**
    1.14 -     * Return the serialziable field name.
    1.15 +     * Return the serializable field name.
    1.16       */
    1.17      public String fieldName();
    1.18  
     2.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java	Wed Oct 17 16:43:26 2012 +0100
     2.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java	Tue Oct 23 13:20:37 2012 -0700
     2.3 @@ -56,32 +56,18 @@
     2.4      protected IndexBuilder indexbuilder;
     2.5  
     2.6      /**
     2.7 -     * This constructor will be used by {@link SplitIndexWriter}. Initialises
     2.8 +     * This constructor will be used by {@link SplitIndexWriter}. Initializes
     2.9       * path to this file and relative path from this file.
    2.10       *
    2.11 +     * @param configuration  The current configuration
    2.12       * @param path       Path to the file which is getting generated.
    2.13 -     * @param filename   Name of the file which is getting genrated.
    2.14 -     * @param relpath    Relative path from this file to the current directory.
    2.15       * @param indexbuilder Unicode based Index from {@link IndexBuilder}
    2.16       */
    2.17      protected AbstractIndexWriter(ConfigurationImpl configuration,
    2.18 -                                  String path, String filename,
    2.19 -                                  String relpath, IndexBuilder indexbuilder)
    2.20 +                                  DocPath path,
    2.21 +                                  IndexBuilder indexbuilder)
    2.22                                    throws IOException {
    2.23 -        super(configuration, path, filename, relpath);
    2.24 -        this.indexbuilder = indexbuilder;
    2.25 -    }
    2.26 -
    2.27 -    /**
    2.28 -     * This Constructor will be used by {@link SingleIndexWriter}.
    2.29 -     *
    2.30 -     * @param filename   Name of the file which is getting genrated.
    2.31 -     * @param indexbuilder Unicode based Index form {@link IndexBuilder}
    2.32 -     */
    2.33 -    protected AbstractIndexWriter(ConfigurationImpl configuration,
    2.34 -                                  String filename, IndexBuilder indexbuilder)
    2.35 -                                  throws IOException {
    2.36 -        super(configuration, filename);
    2.37 +        super(configuration, path);
    2.38          this.indexbuilder = indexbuilder;
    2.39      }
    2.40  
     3.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java	Wed Oct 17 16:43:26 2012 +0100
     3.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java	Tue Oct 23 13:20:37 2012 -0700
     3.3 @@ -27,9 +27,11 @@
     3.4  
     3.5  import java.io.*;
     3.6  import java.util.*;
     3.7 +
     3.8  import com.sun.javadoc.*;
     3.9  import com.sun.tools.doclets.formats.html.markup.*;
    3.10  import com.sun.tools.doclets.internal.toolkit.*;
    3.11 +import com.sun.tools.doclets.internal.toolkit.util.DocPath;
    3.12  
    3.13  /**
    3.14   * Abstract class to generate the overview files in
    3.15 @@ -52,14 +54,14 @@
    3.16      protected PackageDoc[] packages;
    3.17  
    3.18      /**
    3.19 -     * Constructor. Also initialises the packages variable.
    3.20 +     * Constructor. Also initializes the packages variable.
    3.21       *
    3.22 +     * @param configuration  The current configuration
    3.23       * @param filename Name of the package index file to be generated.
    3.24       */
    3.25      public AbstractPackageIndexWriter(ConfigurationImpl configuration,
    3.26 -                                      String filename) throws IOException {
    3.27 +                                      DocPath filename) throws IOException {
    3.28          super(configuration, filename);
    3.29 -        this.relativepathNoSlash = ".";
    3.30          packages = configuration.packages;
    3.31      }
    3.32  
     4.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java	Wed Oct 17 16:43:26 2012 +0100
     4.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java	Tue Oct 23 13:20:37 2012 -0700
     4.3 @@ -56,46 +56,23 @@
     4.4      private static final String LI_CIRCLE  = "circle";
     4.5  
     4.6      /**
     4.7 -     * Constructor initilises classtree variable. This constructor will be used
     4.8 +     * Constructor initializes classtree variable. This constructor will be used
     4.9       * while generating global tree file "overview-tree.html".
    4.10       *
    4.11 +     * @param configuration  The current configuration
    4.12       * @param filename   File to be generated.
    4.13       * @param classtree  Tree built by {@link ClassTree}.
    4.14       * @throws IOException
    4.15       * @throws DocletAbortException
    4.16       */
    4.17      protected AbstractTreeWriter(ConfigurationImpl configuration,
    4.18 -                                 String filename, ClassTree classtree)
    4.19 +                                 DocPath filename, ClassTree classtree)
    4.20                                   throws IOException {
    4.21          super(configuration, filename);
    4.22          this.classtree = classtree;
    4.23      }
    4.24  
    4.25      /**
    4.26 -     * Create appropriate directory for the package and also initilise the
    4.27 -     * relative path from this generated file to the current or
    4.28 -     * the destination directory. This constructor will be used while
    4.29 -     * generating "package tree" file.
    4.30 -     *
    4.31 -     * @param path Directories in this path will be created if they are not
    4.32 -     * already there.
    4.33 -     * @param filename Name of the package tree file to be generated.
    4.34 -     * @param classtree The tree built using {@link ClassTree}.
    4.35 -     * for the package pkg.
    4.36 -     * @param pkg PackageDoc for which tree file will be generated.
    4.37 -     * @throws IOException
    4.38 -     * @throws DocletAbortException
    4.39 -     */
    4.40 -    protected AbstractTreeWriter(ConfigurationImpl configuration,
    4.41 -                                 String path, String filename,
    4.42 -                                 ClassTree classtree, PackageDoc pkg)
    4.43 -                                 throws IOException {
    4.44 -        super(configuration,
    4.45 -              path, filename, DirectoryManager.getRelativePath(pkg.name()));
    4.46 -        this.classtree = classtree;
    4.47 -    }
    4.48 -
    4.49 -    /**
    4.50       * Add each level of the class tree. For each sub-class or
    4.51       * sub-interface indents the next level information.
    4.52       * Recurses itself to add subclasses info.
     5.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java	Wed Oct 17 16:43:26 2012 +0100
     5.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java	Tue Oct 23 13:20:37 2012 -0700
     5.3 @@ -51,16 +51,6 @@
     5.4  public class AllClassesFrameWriter extends HtmlDocletWriter {
     5.5  
     5.6      /**
     5.7 -     * The name of the output file with frames
     5.8 -     */
     5.9 -    public static final String OUTPUT_FILE_NAME_FRAMES = "allclasses-frame.html";
    5.10 -
    5.11 -    /**
    5.12 -     * The name of the output file without frames
    5.13 -     */
    5.14 -    public static final String OUTPUT_FILE_NAME_NOFRAMES = "allclasses-noframe.html";
    5.15 -
    5.16 -    /**
    5.17       * Index of all the classes.
    5.18       */
    5.19      protected IndexBuilder indexbuilder;
    5.20 @@ -71,13 +61,16 @@
    5.21      final HtmlTree BR = new HtmlTree(HtmlTag.BR);
    5.22  
    5.23      /**
    5.24 -     * Construct AllClassesFrameWriter object. Also initilises the indexbuilder
    5.25 +     * Construct AllClassesFrameWriter object. Also initializes the indexbuilder
    5.26       * variable in this class.
    5.27 +     * @param configuration  The current configuration
    5.28 +     * @param filename       Path to the file which is getting generated.
    5.29 +     * @param indexbuilder   Unicode based Index from {@link IndexBuilder}
    5.30       * @throws IOException
    5.31       * @throws DocletAbortException
    5.32       */
    5.33      public AllClassesFrameWriter(ConfigurationImpl configuration,
    5.34 -                                 String filename, IndexBuilder indexbuilder)
    5.35 +                                 DocPath filename, IndexBuilder indexbuilder)
    5.36                                throws IOException {
    5.37          super(configuration, filename);
    5.38          this.indexbuilder = indexbuilder;
    5.39 @@ -94,13 +87,13 @@
    5.40      public static void generate(ConfigurationImpl configuration,
    5.41                                  IndexBuilder indexbuilder) {
    5.42          AllClassesFrameWriter allclassgen;
    5.43 -        String filename = OUTPUT_FILE_NAME_FRAMES;
    5.44 +        DocPath filename = DocPaths.ALLCLASSES_FRAME;
    5.45          try {
    5.46              allclassgen = new AllClassesFrameWriter(configuration,
    5.47                                                      filename, indexbuilder);
    5.48              allclassgen.buildAllClassesFile(true);
    5.49              allclassgen.close();
    5.50 -            filename = OUTPUT_FILE_NAME_NOFRAMES;
    5.51 +            filename = DocPaths.ALLCLASSES_NOFRAME;
    5.52              allclassgen = new AllClassesFrameWriter(configuration,
    5.53                                                      filename, indexbuilder);
    5.54              allclassgen.buildAllClassesFile(false);
     6.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java	Wed Oct 17 16:43:26 2012 +0100
     6.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java	Tue Oct 23 13:20:37 2012 -0700
     6.3 @@ -141,7 +141,7 @@
     6.4       */
     6.5      protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
     6.6          if (link) {
     6.7 -            return writer.getHyperLink("", "annotation_type_optional_element_summary",
     6.8 +            return writer.getHyperLink("annotation_type_optional_element_summary",
     6.9                      writer.getResource("doclet.navAnnotationTypeOptionalMember"));
    6.10          } else {
    6.11              return writer.getResource("doclet.navAnnotationTypeOptionalMember");
     7.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java	Wed Oct 17 16:43:26 2012 +0100
     7.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java	Tue Oct 23 13:20:37 2012 -0700
     7.3 @@ -260,7 +260,7 @@
     7.4       */
     7.5      protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
     7.6          if (link) {
     7.7 -            return writer.getHyperLink("", "annotation_type_required_element_summary",
     7.8 +            return writer.getHyperLink("annotation_type_required_element_summary",
     7.9                      writer.getResource("doclet.navAnnotationTypeRequiredMember"));
    7.10          } else {
    7.11              return writer.getResource("doclet.navAnnotationTypeRequiredMember");
    7.12 @@ -272,7 +272,7 @@
    7.13       */
    7.14      protected void addNavDetailLink(boolean link, Content liNav) {
    7.15          if (link) {
    7.16 -            liNav.addContent(writer.getHyperLink("", "annotation_type_element_detail",
    7.17 +            liNav.addContent(writer.getHyperLink("annotation_type_element_detail",
    7.18                      writer.getResource("doclet.navAnnotationTypeMember")));
    7.19          } else {
    7.20              liNav.addContent(writer.getResource("doclet.navAnnotationTypeMember"));
     8.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java	Wed Oct 17 16:43:26 2012 +0100
     8.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java	Tue Oct 23 13:20:37 2012 -0700
     8.3 @@ -65,13 +65,10 @@
     8.4       * @param prevType the previous class that was documented.
     8.5       * @param nextType the next class being documented.
     8.6       */
     8.7 -    public AnnotationTypeWriterImpl (AnnotationTypeDoc annotationType,
     8.8 +    public AnnotationTypeWriterImpl(AnnotationTypeDoc annotationType,
     8.9              Type prevType, Type nextType)
    8.10 -    throws Exception {
    8.11 -        super(ConfigurationImpl.getInstance(),
    8.12 -              DirectoryManager.getDirectoryPath(annotationType.containingPackage()),
    8.13 -              annotationType.name() + ".html",
    8.14 -              DirectoryManager.getRelativePath(annotationType.containingPackage().name()));
    8.15 +            throws Exception {
    8.16 +        super(ConfigurationImpl.getInstance(), DocPath.forClass(annotationType));
    8.17          this.annotationType = annotationType;
    8.18          configuration.currentcd = annotationType.asClassDoc();
    8.19          this.prev = prevType;
    8.20 @@ -84,7 +81,7 @@
    8.21       * @return a content tree for the package link
    8.22       */
    8.23      protected Content getNavLinkPackage() {
    8.24 -        Content linkContent = getHyperLink("package-summary.html", "",
    8.25 +        Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY, "",
    8.26                  packageLabel);
    8.27          Content li = HtmlTree.LI(linkContent);
    8.28          return li;
    8.29 @@ -106,7 +103,7 @@
    8.30       * @return a content tree for the class use link
    8.31       */
    8.32      protected Content getNavLinkClassUse() {
    8.33 -        Content linkContent = getHyperLink("class-use/" + filename, "", useLabel);
    8.34 +        Content linkContent = getHyperLink(DocPaths.CLASS_USE.resolve(filename), "", useLabel);
    8.35          Content li = HtmlTree.LI(linkContent);
    8.36          return li;
    8.37      }
    8.38 @@ -289,7 +286,7 @@
    8.39       * {@inheritDoc}
    8.40       */
    8.41      protected Content getNavLinkTree() {
    8.42 -        Content treeLinkContent = getHyperLink("package-tree.html",
    8.43 +        Content treeLinkContent = getHyperLink(DocPaths.PACKAGE_TREE,
    8.44                  "", treeLabel, "", "");
    8.45          Content li = HtmlTree.LI(treeLinkContent);
    8.46          return li;
     9.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java	Wed Oct 17 16:43:26 2012 +0100
     9.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java	Tue Oct 23 13:20:37 2012 -0700
     9.3 @@ -82,7 +82,6 @@
     9.4      final String methodUseTableSummary;
     9.5      final String constructorUseTableSummary;
     9.6  
     9.7 -
     9.8      /**
     9.9       * Constructor.
    9.10       *
    9.11 @@ -91,10 +90,9 @@
    9.12       * @throws DocletAbortException
    9.13       */
    9.14      public ClassUseWriter(ConfigurationImpl configuration,
    9.15 -                          ClassUseMapper mapper, String path,
    9.16 -                          String filename, String relpath,
    9.17 +                          ClassUseMapper mapper, DocPath filename,
    9.18                            ClassDoc classdoc) throws IOException {
    9.19 -        super(configuration, path, filename, relpath);
    9.20 +        super(configuration, filename);
    9.21          this.classdoc = classdoc;
    9.22          if (mapper.classToPackageAnnotations.containsKey(classdoc.qualifiedName()))
    9.23                  pkgToPackageAnnotations = new HashSet<PackageDoc>(mapper.classToPackageAnnotations.get(classdoc.qualifiedName()));
    9.24 @@ -199,23 +197,19 @@
    9.25      public static void generate(ConfigurationImpl configuration,
    9.26                                  ClassUseMapper mapper, ClassDoc classdoc) {
    9.27          ClassUseWriter clsgen;
    9.28 -        String path = DirectoryManager.getDirectoryPath(classdoc.
    9.29 -                                                            containingPackage());
    9.30 -        path += "class-use" + DirectoryManager.URL_FILE_SEPARATOR;
    9.31 -        String filename = classdoc.name() + ".html";
    9.32 -        String pkgname = classdoc.containingPackage().name();
    9.33 -        pkgname += (pkgname.length() > 0)? ".class-use": "class-use";
    9.34 -        String relpath = DirectoryManager.getRelativePath(pkgname);
    9.35 +        DocPath path = DocPath.forPackage(classdoc)
    9.36 +                .resolve(DocPaths.CLASS_USE)
    9.37 +                .resolve(DocPath.forName(classdoc));
    9.38          try {
    9.39              clsgen = new ClassUseWriter(configuration,
    9.40 -                                        mapper, path, filename,
    9.41 -                                        relpath, classdoc);
    9.42 +                                        mapper, path,
    9.43 +                                        classdoc);
    9.44              clsgen.generateClassUseFile();
    9.45              clsgen.close();
    9.46          } catch (IOException exc) {
    9.47              configuration.standardmessage.
    9.48                  error("doclet.exception_encountered",
    9.49 -                      exc.toString(), filename);
    9.50 +                      exc.toString(), path.getPath());
    9.51              throw new DocletAbortException();
    9.52          }
    9.53      }
    9.54 @@ -359,7 +353,7 @@
    9.55       */
    9.56      protected void addPackageUse(PackageDoc pkg, Content contentTree) throws IOException {
    9.57          Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst,
    9.58 -                getHyperLink("", pkg.name(), new StringContent(Util.getPackageName(pkg))));
    9.59 +                getHyperLink(pkg.name(), new StringContent(Util.getPackageName(pkg))));
    9.60          contentTree.addContent(tdFirst);
    9.61          HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
    9.62          tdLast.addStyle(HtmlStyle.colLast);
    9.63 @@ -470,8 +464,8 @@
    9.64       * @return a content tree for the package link
    9.65       */
    9.66      protected Content getNavLinkPackage() {
    9.67 -        Content linkContent = getHyperLink("../package-summary.html", "",
    9.68 -                packageLabel);
    9.69 +        Content linkContent =
    9.70 +                getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_SUMMARY), "", packageLabel);
    9.71          Content li = HtmlTree.LI(linkContent);
    9.72          return li;
    9.73      }
    9.74 @@ -506,8 +500,8 @@
    9.75       */
    9.76      protected Content getNavLinkTree() {
    9.77          Content linkContent = classdoc.containingPackage().isIncluded() ?
    9.78 -            getHyperLink("../package-tree.html", "", treeLabel) :
    9.79 -            getHyperLink(relativePath + "overview-tree.html", "", treeLabel);
    9.80 +            getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_TREE), "", treeLabel) :
    9.81 +            getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), "", treeLabel);
    9.82          Content li = HtmlTree.LI(linkContent);
    9.83          return li;
    9.84      }
    10.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java	Wed Oct 17 16:43:26 2012 +0100
    10.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java	Tue Oct 23 13:20:37 2012 -0700
    10.3 @@ -72,11 +72,8 @@
    10.4       */
    10.5      public ClassWriterImpl (ClassDoc classDoc,
    10.6              ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree)
    10.7 -    throws Exception {
    10.8 -        super(ConfigurationImpl.getInstance(),
    10.9 -              DirectoryManager.getDirectoryPath(classDoc.containingPackage()),
   10.10 -              classDoc.name() + ".html",
   10.11 -              DirectoryManager.getRelativePath(classDoc.containingPackage().name()));
   10.12 +            throws Exception {
   10.13 +        super(ConfigurationImpl.getInstance(), DocPath.forClass(classDoc));
   10.14          this.classDoc = classDoc;
   10.15          configuration.currentcd = classDoc;
   10.16          this.classtree = classTree;
   10.17 @@ -90,7 +87,7 @@
   10.18       * @return a content tree for the package link
   10.19       */
   10.20      protected Content getNavLinkPackage() {
   10.21 -        Content linkContent = getHyperLink("package-summary.html", "",
   10.22 +        Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY, "",
   10.23                  packageLabel);
   10.24          Content li = HtmlTree.LI(linkContent);
   10.25          return li;
   10.26 @@ -112,7 +109,7 @@
   10.27       * @return a content tree for the class use link
   10.28       */
   10.29      protected Content getNavLinkClassUse() {
   10.30 -        Content linkContent = getHyperLink("class-use/" + filename, "", useLabel);
   10.31 +        Content linkContent = getHyperLink(DocPaths.CLASS_USE.resolve(filename), "", useLabel);
   10.32          Content li = HtmlTree.LI(linkContent);
   10.33          return li;
   10.34      }
   10.35 @@ -567,7 +564,7 @@
   10.36       * {@inheritDoc}
   10.37       */
   10.38      protected Content getNavLinkTree() {
   10.39 -        Content treeLinkContent = getHyperLink("package-tree.html",
   10.40 +        Content treeLinkContent = getHyperLink(DocPaths.PACKAGE_TREE,
   10.41                  "", treeLabel, "", "");
   10.42          Content li = HtmlTree.LI(treeLinkContent);
   10.43          return li;
    11.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java	Wed Oct 17 16:43:26 2012 +0100
    11.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java	Tue Oct 23 13:20:37 2012 -0700
    11.3 @@ -62,11 +62,6 @@
    11.4      public static final String BUILD_DATE = System.getProperty("java.version");
    11.5  
    11.6      /**
    11.7 -     * The name of the constant values file.
    11.8 -     */
    11.9 -    public static final String CONSTANTS_FILE_NAME = "constant-values.html";
   11.10 -
   11.11 -    /**
   11.12       * Argument for command line option "-header".
   11.13       */
   11.14      public String header = "";
   11.15 @@ -179,7 +174,7 @@
   11.16       * First file to appear in the right-hand frame in the generated
   11.17       * documentation.
   11.18       */
   11.19 -    public String topFile = "";
   11.20 +    public DocPath topFile = DocPath.empty;
   11.21  
   11.22      /**
   11.23       * The classdoc for the class file getting generated.
   11.24 @@ -447,18 +442,17 @@
   11.25              return;
   11.26          }
   11.27          if (createoverview) {
   11.28 -            topFile = "overview-summary.html";
   11.29 +            topFile = DocPaths.OVERVIEW_SUMMARY;
   11.30          } else {
   11.31              if (packages.length == 1 && packages[0].name().equals("")) {
   11.32                  if (root.classes().length > 0) {
   11.33                      ClassDoc[] classarr = root.classes();
   11.34                      Arrays.sort(classarr);
   11.35                      ClassDoc cd = getValidClass(classarr);
   11.36 -                    topFile = DirectoryManager.getPathToClass(cd);
   11.37 +                    topFile = DocPath.forClass(cd);
   11.38                  }
   11.39              } else {
   11.40 -                topFile = DirectoryManager.getPathToPackage(packages[0],
   11.41 -                                                            "package-summary.html");
   11.42 +                topFile = DocPath.forPackage(packages[0]).resolve(DocPaths.PACKAGE_SUMMARY);
   11.43              }
   11.44          }
   11.45      }
    12.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java	Wed Oct 17 16:43:26 2012 +0100
    12.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java	Tue Oct 23 13:20:37 2012 -0700
    12.3 @@ -69,7 +69,7 @@
    12.4       */
    12.5      public ConstantsSummaryWriterImpl(ConfigurationImpl configuration)
    12.6              throws IOException {
    12.7 -        super(configuration, ConfigurationImpl.CONSTANTS_FILE_NAME);
    12.8 +        super(configuration, DocPaths.CONSTANT_VALUES);
    12.9          this.configuration = configuration;
   12.10          constantsTableSummary = configuration.getText("doclet.Constants_Table_Summary",
   12.11                  configuration.getText("doclet.Constants_Summary"));
    13.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java	Wed Oct 17 16:43:26 2012 +0100
    13.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java	Tue Oct 23 13:20:37 2012 -0700
    13.3 @@ -280,7 +280,7 @@
    13.4       */
    13.5      protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
    13.6          if (link) {
    13.7 -            return writer.getHyperLink("", "constructor_summary",
    13.8 +            return writer.getHyperLink("constructor_summary",
    13.9                      writer.getResource("doclet.navConstructor"));
   13.10          } else {
   13.11              return writer.getResource("doclet.navConstructor");
   13.12 @@ -292,7 +292,7 @@
   13.13       */
   13.14      protected void addNavDetailLink(boolean link, Content liNav) {
   13.15          if (link) {
   13.16 -            liNav.addContent(writer.getHyperLink("", "constructor_detail",
   13.17 +            liNav.addContent(writer.getHyperLink("constructor_detail",
   13.18                      writer.getResource("doclet.navConstructor")));
   13.19          } else {
   13.20              liNav.addContent(writer.getResource("doclet.navConstructor"));
    14.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java	Wed Oct 17 16:43:26 2012 +0100
    14.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java	Tue Oct 23 13:20:37 2012 -0700
    14.3 @@ -95,7 +95,7 @@
    14.4       * @param filename the file to be generated.
    14.5       */
    14.6      public DeprecatedListWriter(ConfigurationImpl configuration,
    14.7 -                                String filename) throws IOException {
    14.8 +                                DocPath filename) throws IOException {
    14.9          super(configuration, filename);
   14.10          this.configuration = configuration;
   14.11          NestedClassWriterImpl classW = new NestedClassWriterImpl(this);
   14.12 @@ -116,7 +116,7 @@
   14.13       * @param configuration the current configuration of the doclet.
   14.14       */
   14.15      public static void generate(ConfigurationImpl configuration) {
   14.16 -        String filename = "deprecated-list.html";
   14.17 +        DocPath filename = DocPaths.DEPRECATED_LIST;
   14.18          try {
   14.19              DeprecatedListWriter depr =
   14.20                     new DeprecatedListWriter(configuration, filename);
   14.21 @@ -180,7 +180,7 @@
   14.22      private void addIndexLink(DeprecatedAPIListBuilder builder,
   14.23              int type, Content contentTree) {
   14.24          if (builder.hasDocumentation(type)) {
   14.25 -            Content li = HtmlTree.LI(getHyperLink("#" + ANCHORS[type],
   14.26 +            Content li = HtmlTree.LI(getHyperLink(ANCHORS[type],
   14.27                      getResource(HEADING_KEYS[type])));
   14.28              contentTree.addContent(li);
   14.29          }
    15.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java	Wed Oct 17 16:43:26 2012 +0100
    15.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java	Tue Oct 23 13:20:37 2012 -0700
    15.3 @@ -263,7 +263,7 @@
    15.4       */
    15.5      protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
    15.6          if (link) {
    15.7 -            return writer.getHyperLink("", (cd == null)?
    15.8 +            return writer.getHyperLink((cd == null)?
    15.9                  "enum_constant_summary":
   15.10                  "enum_constants_inherited_from_class_" +
   15.11                  configuration().getClassName(cd),
   15.12 @@ -278,7 +278,7 @@
   15.13       */
   15.14      protected void addNavDetailLink(boolean link, Content liNav) {
   15.15          if (link) {
   15.16 -            liNav.addContent(writer.getHyperLink("", "enum_constant_detail",
   15.17 +            liNav.addContent(writer.getHyperLink("enum_constant_detail",
   15.18                      writer.getResource("doclet.navEnum")));
   15.19          } else {
   15.20              liNav.addContent(writer.getResource("doclet.navEnum"));
    16.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java	Wed Oct 17 16:43:26 2012 +0100
    16.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java	Tue Oct 23 13:20:37 2012 -0700
    16.3 @@ -293,7 +293,7 @@
    16.4       */
    16.5      protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
    16.6          if (link) {
    16.7 -            return writer.getHyperLink("", (cd == null)?
    16.8 +            return writer.getHyperLink((cd == null)?
    16.9                  "field_summary":
   16.10                  "fields_inherited_from_class_" +
   16.11                  configuration().getClassName(cd),
   16.12 @@ -308,7 +308,7 @@
   16.13       */
   16.14      protected void addNavDetailLink(boolean link, Content liNav) {
   16.15          if (link) {
   16.16 -            liNav.addContent(writer.getHyperLink("", "field_detail",
   16.17 +            liNav.addContent(writer.getHyperLink("field_detail",
   16.18                      writer.getResource("doclet.navField")));
   16.19          } else {
   16.20              liNav.addContent(writer.getResource("doclet.navField"));
    17.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java	Wed Oct 17 16:43:26 2012 +0100
    17.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java	Tue Oct 23 13:20:37 2012 -0700
    17.3 @@ -63,7 +63,7 @@
    17.4       * @param filename File to be generated.
    17.5       */
    17.6      public FrameOutputWriter(ConfigurationImpl configuration,
    17.7 -                             String filename) throws IOException {
    17.8 +                             DocPath filename) throws IOException {
    17.9          super(configuration, filename);
   17.10      noOfPackages = configuration.packages.length;
   17.11      }
   17.12 @@ -77,9 +77,9 @@
   17.13       */
   17.14      public static void generate(ConfigurationImpl configuration) {
   17.15          FrameOutputWriter framegen;
   17.16 -        String filename = "";
   17.17 +        DocPath filename = DocPath.empty;
   17.18          try {
   17.19 -            filename = "index.html";
   17.20 +            filename = DocPaths.INDEX;
   17.21              framegen = new FrameOutputWriter(configuration, filename);
   17.22              framegen.generateFrameFile();
   17.23              framegen.close();
   17.24 @@ -92,7 +92,7 @@
   17.25      }
   17.26  
   17.27      /**
   17.28 -     * Generate the contants in the "index.html" file. Print the frame details
   17.29 +     * Generate the constants in the "index.html" file. Print the frame details
   17.30       * as well as warning if browser is not supporting the Html frames.
   17.31       */
   17.32      protected void generateFrameFile() throws IOException {
   17.33 @@ -155,8 +155,8 @@
   17.34       * @param contentTree the content tree to which the information will be added
   17.35       */
   17.36      private void addAllPackagesFrameTag(Content contentTree) {
   17.37 -        HtmlTree frame = HtmlTree.FRAME("overview-frame.html", "packageListFrame",
   17.38 -                configuration.getText("doclet.All_Packages"));
   17.39 +        HtmlTree frame = HtmlTree.FRAME(DocPaths.OVERVIEW_FRAME.getPath(),
   17.40 +                "packageListFrame", configuration.getText("doclet.All_Packages"));
   17.41          contentTree.addContent(frame);
   17.42      }
   17.43  
   17.44 @@ -166,8 +166,8 @@
   17.45       * @param contentTree the content tree to which the information will be added
   17.46       */
   17.47      private void addAllClassesFrameTag(Content contentTree) {
   17.48 -        HtmlTree frame = HtmlTree.FRAME("allclasses-frame.html", "packageFrame",
   17.49 -                configuration.getText("doclet.All_classes_and_interfaces"));
   17.50 +        HtmlTree frame = HtmlTree.FRAME(DocPaths.ALLCLASSES_FRAME.getPath(),
   17.51 +                "packageFrame", configuration.getText("doclet.All_classes_and_interfaces"));
   17.52          contentTree.addContent(frame);
   17.53      }
   17.54  
   17.55 @@ -177,7 +177,7 @@
   17.56       * @param contentTree the content tree to which the information will be added
   17.57       */
   17.58      private void addClassFrameTag(Content contentTree) {
   17.59 -        HtmlTree frame = HtmlTree.FRAME(configuration.topFile, "classFrame",
   17.60 +        HtmlTree frame = HtmlTree.FRAME(configuration.topFile.getPath(), "classFrame",
   17.61                  configuration.getText("doclet.Package_class_and_interface_descriptions"),
   17.62                  SCROLL_YES);
   17.63          contentTree.addContent(frame);
    18.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java	Wed Oct 17 16:43:26 2012 +0100
    18.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java	Tue Oct 23 13:20:37 2012 -0700
    18.3 @@ -49,7 +49,7 @@
    18.4       * @param filename File to be generated.
    18.5       */
    18.6      public HelpWriter(ConfigurationImpl configuration,
    18.7 -                      String filename) throws IOException {
    18.8 +                      DocPath filename) throws IOException {
    18.9          super(configuration, filename);
   18.10      }
   18.11  
   18.12 @@ -62,9 +62,9 @@
   18.13       */
   18.14      public static void generate(ConfigurationImpl configuration) {
   18.15          HelpWriter helpgen;
   18.16 -        String filename = "";
   18.17 +        DocPath filename = DocPath.empty;
   18.18          try {
   18.19 -            filename = "help-doc.html";
   18.20 +            filename = DocPaths.HELP_DOC;
   18.21              helpgen = new HelpWriter(configuration, filename);
   18.22              helpgen.generateHelpFile();
   18.23              helpgen.close();
   18.24 @@ -113,7 +113,7 @@
   18.25                  getResource("doclet.Overview"));
   18.26              Content liOverview = HtmlTree.LI(HtmlStyle.blockList, overviewHeading);
   18.27              Content line3 = getResource("doclet.Help_line_3",
   18.28 -                    getHyperLinkString("overview-summary.html",
   18.29 +                    getHyperLinkString(DocPaths.OVERVIEW_SUMMARY,
   18.30                      configuration.getText("doclet.Overview")));
   18.31              Content overviewPara = HtmlTree.P(line3);
   18.32              liOverview.addContent(overviewPara);
   18.33 @@ -234,7 +234,7 @@
   18.34                      getResource("doclet.Help_line_16"));
   18.35              Content liTree = HtmlTree.LI(HtmlStyle.blockList, treeHead);
   18.36              Content line17 = getResource("doclet.Help_line_17_with_tree_link",
   18.37 -                    getHyperLinkString("overview-tree.html",
   18.38 +                    getHyperLinkString(DocPaths.OVERVIEW_TREE,
   18.39                      configuration.getText("doclet.Class_Hierarchy")));
   18.40              Content treePara = HtmlTree.P(line17);
   18.41              liTree.addContent(treePara);
   18.42 @@ -252,7 +252,7 @@
   18.43                      getResource("doclet.Deprecated_API"));
   18.44              Content liDeprecated = HtmlTree.LI(HtmlStyle.blockList, dHead);
   18.45              Content line20 = getResource("doclet.Help_line_20_with_deprecated_api_link",
   18.46 -                    getHyperLinkString("deprecated-list.html",
   18.47 +                    getHyperLinkString(DocPaths.DEPRECATED_LIST,
   18.48                      configuration.getText("doclet.Deprecated_API")));
   18.49              Content dPara = HtmlTree.P(line20);
   18.50              liDeprecated.addContent(dPara);
   18.51 @@ -261,10 +261,10 @@
   18.52          if (configuration.createindex) {
   18.53              String indexlink;
   18.54              if (configuration.splitindex) {
   18.55 -                indexlink = getHyperLinkString("index-files/index-1.html",
   18.56 +                indexlink = getHyperLinkString(DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1)),
   18.57                          configuration.getText("doclet.Index"));
   18.58              } else {
   18.59 -                indexlink = getHyperLinkString("index-all.html",
   18.60 +                indexlink = getHyperLinkString(DocPaths.INDEX_ALL,
   18.61                          configuration.getText("doclet.Index"));
   18.62              }
   18.63              Content indexHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
   18.64 @@ -293,7 +293,7 @@
   18.65                  getResource("doclet.All_Classes"));
   18.66          Content liAllClasses = HtmlTree.LI(HtmlStyle.blockList, allclassesHead);
   18.67          Content line27 = getResource("doclet.Help_line_27",
   18.68 -                getHyperLinkString("allclasses-noframe.html",
   18.69 +                getHyperLinkString(DocPaths.ALLCLASSES_NOFRAME,
   18.70                  configuration.getText("doclet.All_Classes")));
   18.71          Content allclassesPara = HtmlTree.P(line27);
   18.72          liAllClasses.addContent(allclassesPara);
   18.73 @@ -309,7 +309,7 @@
   18.74                  getResource("doclet.Constants_Summary"));
   18.75          Content liConst = HtmlTree.LI(HtmlStyle.blockList, constHead);
   18.76          Content line29 = getResource("doclet.Help_line_29",
   18.77 -                getHyperLinkString("constant-values.html",
   18.78 +                getHyperLinkString(DocPaths.CONSTANT_VALUES,
   18.79                  configuration.getText("doclet.Constants_Summary")));
   18.80          Content constPara = HtmlTree.P(line29);
   18.81          liConst.addContent(constPara);
   18.82 @@ -325,6 +325,7 @@
   18.83       *
   18.84       * @return a content tree for the help label
   18.85       */
   18.86 +    @Override
   18.87      protected Content getNavLinkHelp() {
   18.88          Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, helpLabel);
   18.89          return li;
    19.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java	Wed Oct 17 16:43:26 2012 +0100
    19.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java	Tue Oct 23 13:20:37 2012 -0700
    19.3 @@ -94,17 +94,11 @@
    19.4              throws Exception {
    19.5          super.generateOtherFiles(root, classtree);
    19.6          if (configuration.linksource) {
    19.7 -            if (configuration.destDirName.length() > 0) {
    19.8 -                SourceToHTMLConverter.convertRoot(configuration,
    19.9 -                    root, configuration.destDirName + File.separator
   19.10 -                    + DocletConstants.SOURCE_OUTPUT_DIR_NAME);
   19.11 -            } else {
   19.12 -                SourceToHTMLConverter.convertRoot(configuration,
   19.13 -                    root, DocletConstants.SOURCE_OUTPUT_DIR_NAME);
   19.14 -            }
   19.15 +            SourceToHTMLConverter.convertRoot(configuration,
   19.16 +                root, DocPaths.SOURCE_OUTPUT);
   19.17          }
   19.18  
   19.19 -        if (configuration.topFile.length() == 0) {
   19.20 +        if (configuration.topFile.isEmpty()) {
   19.21              configuration.standardmessage.
   19.22                  error("doclet.No_Non_Deprecated_Classes_To_Document");
   19.23              return;
   19.24 @@ -155,9 +149,8 @@
   19.25          // If a stylesheet file is not specified, copy the default stylesheet
   19.26          // and replace newline with platform-specific newline.
   19.27          if (configuration.stylesheetfile.length() == 0) {
   19.28 -            Util.copyFile(configuration, "stylesheet.css", Util.RESOURCESDIR,
   19.29 -                    (configdestdir.isEmpty()) ?
   19.30 -                        System.getProperty("user.dir") : configdestdir, false, true);
   19.31 +            Util.copyFile(configuration, "stylesheet.css", DocPaths.RESOURCES,
   19.32 +                    DocPath.empty, false, true);
   19.33          }
   19.34      }
   19.35  
    20.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Wed Oct 17 16:43:26 2012 +0100
    20.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Tue Oct 23 13:20:37 2012 -0700
    20.3 @@ -55,32 +55,24 @@
    20.4      /**
    20.5       * Relative path from the file getting generated to the destination
    20.6       * directory. For example, if the file getting generated is
    20.7 -     * "java/lang/Object.html", then the relative path string is "../../".
    20.8 +     * "java/lang/Object.html", then the path to the root is "../..".
    20.9       * This string can be empty if the file getting generated is in
   20.10       * the destination directory.
   20.11       */
   20.12 -    public String relativePath = "";
   20.13 +    public final DocPath pathToRoot;
   20.14  
   20.15      /**
   20.16 -     * Same as relativepath, but normalized to never be empty or
   20.17 -     * end with a slash.
   20.18 -     */
   20.19 -    public String relativepathNoSlash = "";
   20.20 -
   20.21 -    /**
   20.22 -     * Platform-dependent directory path from the current or the
   20.23 +     * Platform-independent path from the current or the
   20.24       * destination directory to the file getting generated.
   20.25       * Used when creating the file.
   20.26 -     * For example, if the file getting generated is
   20.27 -     * "java/lang/Object.html", then the path string is "java/lang".
   20.28       */
   20.29 -    public String path = "";
   20.30 +    public final DocPath path;
   20.31  
   20.32      /**
   20.33       * Name of the file getting generated. If the file getting generated is
   20.34       * "java/lang/Object.html", then the filename is "Object.html".
   20.35       */
   20.36 -    public String filename = "";
   20.37 +    public final DocPath filename;
   20.38  
   20.39      /**
   20.40       * The display length used for indentation while generating the class page.
   20.41 @@ -100,33 +92,15 @@
   20.42      /**
   20.43       * Constructor to construct the HtmlStandardWriter object.
   20.44       *
   20.45 -     * @param filename File to be generated.
   20.46 +     * @param path File to be generated.
   20.47       */
   20.48 -    public HtmlDocletWriter(ConfigurationImpl configuration,
   20.49 -                              String filename) throws IOException {
   20.50 -        super(configuration, filename);
   20.51 -        this.configuration = configuration;
   20.52 -        this.filename = filename;
   20.53 -    }
   20.54 -
   20.55 -    /**
   20.56 -     * Constructor to construct the HtmlStandardWriter object.
   20.57 -     *
   20.58 -     * @param path         Platform-dependent {@link #path} used when
   20.59 -     *                     creating file.
   20.60 -     * @param filename     Name of file to be generated.
   20.61 -     * @param relativePath Value for the variable {@link #relativePath}.
   20.62 -     */
   20.63 -    public HtmlDocletWriter(ConfigurationImpl configuration,
   20.64 -                              String path, String filename,
   20.65 -                              String relativePath) throws IOException {
   20.66 -        super(configuration, path, filename);
   20.67 +    public HtmlDocletWriter(ConfigurationImpl configuration, DocPath path)
   20.68 +            throws IOException {
   20.69 +        super(configuration, path);
   20.70          this.configuration = configuration;
   20.71          this.path = path;
   20.72 -        this.relativePath = relativePath;
   20.73 -        this.relativepathNoSlash =
   20.74 -            DirectoryManager.getPathNoTrailingSlash(this.relativePath);
   20.75 -        this.filename = filename;
   20.76 +        this.pathToRoot = path.parent().invert();
   20.77 +        this.filename = path.basename();
   20.78      }
   20.79  
   20.80      /**
   20.81 @@ -165,8 +139,9 @@
   20.82          int previndex = 0;
   20.83          while (true) {
   20.84              if (configuration.docrootparent.length() > 0) {
   20.85 +                final String docroot_parent = "{@docroot}/..";
   20.86                  // Search for lowercase version of {@docRoot}/..
   20.87 -                index = lowerHtml.indexOf("{@docroot}/..", previndex);
   20.88 +                index = lowerHtml.indexOf(docroot_parent, previndex);
   20.89                  // If next {@docRoot}/.. pattern not found, append rest of htmlstr and exit loop
   20.90                  if (index < 0) {
   20.91                      buf.append(htmlstr.substring(previndex));
   20.92 @@ -174,17 +149,18 @@
   20.93                  }
   20.94                  // If next {@docroot}/.. pattern found, append htmlstr up to start of tag
   20.95                  buf.append(htmlstr.substring(previndex, index));
   20.96 -                previndex = index + 13;  // length for {@docroot}/.. string
   20.97 +                previndex = index + docroot_parent.length();
   20.98                  // Insert docrootparent absolute path where {@docRoot}/.. was located
   20.99  
  20.100                  buf.append(configuration.docrootparent);
  20.101                  // Append slash if next character is not a slash
  20.102                  if (previndex < htmlstr.length() && htmlstr.charAt(previndex) != '/') {
  20.103 -                    buf.append(DirectoryManager.URL_FILE_SEPARATOR);
  20.104 +                    buf.append('/');
  20.105                  }
  20.106              } else {
  20.107 +                final String docroot = "{@docroot}";
  20.108                  // Search for lowercase version of {@docRoot}
  20.109 -                index = lowerHtml.indexOf("{@docroot}", previndex);
  20.110 +                index = lowerHtml.indexOf(docroot, previndex);
  20.111                  // If next {@docRoot} tag not found, append rest of htmlstr and exit loop
  20.112                  if (index < 0) {
  20.113                      buf.append(htmlstr.substring(previndex));
  20.114 @@ -192,13 +168,12 @@
  20.115                  }
  20.116                  // If next {@docroot} tag found, append htmlstr up to start of tag
  20.117                  buf.append(htmlstr.substring(previndex, index));
  20.118 -                previndex = index + 10;  // length for {@docroot} string
  20.119 +                previndex = index + docroot.length();
  20.120                  // Insert relative path where {@docRoot} was located
  20.121 -                buf.append(relativepathNoSlash);
  20.122 +                buf.append(pathToRoot.isEmpty() ? "." : pathToRoot.getPath());
  20.123                  // Append slash if next character is not a slash
  20.124 -                if (relativepathNoSlash.length() > 0 && previndex < htmlstr.length() &&
  20.125 -                        htmlstr.charAt(previndex) != '/') {
  20.126 -                    buf.append(DirectoryManager.URL_FILE_SEPARATOR);
  20.127 +                if (previndex < htmlstr.length() && htmlstr.charAt(previndex) != '/') {
  20.128 +                    buf.append('/');
  20.129                  }
  20.130              }
  20.131          }
  20.132 @@ -312,7 +287,7 @@
  20.133       */
  20.134      public Content getTargetPackageLink(PackageDoc pd, String target,
  20.135              Content label) {
  20.136 -        return getHyperLink(pathString(pd, "package-summary.html"), "", label, "", target);
  20.137 +        return getHyperLink(pathString(pd, DocPaths.PACKAGE_SUMMARY), "", label, "", target);
  20.138      }
  20.139  
  20.140      /**
  20.141 @@ -539,8 +514,8 @@
  20.142       * @return a content tree for the link
  20.143       */
  20.144      protected Content getNavLinkContents() {
  20.145 -        Content linkContent = getHyperLink(relativePath +
  20.146 -                "overview-summary.html", "", overviewLabel, "", "");
  20.147 +        Content linkContent = getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_SUMMARY),
  20.148 +                "", overviewLabel, "", "");
  20.149          Content li = HtmlTree.LI(linkContent);
  20.150          return li;
  20.151      }
  20.152 @@ -584,7 +559,7 @@
  20.153       * @param prev File name for the prev link
  20.154       * @return a content tree for the link
  20.155       */
  20.156 -    public Content getNavLinkPrevious(String prev) {
  20.157 +    public Content getNavLinkPrevious(DocPath prev) {
  20.158          Content li;
  20.159          if (prev != null) {
  20.160              li = HtmlTree.LI(getHyperLink(prev, "", prevLabel, "", ""));
  20.161 @@ -601,7 +576,7 @@
  20.162       * @param next File name for the next link
  20.163       * @return a content tree for the link
  20.164       */
  20.165 -    public Content getNavLinkNext(String next) {
  20.166 +    public Content getNavLinkNext(DocPath next) {
  20.167          Content li;
  20.168          if (next != null) {
  20.169              li = HtmlTree.LI(getHyperLink(next, "", nextLabel, "", ""));
  20.170 @@ -617,9 +592,9 @@
  20.171       * @param link File to be linked, "index.html"
  20.172       * @return a content tree for the link
  20.173       */
  20.174 -    protected Content getNavShowLists(String link) {
  20.175 -        Content framesContent = getHyperLink(link + "?" + path +
  20.176 -                filename, "", framesLabel, "", "_top");
  20.177 +    protected Content getNavShowLists(DocPath link) {
  20.178 +        Content framesContent = getHyperLink(link.getPath() + "?" + path.getPath(),
  20.179 +                "", framesLabel, "", "_top");
  20.180          Content li = HtmlTree.LI(framesContent);
  20.181          return li;
  20.182      }
  20.183 @@ -630,7 +605,7 @@
  20.184       * @return a content tree for the link
  20.185       */
  20.186      protected Content getNavShowLists() {
  20.187 -        return getNavShowLists(relativePath + "index.html");
  20.188 +        return getNavShowLists(pathToRoot.resolve(DocPaths.INDEX));
  20.189      }
  20.190  
  20.191      /**
  20.192 @@ -639,7 +614,7 @@
  20.193       * @param link File to be linked
  20.194       * @return a content tree for the link
  20.195       */
  20.196 -    protected Content getNavHideLists(String link) {
  20.197 +    protected Content getNavHideLists(DocPath link) {
  20.198          Content noFramesContent = getHyperLink(link, "", noframesLabel, "", "_top");
  20.199          Content li = HtmlTree.LI(noFramesContent);
  20.200          return li;
  20.201 @@ -658,10 +633,10 @@
  20.202          PackageDoc[] packages = configuration.root.specifiedPackages();
  20.203          if (packages.length == 1 && configuration.root.specifiedClasses().length == 0) {
  20.204              treeLinkContent = getHyperLink(pathString(packages[0],
  20.205 -                    "package-tree.html"), "", treeLabel,
  20.206 +                    DocPaths.PACKAGE_TREE), "", treeLabel,
  20.207                      "", "");
  20.208          } else {
  20.209 -            treeLinkContent = getHyperLink(relativePath + "overview-tree.html",
  20.210 +            treeLinkContent = getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE),
  20.211                      "", treeLabel, "", "");
  20.212          }
  20.213          Content li = HtmlTree.LI(treeLinkContent);
  20.214 @@ -675,7 +650,7 @@
  20.215       * @return a content tree for the link
  20.216       */
  20.217      protected Content getNavLinkMainTree(String label) {
  20.218 -        Content mainTreeContent = getHyperLink(relativePath + "overview-tree.html",
  20.219 +        Content mainTreeContent = getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE),
  20.220                  new StringContent(label));
  20.221          Content li = HtmlTree.LI(mainTreeContent);
  20.222          return li;
  20.223 @@ -697,8 +672,8 @@
  20.224       * @return a content tree for the link
  20.225       */
  20.226      protected Content getNavLinkDeprecated() {
  20.227 -        Content linkContent = getHyperLink(relativePath +
  20.228 -                "deprecated-list.html", "", deprecatedLabel, "", "");
  20.229 +        Content linkContent = getHyperLink(pathToRoot.resolve(DocPaths.DEPRECATED_LIST),
  20.230 +                "", deprecatedLabel, "", "");
  20.231          Content li = HtmlTree.LI(linkContent);
  20.232          return li;
  20.233      }
  20.234 @@ -711,8 +686,8 @@
  20.235       * @return a content tree for the link
  20.236       */
  20.237      protected Content getNavLinkClassIndex() {
  20.238 -        Content allClassesContent = getHyperLink(relativePath +
  20.239 -                AllClassesFrameWriter.OUTPUT_FILE_NAME_NOFRAMES, "",
  20.240 +        Content allClassesContent = getHyperLink(pathToRoot.resolve(
  20.241 +                DocPaths.ALLCLASSES_NOFRAME), "",
  20.242                  allclassesLabel, "", "");
  20.243          Content li = HtmlTree.LI(allClassesContent);
  20.244          return li;
  20.245 @@ -724,9 +699,10 @@
  20.246       * @return a content tree for the link
  20.247       */
  20.248      protected Content getNavLinkIndex() {
  20.249 -        Content linkContent = getHyperLink(relativePath +(configuration.splitindex?
  20.250 -            DirectoryManager.getPath("index-files") + fileseparator: "") +
  20.251 -            (configuration.splitindex?"index-1.html" : "index-all.html"), "",
  20.252 +        Content linkContent = getHyperLink(pathToRoot.resolve(
  20.253 +                (configuration.splitindex
  20.254 +                    ? DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1))
  20.255 +                    : DocPaths.INDEX_ALL)), "",
  20.256              indexLabel, "", "");
  20.257          Content li = HtmlTree.LI(linkContent);
  20.258          return li;
  20.259 @@ -740,16 +716,14 @@
  20.260       * @return a content tree for the link
  20.261       */
  20.262      protected Content getNavLinkHelp() {
  20.263 -        String helpfilenm = configuration.helpfile;
  20.264 -        if (helpfilenm.equals("")) {
  20.265 -            helpfilenm = "help-doc.html";
  20.266 +        String helpfile = configuration.helpfile;
  20.267 +        DocPath helpfilenm;
  20.268 +        if (helpfile.isEmpty()) {
  20.269 +            helpfilenm = DocPaths.HELP_DOC;
  20.270          } else {
  20.271 -            int lastsep;
  20.272 -            if ((lastsep = helpfilenm.lastIndexOf(File.separatorChar)) != -1) {
  20.273 -                helpfilenm = helpfilenm.substring(lastsep + 1);
  20.274 -            }
  20.275 +            helpfilenm = DocPath.create(new File(helpfile).getName());
  20.276          }
  20.277 -        Content linkContent = getHyperLink(relativePath + helpfilenm, "",
  20.278 +        Content linkContent = getHyperLink(pathToRoot.resolve(helpfilenm), "",
  20.279                  helpLabel, "", "");
  20.280          Content li = HtmlTree.LI(linkContent);
  20.281          return li;
  20.282 @@ -884,25 +858,13 @@
  20.283      }
  20.284  
  20.285      /**
  20.286 -     * Return path to the class page for a classdoc. For example, the class
  20.287 -     * name is "java.lang.Object" and if the current file getting generated is
  20.288 -     * "java/io/File.html", then the path string to the class, returned is
  20.289 -     * "../../java/lang.Object.html".
  20.290 -     *
  20.291 -     * @param cd Class to which the path is requested.
  20.292 -     */
  20.293 -    protected String pathToClass(ClassDoc cd) {
  20.294 -        return pathString(cd.containingPackage(), cd.name() + ".html");
  20.295 -    }
  20.296 -
  20.297 -    /**
  20.298       * Return the path to the class page for a classdoc. Works same as
  20.299       * {@link #pathToClass(ClassDoc)}.
  20.300       *
  20.301       * @param cd   Class to which the path is requested.
  20.302       * @param name Name of the file(doesn't include path).
  20.303       */
  20.304 -    protected String pathString(ClassDoc cd, String name) {
  20.305 +    protected DocPath pathString(ClassDoc cd, DocPath name) {
  20.306          return pathString(cd.containingPackage(), name);
  20.307      }
  20.308  
  20.309 @@ -915,10 +877,8 @@
  20.310       * @param pd Package in which the file name is assumed to be.
  20.311       * @param name File name, to which path string is.
  20.312       */
  20.313 -    protected String pathString(PackageDoc pd, String name) {
  20.314 -        StringBuilder buf = new StringBuilder(relativePath);
  20.315 -        buf.append(DirectoryManager.getPathToPackage(pd, name));
  20.316 -        return buf.toString();
  20.317 +    protected DocPath pathString(PackageDoc pd, DocPath name) {
  20.318 +        return pathToRoot.resolve(DocPath.forPackage(pd).resolve(name));
  20.319      }
  20.320  
  20.321      /**
  20.322 @@ -956,12 +916,12 @@
  20.323              }
  20.324          }
  20.325          if (included || pkg == null) {
  20.326 -            return getHyperLinkString(pathString(pkg, "package-summary.html"),
  20.327 +            return getHyperLinkString(pathString(pkg, DocPaths.PACKAGE_SUMMARY),
  20.328                                  "", label, isStrong, style);
  20.329          } else {
  20.330              String crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg));
  20.331              if (crossPkgLink != null) {
  20.332 -                return getHyperLinkString(crossPkgLink, "", label, isStrong, style);
  20.333 +                return getHyperLinkString(/*TEMP*/ DocPath.create(crossPkgLink), "", label, isStrong, style);
  20.334              } else {
  20.335                  return label;
  20.336              }
  20.337 @@ -987,12 +947,12 @@
  20.338              }
  20.339          }
  20.340          if (included || pkg == null) {
  20.341 -            return getHyperLink(pathString(pkg, "package-summary.html"),
  20.342 +            return getHyperLink(pathString(pkg, DocPaths.PACKAGE_SUMMARY),
  20.343                                  "", label);
  20.344          } else {
  20.345              String crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg));
  20.346              if (crossPkgLink != null) {
  20.347 -                return getHyperLink(crossPkgLink, "", label);
  20.348 +                return getHyperLink(/*TEMP*/ DocPath.create(crossPkgLink), "", label);
  20.349              } else {
  20.350                  return label;
  20.351              }
  20.352 @@ -1020,10 +980,10 @@
  20.353              //d must be a class doc since in has no containing class.
  20.354              cd = (ClassDoc) doc;
  20.355          }
  20.356 -        String href = relativePath + DocletConstants.SOURCE_OUTPUT_DIR_NAME
  20.357 -                + DirectoryManager.getDirectoryPath(cd.containingPackage())
  20.358 -                + cd.name() + ".html#" + SourceToHTMLConverter.getAnchorName(doc);
  20.359 -        Content linkContent = getHyperLink(href, "", label, "", "");
  20.360 +        DocPath href = pathToRoot
  20.361 +                .resolve(DocPaths.SOURCE_OUTPUT)
  20.362 +                .resolve(DocPath.forClass(cd));
  20.363 +        Content linkContent = getHyperLink(href, SourceToHTMLConverter.getAnchorName(doc), label, "", "");
  20.364          htmltree.addContent(linkContent);
  20.365      }
  20.366  
  20.367 @@ -1085,7 +1045,7 @@
  20.368                  //exists, but no way to determine if the external class exists.  We just
  20.369                  //have to assume that it does.
  20.370                  return getHyperLinkString(
  20.371 -                    configuration.extern.getExternalLink(packageName, relativePath,
  20.372 +                    configuration.extern.getExternalLink(packageName, pathToRoot,
  20.373                                  className + ".html?is-external=true"),
  20.374                      refMemName == null ? "" : refMemName,
  20.375                      label == null || label.length() == 0 ? defaultLabel : label,
  20.376 @@ -1105,7 +1065,7 @@
  20.377      }
  20.378  
  20.379      public String getCrossPackageLink(String pkgName) {
  20.380 -        return configuration.extern.getExternalLink(pkgName, relativePath,
  20.381 +        return configuration.extern.getExternalLink(pkgName, pathToRoot,
  20.382              "package-summary.html?is-external=true");
  20.383      }
  20.384  
  20.385 @@ -1321,7 +1281,7 @@
  20.386                  String classCrossLink, packageCrossLink = getCrossPackageLink(refClassName);
  20.387                  if (packageCrossLink != null) {
  20.388                      //Package cross link found
  20.389 -                    return getHyperLinkString(packageCrossLink, "",
  20.390 +                    return getHyperLinkString(/*TEMP*/ DocPath.create(packageCrossLink), "",
  20.391                          (label.isEmpty() ? text : label), false);
  20.392                  } else if ((classCrossLink = getCrossClassLink(refClassName,
  20.393                          refMemName, label, false, "", !plain)) != null) {
  20.394 @@ -1450,7 +1410,7 @@
  20.395       * @param doc the doc for which the comment tags will be generated
  20.396       * @param tags the first sentence tags for the doc
  20.397       * @param depr true if it is deprecated
  20.398 -     * @param first true if the first sentenge tags should be added
  20.399 +     * @param first true if the first sentence tags should be added
  20.400       * @param htmltree the documentation tree to which the comment tags will be added
  20.401       */
  20.402      private void addCommentTags(Doc doc, Tag[] tags, boolean depr,
  20.403 @@ -1561,7 +1521,7 @@
  20.404  
  20.405      /**
  20.406       * Suppose a piece of documentation has a relative link.  When you copy
  20.407 -     * that documetation to another place such as the index or class-use page,
  20.408 +     * that documentation to another place such as the index or class-use page,
  20.409       * that relative link will no longer work.  We should redirect those links
  20.410       * so that they will work again.
  20.411       * <p>
  20.412 @@ -1587,21 +1547,17 @@
  20.413              return text;
  20.414          }
  20.415  
  20.416 -        String redirectPathFromRoot;
  20.417 +        DocPath redirectPathFromRoot;
  20.418          if (doc instanceof ClassDoc) {
  20.419 -            redirectPathFromRoot = DirectoryManager.getDirectoryPath(((ClassDoc) doc).containingPackage());
  20.420 +            redirectPathFromRoot = DocPath.forPackage(((ClassDoc) doc).containingPackage());
  20.421          } else if (doc instanceof MemberDoc) {
  20.422 -            redirectPathFromRoot = DirectoryManager.getDirectoryPath(((MemberDoc) doc).containingPackage());
  20.423 +            redirectPathFromRoot = DocPath.forPackage(((MemberDoc) doc).containingPackage());
  20.424          } else if (doc instanceof PackageDoc) {
  20.425 -            redirectPathFromRoot = DirectoryManager.getDirectoryPath((PackageDoc) doc);
  20.426 +            redirectPathFromRoot = DocPath.forPackage((PackageDoc) doc);
  20.427          } else {
  20.428              return text;
  20.429          }
  20.430  
  20.431 -        if (! redirectPathFromRoot.endsWith(DirectoryManager.URL_FILE_SEPARATOR)) {
  20.432 -            redirectPathFromRoot += DirectoryManager.URL_FILE_SEPARATOR;
  20.433 -        }
  20.434 -
  20.435          //Redirect all relative links.
  20.436          int end, begin = text.toLowerCase().indexOf("<a");
  20.437          if(begin >= 0){
  20.438 @@ -1627,22 +1583,21 @@
  20.439                      //might be missing '>' character because the href has an inline tag.
  20.440                      break;
  20.441                  }
  20.442 -                if(textBuff.substring(begin, end).indexOf("\"") != -1){
  20.443 +                if (textBuff.substring(begin, end).indexOf("\"") != -1){
  20.444                      begin = textBuff.indexOf("\"", begin) + 1;
  20.445                      end = textBuff.indexOf("\"", begin +1);
  20.446 -                    if(begin == 0 || end == -1){
  20.447 +                    if (begin == 0 || end == -1){
  20.448                          //Link is missing a quote.
  20.449                          break;
  20.450                      }
  20.451                  }
  20.452                  String relativeLink = textBuff.substring(begin, end);
  20.453 -                if(!(relativeLink.toLowerCase().startsWith("mailto:") ||
  20.454 -                     relativeLink.toLowerCase().startsWith("http:") ||
  20.455 -                     relativeLink.toLowerCase().startsWith("https:") ||
  20.456 -                     relativeLink.toLowerCase().startsWith("file:"))){
  20.457 -                     relativeLink = "{@"+(new DocRootTaglet()).getName() + "}"
  20.458 -                        + redirectPathFromRoot
  20.459 -                        + relativeLink;
  20.460 +                if (!(relativeLink.toLowerCase().startsWith("mailto:") ||
  20.461 +                        relativeLink.toLowerCase().startsWith("http:") ||
  20.462 +                        relativeLink.toLowerCase().startsWith("https:") ||
  20.463 +                        relativeLink.toLowerCase().startsWith("file:"))) {
  20.464 +                    relativeLink = "{@"+(new DocRootTaglet()).getName() + "}/"
  20.465 +                        + redirectPathFromRoot.resolve(relativeLink).getPath();
  20.466                      textBuff.replace(begin, end, relativeLink);
  20.467                  }
  20.468                  begin = textBuff.toString().toLowerCase().indexOf("<a", begin + 1);
  20.469 @@ -1715,17 +1670,15 @@
  20.470       */
  20.471      public HtmlTree getStyleSheetProperties() {
  20.472          String filename = configuration.stylesheetfile;
  20.473 +        DocPath stylesheet;
  20.474          if (filename.length() > 0) {
  20.475 -            File stylefile = new File(filename);
  20.476 -            String parent = stylefile.getParent();
  20.477 -            filename = (parent == null)?
  20.478 -                filename:
  20.479 -                filename.substring(parent.length() + 1);
  20.480 +            stylesheet = DocPath.create(new File(filename).getName());
  20.481          } else {
  20.482 -            filename = "stylesheet.css";
  20.483 +            stylesheet = DocPaths.STYLESHEET;
  20.484          }
  20.485 -        filename = relativePath + filename;
  20.486 -        HtmlTree link = HtmlTree.LINK("stylesheet", "text/css", filename, "Style");
  20.487 +        HtmlTree link = HtmlTree.LINK("stylesheet", "text/css",
  20.488 +                pathToRoot.resolve(stylesheet).getPath(),
  20.489 +                "Style");
  20.490          return link;
  20.491      }
  20.492  
    21.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java	Wed Oct 17 16:43:26 2012 +0100
    21.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java	Tue Oct 23 13:20:37 2012 -0700
    21.3 @@ -78,9 +78,9 @@
    21.4          LinkOutputImpl linkOutput = new LinkOutputImpl();
    21.5          if (classDoc.isIncluded()) {
    21.6              if (configuration.isGeneratedDoc(classDoc)) {
    21.7 -                String filename = pathString(classLinkInfo);
    21.8 +                DocPath filename = getPath(classLinkInfo);
    21.9                  if (linkInfo.linkToSelf ||
   21.10 -                                !(linkInfo.classDoc.name() + ".html").equals(m_writer.filename)) {
   21.11 +                                !(DocPath.forName(classDoc)).equals(m_writer.filename)) {
   21.12                          linkOutput.append(m_writer.getHyperLinkString(filename,
   21.13                              classLinkInfo.where, label.toString(),
   21.14                              classLinkInfo.isStrong, classLinkInfo.styleName,
   21.15 @@ -161,16 +161,12 @@
   21.16       *
   21.17       * @param linkInfo the information about the link.
   21.18       */
   21.19 -    private String pathString(LinkInfoImpl linkInfo) {
   21.20 +    private DocPath getPath(LinkInfoImpl linkInfo) {
   21.21          if (linkInfo.context == LinkInfoImpl.PACKAGE_FRAME) {
   21.22              //Not really necessary to do this but we want to be consistent
   21.23              //with 1.4.2 output.
   21.24 -            return linkInfo.classDoc.name() + ".html";
   21.25 +            return DocPath.forName(linkInfo.classDoc);
   21.26          }
   21.27 -        StringBuilder buf = new StringBuilder(m_writer.relativePath);
   21.28 -        buf.append(DirectoryManager.getPathToPackage(
   21.29 -            linkInfo.classDoc.containingPackage(),
   21.30 -            linkInfo.classDoc.name() + ".html"));
   21.31 -        return buf.toString();
   21.32 +        return m_writer.pathToRoot.resolve(DocPath.forClass(linkInfo.classDoc));
   21.33      }
   21.34  }
    22.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java	Wed Oct 17 16:43:26 2012 +0100
    22.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java	Tue Oct 23 13:20:37 2012 -0700
    22.3 @@ -400,7 +400,7 @@
    22.4       */
    22.5      protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
    22.6          if (link) {
    22.7 -            return writer.getHyperLink("", (cd == null)?
    22.8 +            return writer.getHyperLink((cd == null)?
    22.9                  "method_summary":
   22.10                  "methods_inherited_from_class_" +
   22.11                  configuration().getClassName(cd),
   22.12 @@ -415,7 +415,7 @@
   22.13       */
   22.14      protected void addNavDetailLink(boolean link, Content liNav) {
   22.15          if (link) {
   22.16 -            liNav.addContent(writer.getHyperLink("", "method_detail",
   22.17 +            liNav.addContent(writer.getHyperLink("method_detail",
   22.18                      writer.getResource("doclet.navMethod")));
   22.19          } else {
   22.20              liNav.addContent(writer.getResource("doclet.navMethod"));
    23.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java	Wed Oct 17 16:43:26 2012 +0100
    23.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java	Tue Oct 23 13:20:37 2012 -0700
    23.3 @@ -203,9 +203,8 @@
    23.4       */
    23.5      protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
    23.6          if (link) {
    23.7 -            return writer.getHyperLink("", (cd == null) ? "nested_class_summary":
    23.8 -                "nested_classes_inherited_from_class_" +
    23.9 -                cd.qualifiedName(),
   23.10 +            return writer.getHyperLink((cd == null) ? "nested_class_summary":
   23.11 +                "nested_classes_inherited_from_class_" + cd.qualifiedName(),
   23.12                  writer.getResource("doclet.navNested"));
   23.13          } else {
   23.14              return writer.getResource("doclet.navNested");
    24.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java	Wed Oct 17 16:43:26 2012 +0100
    24.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java	Tue Oct 23 13:20:37 2012 -0700
    24.3 @@ -60,17 +60,12 @@
    24.4      private Set<ClassDoc> documentedClasses;
    24.5  
    24.6      /**
    24.7 -     * The name of the output file.
    24.8 -     */
    24.9 -    public static final String OUTPUT_FILE_NAME = "package-frame.html";
   24.10 -
   24.11 -    /**
   24.12       * Constructor to construct PackageFrameWriter object and to generate
   24.13       * "package-frame.html" file in the respective package directory.
   24.14       * For example for package "java.lang" this will generate file
   24.15       * "package-frame.html" file in the "java/lang" directory. It will also
   24.16       * create "java/lang" directory in the current or the destination directory
   24.17 -     * if it doesen't exist.
   24.18 +     * if it doesn't exist.
   24.19       *
   24.20       * @param configuration the configuration of the doclet.
   24.21       * @param packageDoc PackageDoc under consideration.
   24.22 @@ -78,7 +73,7 @@
   24.23      public PackageFrameWriter(ConfigurationImpl configuration,
   24.24                                PackageDoc packageDoc)
   24.25                                throws IOException {
   24.26 -        super(configuration, DirectoryManager.getDirectoryPath(packageDoc), OUTPUT_FILE_NAME, DirectoryManager.getRelativePath(packageDoc));
   24.27 +        super(configuration, DocPath.forPackage(packageDoc).resolve(DocPaths.PACKAGE_FRAME));
   24.28          this.packageDoc = packageDoc;
   24.29          if (configuration.root.specifiedPackages().length == 0) {
   24.30              documentedClasses = new HashSet<ClassDoc>(Arrays.asList(configuration.root.classes()));
   24.31 @@ -113,7 +108,7 @@
   24.32          } catch (IOException exc) {
   24.33              configuration.standardmessage.error(
   24.34                      "doclet.exception_encountered",
   24.35 -                    exc.toString(), OUTPUT_FILE_NAME);
   24.36 +                    exc.toString(), DocPaths.PACKAGE_FRAME.getPath());
   24.37              throw new DocletAbortException();
   24.38          }
   24.39      }
    25.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java	Wed Oct 17 16:43:26 2012 +0100
    25.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java	Tue Oct 23 13:20:37 2012 -0700
    25.3 @@ -52,7 +52,7 @@
    25.4       * @param filename Name of the package index file to be generated.
    25.5       */
    25.6      public PackageIndexFrameWriter(ConfigurationImpl configuration,
    25.7 -                                   String filename) throws IOException {
    25.8 +                                   DocPath filename) throws IOException {
    25.9          super(configuration, filename);
   25.10      }
   25.11  
   25.12 @@ -62,7 +62,7 @@
   25.13       */
   25.14      public static void generate(ConfigurationImpl configuration) {
   25.15          PackageIndexFrameWriter packgen;
   25.16 -        String filename = "overview-frame.html";
   25.17 +        DocPath filename = DocPaths.OVERVIEW_FRAME;
   25.18          try {
   25.19              packgen = new PackageIndexFrameWriter(configuration, filename);
   25.20              packgen.buildPackageIndexFile("doclet.Window_Overview", false);
   25.21 @@ -109,11 +109,11 @@
   25.22          if (pd.name().length() > 0) {
   25.23              packageLabel = getPackageLabel(pd.name());
   25.24              packageLinkContent = getHyperLink(pathString(pd,
   25.25 -                    "package-frame.html"), "", packageLabel, "",
   25.26 +                     DocPaths.PACKAGE_FRAME), "", packageLabel, "",
   25.27                      "packageFrame");
   25.28          } else {
   25.29              packageLabel = new RawHtml("&lt;unnamed package&gt;");
   25.30 -            packageLinkContent = getHyperLink("package-frame.html",
   25.31 +            packageLinkContent = getHyperLink(DocPaths.PACKAGE_FRAME,
   25.32                      "", packageLabel, "", "packageFrame");
   25.33          }
   25.34          Content li = HtmlTree.LI(packageLinkContent);
   25.35 @@ -148,7 +148,7 @@
   25.36       * @param body the Content object to which the all classes link should be added
   25.37       */
   25.38      protected void addAllClassesLink(Content body) {
   25.39 -        Content linkContent = getHyperLink("allclasses-frame.html", "",
   25.40 +        Content linkContent = getHyperLink(DocPaths.ALLCLASSES_FRAME, "",
   25.41                  allclassesLabel, "", "packageFrame");
   25.42          Content div = HtmlTree.DIV(HtmlStyle.indexHeader, linkContent);
   25.43          body.addContent(div);
    26.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java	Wed Oct 17 16:43:26 2012 +0100
    26.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java	Tue Oct 23 13:20:37 2012 -0700
    26.3 @@ -36,7 +36,7 @@
    26.4  /**
    26.5   * Generate the package index page "overview-summary.html" for the right-hand
    26.6   * frame. A click on the package name on this page will update the same frame
    26.7 - * with the "pacakge-summary.html" file for the clicked package.
    26.8 + * with the "package-summary.html" file for the clicked package.
    26.9   *
   26.10   *  <p><b>This is NOT part of any supported API.
   26.11   *  If you write code that depends on this, you do so at your own risk.
   26.12 @@ -73,7 +73,7 @@
   26.13       * @see Group
   26.14       */
   26.15      public PackageIndexWriter(ConfigurationImpl configuration,
   26.16 -                              String filename)
   26.17 +                              DocPath filename)
   26.18                         throws IOException {
   26.19          super(configuration, filename);
   26.20          this.root = configuration.root;
   26.21 @@ -88,7 +88,7 @@
   26.22       */
   26.23      public static void generate(ConfigurationImpl configuration) {
   26.24          PackageIndexWriter packgen;
   26.25 -        String filename = "overview-summary.html";
   26.26 +        DocPath filename = DocPaths.OVERVIEW_SUMMARY;
   26.27          try {
   26.28              packgen = new PackageIndexWriter(configuration, filename);
   26.29              packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", true);
    27.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java	Wed Oct 17 16:43:26 2012 +0100
    27.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java	Tue Oct 23 13:20:37 2012 -0700
    27.3 @@ -67,15 +67,14 @@
    27.4       * @throws DocletAbortException
    27.5       */
    27.6      public PackageTreeWriter(ConfigurationImpl configuration,
    27.7 -                             String path, String filename,
    27.8 +                             DocPath path,
    27.9                               PackageDoc packagedoc,
   27.10                               PackageDoc prev, PackageDoc next)
   27.11                        throws IOException {
   27.12 -        super(configuration, path, filename,
   27.13 +        super(configuration, path,
   27.14                new ClassTree(
   27.15                  configuration.classDocCatalog.allClasses(packagedoc),
   27.16 -                configuration),
   27.17 -              packagedoc);
   27.18 +                configuration));
   27.19          this.packagedoc = packagedoc;
   27.20          this.prev = prev;
   27.21          this.next = next;
   27.22 @@ -96,17 +95,16 @@
   27.23                                  PackageDoc pkg, PackageDoc prev,
   27.24                                  PackageDoc next, boolean noDeprecated) {
   27.25          PackageTreeWriter packgen;
   27.26 -        String path = DirectoryManager.getDirectoryPath(pkg);
   27.27 -        String filename = "package-tree.html";
   27.28 +        DocPath path = DocPath.forPackage(pkg).resolve(DocPaths.PACKAGE_TREE);
   27.29          try {
   27.30 -            packgen = new PackageTreeWriter(configuration, path, filename, pkg,
   27.31 +            packgen = new PackageTreeWriter(configuration, path, pkg,
   27.32                  prev, next);
   27.33              packgen.generatePackageTreeFile();
   27.34              packgen.close();
   27.35          } catch (IOException exc) {
   27.36              configuration.standardmessage.error(
   27.37                          "doclet.exception_encountered",
   27.38 -                        exc.toString(), filename);
   27.39 +                        exc.toString(), path.getPath());
   27.40              throw new DocletAbortException();
   27.41          }
   27.42      }
   27.43 @@ -175,9 +173,8 @@
   27.44          if (prev == null) {
   27.45              return getNavLinkPrevious(null);
   27.46          } else {
   27.47 -            String path = DirectoryManager.getRelativePath(packagedoc.name(),
   27.48 -                    prev.name());
   27.49 -            return getNavLinkPrevious(path + "package-tree.html");
   27.50 +            DocPath path = DocPath.relativePath(packagedoc, prev);
   27.51 +            return getNavLinkPrevious(path.resolve(DocPaths.PACKAGE_TREE));
   27.52          }
   27.53      }
   27.54  
   27.55 @@ -190,9 +187,8 @@
   27.56          if (next == null) {
   27.57              return getNavLinkNext(null);
   27.58          } else {
   27.59 -            String path = DirectoryManager.getRelativePath(packagedoc.name(),
   27.60 -                    next.name());
   27.61 -            return getNavLinkNext(path + "package-tree.html");
   27.62 +            DocPath path = DocPath.relativePath(packagedoc, next);
   27.63 +            return getNavLinkNext(path.resolve(DocPaths.PACKAGE_TREE));
   27.64          }
   27.65      }
   27.66  
   27.67 @@ -202,7 +198,7 @@
   27.68       * @return a content tree for the package link
   27.69       */
   27.70      protected Content getNavLinkPackage() {
   27.71 -        Content linkContent = getHyperLink("package-summary.html", "",
   27.72 +        Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY, "",
   27.73                  packageLabel);
   27.74          Content li = HtmlTree.LI(linkContent);
   27.75          return li;
    28.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java	Wed Oct 17 16:43:26 2012 +0100
    28.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java	Tue Oct 23 13:20:37 2012 -0700
    28.3 @@ -57,11 +57,9 @@
    28.4       * @throws DocletAbortException
    28.5       */
    28.6      public PackageUseWriter(ConfigurationImpl configuration,
    28.7 -                            ClassUseMapper mapper, String filename,
    28.8 +                            ClassUseMapper mapper, DocPath filename,
    28.9                              PackageDoc pkgdoc) throws IOException {
   28.10 -        super(configuration, DirectoryManager.getDirectoryPath(pkgdoc),
   28.11 -              filename,
   28.12 -              DirectoryManager.getRelativePath(pkgdoc.name()));
   28.13 +        super(configuration, DocPath.forPackage(pkgdoc).resolve(filename));
   28.14          this.pkgdoc = pkgdoc;
   28.15  
   28.16          // by examining all classes in this package, find what packages
   28.17 @@ -98,7 +96,7 @@
   28.18      public static void generate(ConfigurationImpl configuration,
   28.19                                  ClassUseMapper mapper, PackageDoc pkgdoc) {
   28.20          PackageUseWriter pkgusegen;
   28.21 -        String filename = "package-use.html";
   28.22 +        DocPath filename = DocPaths.PACKAGE_USE;
   28.23          try {
   28.24              pkgusegen = new PackageUseWriter(configuration,
   28.25                                               mapper, filename, pkgdoc);
   28.26 @@ -232,8 +230,8 @@
   28.27       */
   28.28      protected void addClassRow(ClassDoc usedClass, String packageName,
   28.29              Content contentTree) {
   28.30 -        String path = pathString(usedClass,
   28.31 -                "class-use/" + usedClass.name() + ".html");
   28.32 +        DocPath path = pathString(usedClass,
   28.33 +                DocPaths.CLASS_USE.resolve(DocPath.forName(usedClass)));
   28.34          Content td = HtmlTree.TD(HtmlStyle.colOne,
   28.35                  getHyperLink(path, packageName, new StringContent(usedClass.name())));
   28.36          addIndexComment(usedClass, td);
   28.37 @@ -248,7 +246,7 @@
   28.38       */
   28.39      protected void addPackageUse(PackageDoc pkg, Content contentTree) throws IOException {
   28.40          Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst,
   28.41 -                getHyperLink("", Util.getPackageName(pkg),
   28.42 +                getHyperLink(Util.getPackageName(pkg),
   28.43                  new RawHtml(Util.getPackageName(pkg))));
   28.44          contentTree.addContent(tdFirst);
   28.45          HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
   28.46 @@ -288,7 +286,7 @@
   28.47       * @return a content tree for the package link
   28.48       */
   28.49      protected Content getNavLinkPackage() {
   28.50 -        Content linkContent = getHyperLink("package-summary.html", "",
   28.51 +        Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY, "",
   28.52                  packageLabel);
   28.53          Content li = HtmlTree.LI(linkContent);
   28.54          return li;
   28.55 @@ -310,7 +308,7 @@
   28.56       * @return a content tree for the tree link
   28.57       */
   28.58      protected Content getNavLinkTree() {
   28.59 -        Content linkContent = getHyperLink("package-tree.html", "",
   28.60 +        Content linkContent = getHyperLink(DocPaths.PACKAGE_TREE, "",
   28.61                  treeLabel);
   28.62          Content li = HtmlTree.LI(linkContent);
   28.63          return li;
    29.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java	Wed Oct 17 16:43:26 2012 +0100
    29.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java	Tue Oct 23 13:20:37 2012 -0700
    29.3 @@ -65,17 +65,12 @@
    29.4      protected PackageDoc packageDoc;
    29.5  
    29.6      /**
    29.7 -     * The name of the output file.
    29.8 -     */
    29.9 -    private static final String OUTPUT_FILE_NAME = "package-summary.html";
   29.10 -
   29.11 -    /**
   29.12       * Constructor to construct PackageWriter object and to generate
   29.13       * "package-summary.html" file in the respective package directory.
   29.14       * For example for package "java.lang" this will generate file
   29.15       * "package-summary.html" file in the "java/lang" directory. It will also
   29.16       * create "java/lang" directory in the current or the destination directory
   29.17 -     * if it doesen't exist.
   29.18 +     * if it doesn't exist.
   29.19       *
   29.20       * @param configuration the configuration of the doclet.
   29.21       * @param packageDoc    PackageDoc under consideration.
   29.22 @@ -83,25 +78,15 @@
   29.23       * @param next            Next package in the sorted array.
   29.24       */
   29.25      public PackageWriterImpl(ConfigurationImpl configuration,
   29.26 -        PackageDoc packageDoc, PackageDoc prev, PackageDoc next)
   29.27 -    throws IOException {
   29.28 -        super(configuration, DirectoryManager.getDirectoryPath(packageDoc), OUTPUT_FILE_NAME,
   29.29 -             DirectoryManager.getRelativePath(packageDoc.name()));
   29.30 +            PackageDoc packageDoc, PackageDoc prev, PackageDoc next)
   29.31 +            throws IOException {
   29.32 +        super(configuration, DocPath.forPackage(packageDoc).resolve(DocPaths.PACKAGE_SUMMARY));
   29.33          this.prev = prev;
   29.34          this.next = next;
   29.35          this.packageDoc = packageDoc;
   29.36      }
   29.37  
   29.38      /**
   29.39 -     * Return the name of the output file.
   29.40 -     *
   29.41 -     * @return the name of the output file.
   29.42 -     */
   29.43 -    public String getOutputFileName() {
   29.44 -        return OUTPUT_FILE_NAME;
   29.45 -    }
   29.46 -
   29.47 -    /**
   29.48       * {@inheritDoc}
   29.49       */
   29.50      public Content getPackageHeader(String heading) {
   29.51 @@ -265,7 +250,7 @@
   29.52       * @return a content tree for the class use link
   29.53       */
   29.54      protected Content getNavLinkClassUse() {
   29.55 -        Content useLink = getHyperLink("package-use.html", "",
   29.56 +        Content useLink = getHyperLink(DocPaths.PACKAGE_USE, "",
   29.57                  useLabel, "", "");
   29.58          Content li = HtmlTree.LI(useLink);
   29.59          return li;
   29.60 @@ -281,9 +266,8 @@
   29.61          if (prev == null) {
   29.62              li = HtmlTree.LI(prevpackageLabel);
   29.63          } else {
   29.64 -            String path = DirectoryManager.getRelativePath(packageDoc.name(),
   29.65 -                                                           prev.name());
   29.66 -            li = HtmlTree.LI(getHyperLink(path + "package-summary.html", "",
   29.67 +            DocPath path = DocPath.relativePath(packageDoc, prev);
   29.68 +            li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.PACKAGE_SUMMARY), "",
   29.69                  prevpackageLabel, "", ""));
   29.70          }
   29.71          return li;
   29.72 @@ -299,9 +283,8 @@
   29.73          if (next == null) {
   29.74              li = HtmlTree.LI(nextpackageLabel);
   29.75          } else {
   29.76 -            String path = DirectoryManager.getRelativePath(packageDoc.name(),
   29.77 -                                                           next.name());
   29.78 -            li = HtmlTree.LI(getHyperLink(path + "package-summary.html", "",
   29.79 +            DocPath path = DocPath.relativePath(packageDoc, next);
   29.80 +            li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.PACKAGE_SUMMARY), "",
   29.81                  nextpackageLabel, "", ""));
   29.82          }
   29.83          return li;
   29.84 @@ -314,7 +297,7 @@
   29.85       * @return a content tree for the tree link
   29.86       */
   29.87      protected Content getNavLinkTree() {
   29.88 -        Content useLink = getHyperLink("package-tree.html", "",
   29.89 +        Content useLink = getHyperLink(DocPaths.PACKAGE_TREE, "",
   29.90                  treeLabel, "", "");
   29.91          Content li = HtmlTree.LI(useLink);
   29.92          return li;
    30.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java	Wed Oct 17 16:43:26 2012 +0100
    30.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java	Tue Oct 23 13:20:37 2012 -0700
    30.3 @@ -29,6 +29,7 @@
    30.4  import com.sun.javadoc.*;
    30.5  import com.sun.tools.doclets.formats.html.markup.*;
    30.6  import com.sun.tools.doclets.internal.toolkit.*;
    30.7 +import com.sun.tools.doclets.internal.toolkit.util.DocPaths;
    30.8  import com.sun.tools.doclets.internal.toolkit.util.DocletAbortException;
    30.9  
   30.10  /**
   30.11 @@ -44,14 +45,12 @@
   30.12  public class SerializedFormWriterImpl extends SubWriterHolderWriter
   30.13      implements SerializedFormWriter {
   30.14  
   30.15 -    private static final String FILE_NAME = "serialized-form.html";
   30.16 -
   30.17      /**
   30.18       * @throws IOException
   30.19       * @throws DocletAbortException
   30.20       */
   30.21      public SerializedFormWriterImpl() throws IOException {
   30.22 -        super(ConfigurationImpl.getInstance(), FILE_NAME);
   30.23 +        super(ConfigurationImpl.getInstance(), DocPaths.SERIALIZED_FORM);
   30.24      }
   30.25  
   30.26      /**
    31.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/SingleIndexWriter.java	Wed Oct 17 16:43:26 2012 +0100
    31.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/SingleIndexWriter.java	Tue Oct 23 13:20:37 2012 -0700
    31.3 @@ -55,11 +55,9 @@
    31.4       * @param indexbuilder Unicode based Index from {@link IndexBuilder}
    31.5       */
    31.6      public SingleIndexWriter(ConfigurationImpl configuration,
    31.7 -                             String filename,
    31.8 +                             DocPath filename,
    31.9                               IndexBuilder indexbuilder) throws IOException {
   31.10          super(configuration, filename, indexbuilder);
   31.11 -        relativepathNoSlash = ".";
   31.12 -        relativePath = "./";
   31.13      }
   31.14  
   31.15      /**
   31.16 @@ -71,7 +69,7 @@
   31.17      public static void generate(ConfigurationImpl configuration,
   31.18                                  IndexBuilder indexbuilder) {
   31.19          SingleIndexWriter indexgen;
   31.20 -        String filename = "index-all.html";
   31.21 +        DocPath filename = DocPaths.INDEX_ALL;
   31.22          try {
   31.23              indexgen = new SingleIndexWriter(configuration,
   31.24                                               filename, indexbuilder);
   31.25 @@ -117,7 +115,7 @@
   31.26          for (int i = 0; i < indexbuilder.elements().length; i++) {
   31.27              String unicode = (indexbuilder.elements())[i].toString();
   31.28              contentTree.addContent(
   31.29 -                    getHyperLink("#_" + unicode + "_", new StringContent(unicode)));
   31.30 +                    getHyperLink("_" + unicode + "_", new StringContent(unicode)));
   31.31              contentTree.addContent(getSpace());
   31.32          }
   31.33      }
    32.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java	Wed Oct 17 16:43:26 2012 +0100
    32.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java	Tue Oct 23 13:20:37 2012 -0700
    32.3 @@ -62,7 +62,7 @@
    32.4       * Relative path from the documentation root to the file that is being
    32.5       * generated.
    32.6       */
    32.7 -    private static String relativePath = "";
    32.8 +    private static DocPath relativePath = DocPath.empty;
    32.9  
   32.10      /**
   32.11       * Source is converted to HTML using static methods below.
   32.12 @@ -77,7 +77,7 @@
   32.13       * @param outputdir the name of the directory to output to.
   32.14       */
   32.15      public static void convertRoot(ConfigurationImpl configuration, RootDoc rd,
   32.16 -            String outputdir) {
   32.17 +            DocPath outputdir) {
   32.18          if (rd == null || outputdir == null) {
   32.19              return;
   32.20          }
   32.21 @@ -108,11 +108,11 @@
   32.22       * @param outputdir the name of the directory to output to.
   32.23       */
   32.24      public static void convertPackage(ConfigurationImpl configuration, PackageDoc pd,
   32.25 -            String outputdir) {
   32.26 +            DocPath outputdir) {
   32.27          if (pd == null || outputdir == null) {
   32.28              return;
   32.29          }
   32.30 -        String classOutputdir = getPackageOutputDir(outputdir, pd);
   32.31 +        DocPath classOutputdir = getPackageOutputDir(outputdir, pd);
   32.32          ClassDoc[] cds = pd.allClasses();
   32.33          for (int i = 0; i < cds.length; i++) {
   32.34              // If -nodeprecated option is set and the class is marked as deprecated,
   32.35 @@ -131,9 +131,8 @@
   32.36       * @param pd the Package to generate output for.
   32.37       * @return the package output directory as a String.
   32.38       */
   32.39 -    private static String getPackageOutputDir(String outputDir, PackageDoc pd) {
   32.40 -        return outputDir + File.separator +
   32.41 -            DirectoryManager.getDirectoryPath(pd) + File.separator;
   32.42 +    private static DocPath getPackageOutputDir(DocPath outputDir, PackageDoc pd) {
   32.43 +        return outputDir.resolve(DocPath.forPackage(pd));
   32.44      }
   32.45  
   32.46      /**
   32.47 @@ -144,7 +143,7 @@
   32.48       * @param outputdir the name of the directory to output to.
   32.49       */
   32.50      public static void convertClass(ConfigurationImpl configuration, ClassDoc cd,
   32.51 -            String outputdir) {
   32.52 +            DocPath outputdir) {
   32.53          if (cd == null || outputdir == null) {
   32.54              return;
   32.55          }
   32.56 @@ -168,8 +167,9 @@
   32.57              LineNumberReader reader = new LineNumberReader(r);
   32.58              int lineno = 1;
   32.59              String line;
   32.60 -            relativePath = DirectoryManager.getRelativePath(DocletConstants.SOURCE_OUTPUT_DIR_NAME) +
   32.61 -                    DirectoryManager.getRelativePath(cd.containingPackage());
   32.62 +            relativePath = DocPaths.SOURCE_OUTPUT
   32.63 +                    .resolve(DocPath.forPackage(cd))
   32.64 +                    .invert();
   32.65              Content body = getHeader();
   32.66              Content pre = new HtmlTree(HtmlTag.PRE);
   32.67              try {
   32.68 @@ -198,7 +198,7 @@
   32.69       * @param className the name of the class that I am converting to HTML.
   32.70       * @param configuration the Doclet configuration to pass notices to.
   32.71       */
   32.72 -    private static void writeToFile(Content body, String outputDir,
   32.73 +    private static void writeToFile(Content body, DocPath outputDir,
   32.74              String className, ConfigurationImpl configuration) throws IOException {
   32.75          Content htmlDocType = DocType.Transitional();
   32.76          Content head = new HtmlTree(HtmlTag.HEAD);
   32.77 @@ -208,7 +208,7 @@
   32.78          Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
   32.79                  head, body);
   32.80          Content htmlDocument = new HtmlDocument(htmlDocType, htmlTree);
   32.81 -        File dir = new File(outputDir);
   32.82 +        File dir = outputDir.resolveAgainst(configuration.destDirName);
   32.83          dir.mkdirs();
   32.84          File newFile = new File(dir, className + ".html");
   32.85          configuration.message.notice("doclet.Generating_0", newFile.getPath());
   32.86 @@ -227,17 +227,14 @@
   32.87       */
   32.88      public static HtmlTree getStyleSheetProperties(ConfigurationImpl configuration) {
   32.89          String filename = configuration.stylesheetfile;
   32.90 +        DocPath stylesheet;
   32.91          if (filename.length() > 0) {
   32.92 -            File stylefile = new File(filename);
   32.93 -            String parent = stylefile.getParent();
   32.94 -            filename = (parent == null)?
   32.95 -                filename:
   32.96 -                filename.substring(parent.length() + 1);
   32.97 +            stylesheet = DocPath.create(new File(filename).getName());
   32.98          } else {
   32.99 -            filename = "stylesheet.css";
  32.100 +            stylesheet = DocPaths.STYLESHEET;
  32.101          }
  32.102 -        filename = relativePath + filename;
  32.103 -        HtmlTree link = HtmlTree.LINK("stylesheet", "text/css", filename, "Style");
  32.104 +        DocPath p = relativePath.resolve(stylesheet);
  32.105 +        HtmlTree link = HtmlTree.LINK("stylesheet", "text/css", p.getPath(), "Style");
  32.106          return link;
  32.107      }
  32.108  
    33.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/SplitIndexWriter.java	Wed Oct 17 16:43:26 2012 +0100
    33.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/SplitIndexWriter.java	Tue Oct 23 13:20:37 2012 -0700
    33.3 @@ -67,10 +67,10 @@
    33.4       * @param indexbuilder Unicode based Index from {@link IndexBuilder}
    33.5       */
    33.6      public SplitIndexWriter(ConfigurationImpl configuration,
    33.7 -                            String path, String filename,
    33.8 -                            String relpath, IndexBuilder indexbuilder,
    33.9 +                            DocPath path,
   33.10 +                            IndexBuilder indexbuilder,
   33.11                              int prev, int next) throws IOException {
   33.12 -        super(configuration, path, filename, relpath, indexbuilder);
   33.13 +        super(configuration, path, indexbuilder);
   33.14          this.prev = prev;
   33.15          this.next = next;
   33.16      }
   33.17 @@ -85,17 +85,16 @@
   33.18      public static void generate(ConfigurationImpl configuration,
   33.19                                  IndexBuilder indexbuilder) {
   33.20          SplitIndexWriter indexgen;
   33.21 -        String filename = "";
   33.22 -        String path = DirectoryManager.getPath("index-files");
   33.23 -        String relpath = DirectoryManager.getRelativePath("index-files");
   33.24 +        DocPath filename = DocPath.empty;
   33.25 +        DocPath path = DocPaths.INDEX_FILES;
   33.26          try {
   33.27              for (int i = 0; i < indexbuilder.elements().length; i++) {
   33.28                  int j = i + 1;
   33.29                  int prev = (j == 1)? -1: i;
   33.30                  int next = (j == indexbuilder.elements().length)? -1: j + 1;
   33.31 -                filename = "index-" + j +".html";
   33.32 +                filename = DocPaths.indexN(j);
   33.33                  indexgen = new SplitIndexWriter(configuration,
   33.34 -                                                path, filename, relpath,
   33.35 +                                                path.resolve(filename),
   33.36                                                  indexbuilder, prev, next);
   33.37                  indexgen.generateIndexFile((Character)indexbuilder.
   33.38                                                                   elements()[i]);
   33.39 @@ -104,7 +103,7 @@
   33.40          } catch (IOException exc) {
   33.41              configuration.standardmessage.error(
   33.42                          "doclet.exception_encountered",
   33.43 -                        exc.toString(), filename);
   33.44 +                        exc.toString(), filename.getPath());
   33.45              throw new DocletAbortException();
   33.46          }
   33.47      }
   33.48 @@ -142,7 +141,7 @@
   33.49          Object[] unicodeChars = indexbuilder.elements();
   33.50          for (int i = 0; i < unicodeChars.length; i++) {
   33.51              int j = i + 1;
   33.52 -            contentTree.addContent(getHyperLink("index-" + j + ".html",
   33.53 +            contentTree.addContent(getHyperLink(DocPaths.indexN(j),
   33.54                      new StringContent(unicodeChars[i].toString())));
   33.55              contentTree.addContent(getSpace());
   33.56          }
   33.57 @@ -159,7 +158,7 @@
   33.58              return HtmlTree.LI(prevletterLabel);
   33.59          }
   33.60          else {
   33.61 -            Content prevLink = getHyperLink("index-" + prev + ".html", "",
   33.62 +            Content prevLink = getHyperLink(DocPaths.indexN(prev), "",
   33.63                      prevletterLabel);
   33.64              return HtmlTree.LI(prevLink);
   33.65          }
   33.66 @@ -176,7 +175,7 @@
   33.67              return HtmlTree.LI(nextletterLabel);
   33.68          }
   33.69          else {
   33.70 -            Content nextLink = getHyperLink("index-" + next + ".html","",
   33.71 +            Content nextLink = getHyperLink(DocPaths.indexN(next), "",
   33.72                      nextletterLabel);
   33.73              return HtmlTree.LI(nextLink);
   33.74          }
    34.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java	Wed Oct 17 16:43:26 2012 +0100
    34.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java	Tue Oct 23 13:20:37 2012 -0700
    34.3 @@ -54,18 +54,11 @@
    34.4   */
    34.5  public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
    34.6  
    34.7 -    public SubWriterHolderWriter(ConfigurationImpl configuration,
    34.8 -                                 String filename) throws IOException {
    34.9 +    public SubWriterHolderWriter(ConfigurationImpl configuration, DocPath filename)
   34.10 +            throws IOException {
   34.11          super(configuration, filename);
   34.12      }
   34.13  
   34.14 -
   34.15 -    public SubWriterHolderWriter(ConfigurationImpl configuration,
   34.16 -                                 String path, String filename, String relpath)
   34.17 -                                 throws IOException {
   34.18 -        super(configuration, path, filename, relpath);
   34.19 -    }
   34.20 -
   34.21      /**
   34.22       * Add the summary header.
   34.23       *
    35.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java	Wed Oct 17 16:43:26 2012 +0100
    35.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java	Tue Oct 23 13:20:37 2012 -0700
    35.3 @@ -66,8 +66,10 @@
    35.4      public TagletOutput getDocRootOutput() {
    35.5          if (htmlWriter.configuration.docrootparent.length() > 0)
    35.6              return new TagletOutputImpl(htmlWriter.configuration.docrootparent);
    35.7 +        else if (htmlWriter.pathToRoot.isEmpty())
    35.8 +            return new TagletOutputImpl(".");
    35.9          else
   35.10 -            return new TagletOutputImpl(htmlWriter.relativepathNoSlash);
   35.11 +            return new TagletOutputImpl(htmlWriter.pathToRoot.getPath());
   35.12      }
   35.13  
   35.14      /**
   35.15 @@ -170,18 +172,18 @@
   35.16                  htmlWriter instanceof ClassWriterImpl) {
   35.17              //Automatically add link to constant values page for constant fields.
   35.18              result = addSeeHeader(result);
   35.19 -            result += htmlWriter.getHyperLinkString(htmlWriter.relativePath +
   35.20 -                ConfigurationImpl.CONSTANTS_FILE_NAME
   35.21 -                + "#" + ((ClassWriterImpl) htmlWriter).getClassDoc().qualifiedName()
   35.22 +            result += htmlWriter.getHyperLinkString(htmlWriter.pathToRoot.resolve(
   35.23 +                DocPaths.CONSTANT_VALUES),
   35.24 +                ((ClassWriterImpl) htmlWriter).getClassDoc().qualifiedName()
   35.25                  + "." + ((FieldDoc) holder).name(),
   35.26 -                htmlWriter.configuration.getText("doclet.Constants_Summary"));
   35.27 +                htmlWriter.configuration.getText("doclet.Constants_Summary"), false);
   35.28          }
   35.29          if (holder.isClass() && ((ClassDoc)holder).isSerializable()) {
   35.30              //Automatically add link to serialized form page for serializable classes.
   35.31              if ((SerializedFormBuilder.serialInclude(holder) &&
   35.32                        SerializedFormBuilder.serialInclude(((ClassDoc)holder).containingPackage()))) {
   35.33                  result = addSeeHeader(result);
   35.34 -                result += htmlWriter.getHyperLinkString(htmlWriter.relativePath + "serialized-form.html",
   35.35 +                result += htmlWriter.getHyperLinkString(htmlWriter.pathToRoot.resolve(DocPaths.SERIALIZED_FORM),
   35.36                          ((ClassDoc)holder).qualifiedName(), htmlWriter.configuration.getText("doclet.Serialized_Form"), false);
   35.37              }
   35.38          }
    36.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java	Wed Oct 17 16:43:26 2012 +0100
    36.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java	Tue Oct 23 13:20:37 2012 -0700
    36.3 @@ -67,7 +67,7 @@
    36.4       * @param classtree the tree being built.
    36.5       */
    36.6      public TreeWriter(ConfigurationImpl configuration,
    36.7 -            String filename, ClassTree classtree)
    36.8 +            DocPath filename, ClassTree classtree)
    36.9      throws IOException {
   36.10          super(configuration, filename, classtree);
   36.11          packages = configuration.packages;
   36.12 @@ -84,7 +84,7 @@
   36.13      public static void generate(ConfigurationImpl configuration,
   36.14                                  ClassTree classtree) {
   36.15          TreeWriter treegen;
   36.16 -        String filename = "overview-tree.html";
   36.17 +        DocPath filename = DocPaths.OVERVIEW_TREE;
   36.18          try {
   36.19              treegen = new TreeWriter(configuration, filename, classtree);
   36.20              treegen.generateTreeFile();
   36.21 @@ -144,7 +144,7 @@
   36.22                          (configuration.nodeprecated && Util.isDeprecated(packages[i]))) {
   36.23                      continue;
   36.24                  }
   36.25 -                String link = pathString(packages[i], "package-tree.html");
   36.26 +                DocPath link = pathString(packages[i], DocPaths.PACKAGE_TREE);
   36.27                  Content li = HtmlTree.LI(getHyperLink(
   36.28                          link, "", new StringContent(packages[i].name())));
   36.29                  if (i < packages.length - 1) {
    37.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java	Wed Oct 17 16:43:26 2012 +0100
    37.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java	Tue Oct 23 13:20:37 2012 -0700
    37.3 @@ -31,6 +31,8 @@
    37.4  import com.sun.javadoc.*;
    37.5  import com.sun.tools.doclets.formats.html.ConfigurationImpl;
    37.6  import com.sun.tools.doclets.internal.toolkit.*;
    37.7 +import com.sun.tools.doclets.internal.toolkit.util.DocPath;
    37.8 +import com.sun.tools.doclets.internal.toolkit.util.DocPaths;
    37.9  
   37.10  
   37.11  /**
   37.12 @@ -56,25 +58,11 @@
   37.13       *
   37.14       * @param filename String file name.
   37.15       */
   37.16 -    public HtmlDocWriter(Configuration configuration,
   37.17 -                         String filename) throws IOException {
   37.18 -        super(configuration,
   37.19 -              null, configuration.destDirName + filename,
   37.20 -              configuration.docencoding);
   37.21 -        // use File to normalize file separators
   37.22 +    public HtmlDocWriter(Configuration configuration, DocPath filename)
   37.23 +            throws IOException {
   37.24 +        super(configuration, filename);
   37.25          configuration.message.notice("doclet.Generating_0",
   37.26 -            new File(configuration.destDirName, filename));
   37.27 -    }
   37.28 -
   37.29 -    public HtmlDocWriter(Configuration configuration,
   37.30 -                         String path, String filename) throws IOException {
   37.31 -        super(configuration,
   37.32 -              configuration.destDirName + path, filename,
   37.33 -              configuration.docencoding);
   37.34 -        // use File to normalize file separators
   37.35 -        configuration.message.notice("doclet.Generating_0",
   37.36 -            new File(configuration.destDirName,
   37.37 -                    ((path.length() > 0)? path + File.separator: "") + filename));
   37.38 +            filename.resolveAgainst(configuration.destDirName));
   37.39      }
   37.40  
   37.41      /**
   37.42 @@ -92,7 +80,7 @@
   37.43       * @param strong       Boolean that sets label to strong.
   37.44       * @return String    Hyper Link.
   37.45       */
   37.46 -    public String getHyperLinkString(String link, String where,
   37.47 +    public String getHyperLinkString(DocPath link, String where,
   37.48                                 String label, boolean strong) {
   37.49          return getHyperLinkString(link, where, label, strong, "", "", "");
   37.50      }
   37.51 @@ -108,7 +96,7 @@
   37.52       * @param stylename  String style of text defined in style sheet.
   37.53       * @return String    Hyper Link.
   37.54       */
   37.55 -    public String getHyperLinkString(String link, String where,
   37.56 +    public String getHyperLinkString(DocPath link, String where,
   37.57                                 String label, boolean strong,
   37.58                                 String stylename) {
   37.59          return getHyperLinkString(link, where, label, strong, stylename, "", "");
   37.60 @@ -117,13 +105,26 @@
   37.61      /**
   37.62       * Get Html Hyper Link string.
   37.63       *
   37.64 +     * @param where      Position of the link in the file. Character '#' is not
   37.65 +     *                   needed.
   37.66 +     * @param label      Tag for the link.
   37.67 +     * @return a content tree for the hyper link
   37.68 +     */
   37.69 +    public Content getHyperLink(String where,
   37.70 +                               Content label) {
   37.71 +        return getHyperLink(DocPath.empty, where, label, "", "");
   37.72 +    }
   37.73 +
   37.74 +    /**
   37.75 +     * Get Html Hyper Link string.
   37.76 +     *
   37.77       * @param link       String name of the file.
   37.78       * @param where      Position of the link in the file. Character '#' is not
   37.79       *                   needed.
   37.80       * @param label      Tag for the link.
   37.81       * @return a content tree for the hyper link
   37.82       */
   37.83 -    public Content getHyperLink(String link, String where,
   37.84 +    public Content getHyperLink(DocPath link, String where,
   37.85                                 Content label) {
   37.86          return getHyperLink(link, where, label, "", "");
   37.87      }
   37.88 @@ -141,6 +142,13 @@
   37.89       * @param target     Target frame.
   37.90       * @return String    Hyper Link.
   37.91       */
   37.92 +    public String getHyperLinkString(DocPath link, String where,
   37.93 +                               String label, boolean strong,
   37.94 +                               String stylename, String title, String target) {
   37.95 +        return getHyperLinkString(link.getPath(), where, label, strong,
   37.96 +                stylename, title, target);
   37.97 +    }
   37.98 +
   37.99      public String getHyperLinkString(String link, String where,
  37.100                                 String label, boolean strong,
  37.101                                 String stylename, String title, String target) {
  37.102 @@ -189,8 +197,13 @@
  37.103       * @param target     Target frame.
  37.104       * @return a content tree for the hyper link.
  37.105       */
  37.106 +    public Content getHyperLink(DocPath link, String where,
  37.107 +            Content label, String title, String target) {
  37.108 +        return getHyperLink(link.getPath(), where, label, title, target);
  37.109 +    }
  37.110      public Content getHyperLink(String link, String where,
  37.111              Content label, String title, String target) {
  37.112 +        if (link.startsWith("/")) Thread.dumpStack();
  37.113          if (where != null && where.length() != 0) {
  37.114              link += "#" + where;
  37.115          }
  37.116 @@ -211,7 +224,7 @@
  37.117       * @param label Label for the link
  37.118       * @return a content for the hyperlink to the file
  37.119       */
  37.120 -    public Content getHyperLink(String link, Content label) {
  37.121 +    public Content getHyperLink(DocPath link, Content label) {
  37.122          return getHyperLink(link, "", label);
  37.123      }
  37.124  
  37.125 @@ -222,7 +235,7 @@
  37.126       * @param label      Tag for the link.
  37.127       * @return Strign    Hyper link.
  37.128       */
  37.129 -    public String getHyperLinkString(String link, String label) {
  37.130 +    public String getHyperLinkString(DocPath link, String label) {
  37.131          return getHyperLinkString(link, "", label, false);
  37.132      }
  37.133  
    38.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java	Wed Oct 17 16:43:26 2012 +0100
    38.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java	Tue Oct 23 13:20:37 2012 -0700
    38.3 @@ -47,22 +47,11 @@
    38.4  public class HtmlWriter {
    38.5  
    38.6      /**
    38.7 -     * Name of the file, to which this writer is writing to.
    38.8 -     */
    38.9 -    protected final String htmlFilename;
   38.10 -
   38.11 -    /**
   38.12       * The window title of this file
   38.13       */
   38.14      protected String winTitle;
   38.15  
   38.16      /**
   38.17 -     * URL file separator string("/").
   38.18 -     */
   38.19 -    public static final String fileseparator =
   38.20 -         DirectoryManager.URL_FILE_SEPARATOR;
   38.21 -
   38.22 -    /**
   38.23       * The configuration
   38.24       */
   38.25      protected Configuration configuration;
   38.26 @@ -162,18 +151,15 @@
   38.27       *             or null if none to be created.
   38.28       * @param filename File Name to which the PrintWriter will
   38.29       *                 do the Output.
   38.30 -     * @param docencoding Encoding to be used for this file.
   38.31       * @exception IOException Exception raised by the FileWriter is passed on
   38.32       * to next level.
   38.33       * @exception UnsupportedEncodingException Exception raised by the
   38.34       * OutputStreamWriter is passed on to next level.
   38.35       */
   38.36 -    public HtmlWriter(Configuration configuration,
   38.37 -                      String path, String filename, String docencoding)
   38.38 -                      throws IOException, UnsupportedEncodingException {
   38.39 -        writer = Util.genWriter(configuration, path, filename, docencoding);
   38.40 +    public HtmlWriter(Configuration configuration,DocPath path)
   38.41 +            throws IOException, UnsupportedEncodingException {
   38.42 +        writer = Util.genWriter(configuration, path);
   38.43          this.configuration = configuration;
   38.44 -        htmlFilename = filename;
   38.45          this.memberDetailsListPrinted = false;
   38.46          packageTableHeader = new String[] {
   38.47              configuration.getText("doclet.Package"),
    39.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java	Wed Oct 17 16:43:26 2012 +0100
    39.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java	Tue Oct 23 13:20:37 2012 -0700
    39.3 @@ -130,8 +130,8 @@
    39.4              boolean first = true;
    39.5              while(pathTokens.hasMoreTokens()){
    39.6                  Util.copyDocFiles(configuration,
    39.7 -                    pathTokens.nextToken() + File.separator,
    39.8 -                    DocletConstants.DOC_FILES_DIR_NAME, first);
    39.9 +                    new File(pathTokens.nextToken()),
   39.10 +                    DocPaths.DOC_FILES, first);
   39.11                  first = false;
   39.12              }
   39.13          }
    40.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/PackageSummaryWriter.java	Wed Oct 17 16:43:26 2012 +0100
    40.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/PackageSummaryWriter.java	Tue Oct 23 13:20:37 2012 -0700
    40.3 @@ -45,13 +45,6 @@
    40.4  public interface PackageSummaryWriter {
    40.5  
    40.6      /**
    40.7 -     * Return the name of the output file.
    40.8 -     *
    40.9 -     * @return the name of the output file.
   40.10 -     */
   40.11 -    public abstract String getOutputFileName();
   40.12 -
   40.13 -    /**
   40.14       * Get the header for the summary.
   40.15       *
   40.16       * @param heading Package name.
    41.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java	Wed Oct 17 16:43:26 2012 +0100
    41.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java	Tue Oct 23 13:20:37 2012 -0700
    41.3 @@ -141,11 +141,9 @@
    41.4              //documented AND if we have not documented a class from the same
    41.5              //package already. Otherwise, we are making duplicate copies.
    41.6              Util.copyDocFiles(configuration,
    41.7 -                Util.getPackageSourcePath(configuration,
    41.8 -                    annotationTypeDoc.containingPackage()) +
    41.9 -                DirectoryManager.getDirectoryPath(
   41.10 -                    annotationTypeDoc.containingPackage())
   41.11 -                    + File.separator, DocletConstants.DOC_FILES_DIR_NAME, true);
   41.12 +                new File(Util.getPackageSourcePath(configuration, containingPackage),
   41.13 +                    DocPath.forPackage(annotationTypeDoc).getPath()),
   41.14 +                DocPaths.DOC_FILES, true);
   41.15              containingPackagesSeen.add(containingPackage.name());
   41.16          }
   41.17       }
    42.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java	Wed Oct 17 16:43:26 2012 +0100
    42.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java	Tue Oct 23 13:20:37 2012 -0700
    42.3 @@ -267,10 +267,9 @@
    42.4              //documented AND if we have not documented a class from the same
    42.5              //package already. Otherwise, we are making duplicate copies.
    42.6              Util.copyDocFiles(configuration,
    42.7 -                    Util.getPackageSourcePath(configuration,
    42.8 -                    classDoc.containingPackage()) +
    42.9 -                    DirectoryManager.getDirectoryPath(classDoc.containingPackage())
   42.10 -                    + File.separator, DocletConstants.DOC_FILES_DIR_NAME, true);
   42.11 +                new File(Util.getPackageSourcePath(configuration, containingPackage),
   42.12 +                    DocPath.forPackage(classDoc).getPath()),
   42.13 +                DocPaths.DOC_FILES, true);
   42.14              containingPackagesSeen.add(containingPackage.name());
   42.15          }
   42.16       }
    43.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java	Wed Oct 17 16:43:26 2012 +0100
    43.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java	Tue Oct 23 13:20:37 2012 -0700
    43.3 @@ -122,9 +122,7 @@
    43.4          Util.copyDocFiles(
    43.5                  configuration,
    43.6                  Util.getPackageSourcePath(configuration, packageDoc),
    43.7 -                DirectoryManager.getDirectoryPath(packageDoc)
    43.8 -                        + File.separator
    43.9 -                        + DocletConstants.DOC_FILES_DIR_NAME,
   43.10 +                DocPath.forPackage(packageDoc).resolve(DocPaths.DOC_FILES),
   43.11                  true);
   43.12      }
   43.13  
    44.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java	Wed Oct 17 16:43:26 2012 +0100
    44.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java	Tue Oct 23 13:20:37 2012 -0700
    44.3 @@ -474,6 +474,8 @@
    44.4          Arrays.sort(tags);
    44.5          int tagsLength = tags.length;
    44.6          for (int i = 0; i < tagsLength; i++) {
    44.7 +            if (tags[i].fieldName() == null || tags[i].fieldType() == null) // ignore malformed @serialField tags
    44.8 +                continue;
    44.9              Content fieldsContentTree = fieldWriter.getFieldsContentHeader(
   44.10                      (i == tagsLength - 1));
   44.11              fieldWriter.addMemberHeader(tags[i].fieldTypeDoc(),
    45.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DirectoryManager.java	Wed Oct 17 16:43:26 2012 +0100
    45.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.3 @@ -1,317 +0,0 @@
    45.4 -/*
    45.5 - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
    45.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    45.7 - *
    45.8 - * This code is free software; you can redistribute it and/or modify it
    45.9 - * under the terms of the GNU General Public License version 2 only, as
   45.10 - * published by the Free Software Foundation.  Oracle designates this
   45.11 - * particular file as subject to the "Classpath" exception as provided
   45.12 - * by Oracle in the LICENSE file that accompanied this code.
   45.13 - *
   45.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   45.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   45.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   45.17 - * version 2 for more details (a copy is included in the LICENSE file that
   45.18 - * accompanied this code).
   45.19 - *
   45.20 - * You should have received a copy of the GNU General Public License version
   45.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   45.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   45.23 - *
   45.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   45.25 - * or visit www.oracle.com if you need additional information or have any
   45.26 - * questions.
   45.27 - */
   45.28 -
   45.29 -package com.sun.tools.doclets.internal.toolkit.util;
   45.30 -
   45.31 -import com.sun.tools.doclets.internal.toolkit.*;
   45.32 -import com.sun.javadoc.*;
   45.33 -import java.io.*;
   45.34 -
   45.35 -
   45.36 -/**
   45.37 - * Handle the directory creations and the path string generations.
   45.38 - * All static - never instaniated.
   45.39 - *
   45.40 - * This code is not part of an API.
   45.41 - * It is implementation that is subject to change.
   45.42 - * Do not use it as an API
   45.43 - *
   45.44 - * @since 1.2
   45.45 - * @author Atul M Dambalkar
   45.46 - */
   45.47 -public class DirectoryManager {
   45.48 -
   45.49 -    /**
   45.50 -     * The file separator string, "/", used in the formation of the URL path.
   45.51 -     */
   45.52 -    public static final String URL_FILE_SEPARATOR = "/";
   45.53 -
   45.54 -    /**
   45.55 -     * Never instaniated.
   45.56 -     */
   45.57 -    private DirectoryManager() {
   45.58 -    }
   45.59 -
   45.60 -    /**
   45.61 -     * Given a PackageDoc, return its URL path string.
   45.62 -     *
   45.63 -     * @param pd PackageDoc
   45.64 -     * @see #getPath(String)
   45.65 -     */
   45.66 -    public static String createPathString(PackageDoc pd) {
   45.67 -        if (pd == null) {
   45.68 -            return "";
   45.69 -        }
   45.70 -        return getPath(pd.name());
   45.71 -    }
   45.72 -
   45.73 -    /**
   45.74 -     * Given a ClassDoc, return its URL path string.
   45.75 -     *
   45.76 -     * @param cd ClassDoc
   45.77 -     * @see #getPath(String)
   45.78 -     */
   45.79 -    public static String createPathString(ClassDoc cd) {
   45.80 -        if (cd == null) {
   45.81 -            return "";
   45.82 -        }
   45.83 -        PackageDoc pd = cd.containingPackage();
   45.84 -        return (pd == null)? "": getPath(pd.name());
   45.85 -    }
   45.86 -
   45.87 -    /**
   45.88 -     * Given a PackageDoc, return the corresponding directory name
   45.89 -     * with the platform-dependent file separator between subdirectory names.
   45.90 -     * For example, if name of the package is "java.lang" , then it
   45.91 -     * returns "java/lang" on Unix and "java\lang" on Windows.
   45.92 -     * If name of the package contains no dot, then the value
   45.93 -     * will be returned unchanged.  Because package names cannot
   45.94 -     * end in a dot, the return value will never end with a slash.
   45.95 -     * <p>
   45.96 -     * Also see getPath for the URL separator version of this method
   45.97 -     * that takes a string instead of a PackageDoc.
   45.98 -     *
   45.99 -     * @param  pd    the PackageDoc
  45.100 -     * @return       the platform-dependent directory path for the package
  45.101 -     */
  45.102 -    public static String getDirectoryPath(PackageDoc pd) {
  45.103 -        return pd == null || pd.name().length() == 0 ? "" : getDirectoryPath(pd.name());
  45.104 -    }
  45.105 -
  45.106 -    /**
  45.107 -     * Given a package name, return the corresponding directory name
  45.108 -     * with the platform-dependent file separator between subdirectory names.
  45.109 -     * For example, if name of the package is "java.lang" , then it
  45.110 -     * returns "java/lang" on Unix and "java\lang" on Windows.
  45.111 -     * If name of the package contains no dot, then the value
  45.112 -     * will be returned unchanged.  Because package names cannot
  45.113 -     * end in a dot, the return value will never end with a slash.
  45.114 -     * <p>
  45.115 -     * Also see getPath for the URL separator version of this method
  45.116 -     * that takes a string instead of a PackageDoc.
  45.117 -     *
  45.118 -     * @param  packageName    the name of the package
  45.119 -     * @return       the platform-dependent directory path for the package
  45.120 -     */
  45.121 -    public static String getDirectoryPath(String packageName) {
  45.122 -        if (packageName == null || packageName.length() == 0) {
  45.123 -            return "";
  45.124 -        }
  45.125 -        StringBuilder pathstr = new StringBuilder();
  45.126 -        for (int i = 0; i < packageName.length(); i++) {
  45.127 -            char ch = packageName.charAt(i);
  45.128 -            if (ch == '.') {
  45.129 -                pathstr.append(URL_FILE_SEPARATOR);
  45.130 -            } else {
  45.131 -                pathstr.append(ch);
  45.132 -            }
  45.133 -        }
  45.134 -        if (pathstr.length() > 0 && ! pathstr.toString().endsWith(URL_FILE_SEPARATOR)) {
  45.135 -            pathstr.append(URL_FILE_SEPARATOR);
  45.136 -        }
  45.137 -        return pathstr.toString();
  45.138 -    }
  45.139 -
  45.140 -    /**
  45.141 -     * Given a package name (a string), return the path string,
  45.142 -     * with the URL separator "/" separating the subdirectory names.
  45.143 -     * If name of the package contains no dot, then the value
  45.144 -     * will be returned unchanged.  Because package names cannot
  45.145 -     * end in a dot, the return value will never end with a slash.
  45.146 -     * <p>
  45.147 -     * For example if the string is "com.sun.javadoc" then the URL
  45.148 -     * path string will be "com/sun/javadoc".
  45.149 -     *
  45.150 -     * @param name   the package name as a String
  45.151 -     * @return       the String URL path
  45.152 -     */
  45.153 -    public static String getPath(String name) {
  45.154 -        if (name == null || name.length() == 0) {
  45.155 -            return "";
  45.156 -        }
  45.157 -        StringBuilder pathstr = new StringBuilder();
  45.158 -        for (int i = 0; i < name.length(); i++) {
  45.159 -            char ch = name.charAt(i);
  45.160 -            if (ch == '.') {
  45.161 -                pathstr.append(URL_FILE_SEPARATOR);
  45.162 -            } else {
  45.163 -                pathstr.append(ch);
  45.164 -            }
  45.165 -        }
  45.166 -        return pathstr.toString();
  45.167 -    }
  45.168 -
  45.169 -    /**
  45.170 -     * Given two package names as strings, return the relative path
  45.171 -     * from the package directory corresponding to the first string
  45.172 -     * to the package directory corresponding to the second string,
  45.173 -     * with the URL file separator "/" separating subdirectory names.
  45.174 -     * <p>
  45.175 -     * For example, if the parameter "from" is "java.lang"
  45.176 -     * and parameter "to" is "java.applet", return string
  45.177 -     * "../../java/applet".
  45.178 -     *
  45.179 -     * @param from   the package name from which path is calculated
  45.180 -     * @param to     the package name to which path is calculated
  45.181 -     * @return       relative path between "from" and "to" with URL
  45.182 -     *               separators
  45.183 -     * @see          #getRelativePath(String)
  45.184 -     * @see          #getPath(String)
  45.185 -     */
  45.186 -    public static String getRelativePath(String from, String to) {
  45.187 -        StringBuilder pathstr = new StringBuilder();
  45.188 -        pathstr.append(getRelativePath(from));
  45.189 -        pathstr.append(getPath(to));
  45.190 -        pathstr.append(URL_FILE_SEPARATOR);
  45.191 -        return pathstr.toString();
  45.192 -    }
  45.193 -
  45.194 -    /**
  45.195 -     * Given a package name as a string, return relative path string
  45.196 -     * from the corresponding package directory to the root of
  45.197 -     * the documentation, using the URL separator "/" between
  45.198 -     * subdirectory names.
  45.199 -     * <p>
  45.200 -     * For example, if the string "from" is "java.lang",
  45.201 -     * return "../../"
  45.202 -     *
  45.203 -     * @param from    the package
  45.204 -     * @return        String relative path from "from".
  45.205 -     * @see           #getRelativePath(String, String)
  45.206 -     */
  45.207 -    public static String getRelativePath(PackageDoc from) {
  45.208 -        return from == null || from.name().length() == 0 ? "" : getRelativePath(from.name());
  45.209 -    }
  45.210 -
  45.211 -    /**
  45.212 -     * Given a package name as a string, return relative path string
  45.213 -     * from the corresponding package directory to the root of
  45.214 -     * the documentation, using the URL separator "/" between
  45.215 -     * subdirectory names.
  45.216 -     * <p>
  45.217 -     * For example, if the string "from" is "java.lang",
  45.218 -     * return "../../"
  45.219 -     *
  45.220 -     * @param from    the package name
  45.221 -     * @return        String relative path from "from".
  45.222 -     * @see           #getRelativePath(String, String)
  45.223 -     */
  45.224 -    public static String getRelativePath(String from) {
  45.225 -        if (from == null || from.length() == 0) {
  45.226 -            return "";
  45.227 -        }
  45.228 -        StringBuilder pathstr = new StringBuilder();
  45.229 -        for (int i = 0; i < from.length(); i++) {
  45.230 -            char ch = from.charAt(i);
  45.231 -            if (ch == '.') {
  45.232 -                pathstr.append(".." + URL_FILE_SEPARATOR);
  45.233 -            }
  45.234 -        }
  45.235 -        pathstr.append(".." + URL_FILE_SEPARATOR);
  45.236 -        return pathstr.toString();
  45.237 -    }
  45.238 -
  45.239 -    /**
  45.240 -     * Given a relative or absolute path that might be empty,
  45.241 -     * convert it to a path that does not end with a
  45.242 -     * URL separator "/".  Used for converting
  45.243 -     * HtmlStandardWriter.relativepath when replacing {@docRoot}.
  45.244 -     *
  45.245 -     * @param path   the path to convert.  An empty path represents
  45.246 -     *               the current directory.
  45.247 -     */
  45.248 -    public static String getPathNoTrailingSlash(String path) {
  45.249 -        if ( path.equals("") ) {
  45.250 -            return ".";
  45.251 -        }
  45.252 -        if ( path.equals("/") ) {
  45.253 -            return "/.";
  45.254 -        }
  45.255 -        if ( path.endsWith("/") ) {
  45.256 -            // Remove trailing slash
  45.257 -            path = path.substring(0, path.length() -1);
  45.258 -        }
  45.259 -        return path;
  45.260 -    }
  45.261 -
  45.262 -    /**
  45.263 -     * Given a path string create all the directories in the path. For example,
  45.264 -     * if the path string is "java/applet", the method will create directory
  45.265 -     * "java" and then "java/applet" if they don't exist. The file separator
  45.266 -     * string "/" is platform dependent system property.
  45.267 -     *
  45.268 -     * @param path Directory path string.
  45.269 -     */
  45.270 -    public static void createDirectory(Configuration configuration,
  45.271 -                                       String path) {
  45.272 -        if (path == null || path.length() == 0) {
  45.273 -            return;
  45.274 -        }
  45.275 -        File dir = new File(path);
  45.276 -        if (dir.exists()) {
  45.277 -            return;
  45.278 -        } else {
  45.279 -            if (dir.mkdirs()) {
  45.280 -                return;
  45.281 -            } else {
  45.282 -                configuration.message.error(
  45.283 -                       "doclet.Unable_to_create_directory_0", path);
  45.284 -                throw new DocletAbortException();
  45.285 -            }
  45.286 -        }
  45.287 -    }
  45.288 -
  45.289 -    /**
  45.290 -     * Given a package name and a file name, return the full path to that file.
  45.291 -     * For example, if PackageDoc passed is for "java.lang" and the filename
  45.292 -     * passed is "package-summary.html", then the string returned is
  45.293 -     * "java/lang/package-summary.html".
  45.294 -     *
  45.295 -     * @param pd         PackageDoc.
  45.296 -     * @param filename   File name to be appended to the path of the package.
  45.297 -     */
  45.298 -    public static String getPathToPackage(PackageDoc pd, String filename) {
  45.299 -        StringBuilder buf = new StringBuilder();
  45.300 -        String pathstr = createPathString(pd);
  45.301 -        if (pathstr.length() > 0) {
  45.302 -            buf.append(pathstr);
  45.303 -            buf.append(URL_FILE_SEPARATOR);
  45.304 -        }
  45.305 -        buf.append(filename);
  45.306 -        return buf.toString();
  45.307 -    }
  45.308 -
  45.309 -    /**
  45.310 -     * Given a class name return the full path to the class file.
  45.311 -     * For example, if ClassDoc passed is for "java.lang.Object" then the
  45.312 -     * string returned is "java/lang/Object.html".
  45.313 -     *
  45.314 -     * @param cd   ClassDoc.
  45.315 -     */
  45.316 -    public static String getPathToClass(ClassDoc cd) {
  45.317 -        return getPathToPackage(cd.containingPackage(), cd.name() + ".html");
  45.318 -    }
  45.319 -
  45.320 -}
    46.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPath.java	Tue Oct 23 13:20:37 2012 -0700
    46.3 @@ -0,0 +1,188 @@
    46.4 +/*
    46.5 + * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
    46.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    46.7 + *
    46.8 + * This code is free software; you can redistribute it and/or modify it
    46.9 + * under the terms of the GNU General Public License version 2 only, as
   46.10 + * published by the Free Software Foundation.  Oracle designates this
   46.11 + * particular file as subject to the "Classpath" exception as provided
   46.12 + * by Oracle in the LICENSE file that accompanied this code.
   46.13 + *
   46.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   46.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   46.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   46.17 + * version 2 for more details (a copy is included in the LICENSE file that
   46.18 + * accompanied this code).
   46.19 + *
   46.20 + * You should have received a copy of the GNU General Public License version
   46.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   46.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   46.23 + *
   46.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   46.25 + * or visit www.oracle.com if you need additional information or have any
   46.26 + * questions.
   46.27 + */
   46.28 +
   46.29 +package com.sun.tools.doclets.internal.toolkit.util;
   46.30 +
   46.31 +import com.sun.javadoc.ClassDoc;
   46.32 +import com.sun.javadoc.PackageDoc;
   46.33 +import java.io.File;
   46.34 +
   46.35 +/**
   46.36 + * Abstraction for immutable relative paths.
   46.37 + * Paths always use '/' as a separator, and never begin or end with '/'.
   46.38 + */
   46.39 +public class DocPath {
   46.40 +    private final String path;
   46.41 +
   46.42 +    /** The empty path. */
   46.43 +    public static final DocPath empty = new DocPath("");
   46.44 +
   46.45 +    /** The empty path. */
   46.46 +    public static final DocPath parent = new DocPath("..");
   46.47 +
   46.48 +    /**
   46.49 +     * Create a path from a string.
   46.50 +     */
   46.51 +    public static DocPath create(String p) {
   46.52 +        return (p == null) || p.isEmpty() ? empty : new DocPath(p);
   46.53 +    }
   46.54 +
   46.55 +    /**
   46.56 +     * Return the path for a class.
   46.57 +     * For example, if the class is java.lang.Object,
   46.58 +     * the path is java/lang/Object.html.
   46.59 +     */
   46.60 +    public static DocPath forClass(ClassDoc cd) {
   46.61 +        return (cd == null) ? empty :
   46.62 +                forPackage(cd.containingPackage()).resolve(forName(cd));
   46.63 +    }
   46.64 +
   46.65 +    /**
   46.66 +     * Return the path for the simple name of the class.
   46.67 +     * For example, if the class is java.lang.Object,
   46.68 +     * the path is Object.html.
   46.69 +     */
   46.70 +    public static DocPath forName(ClassDoc cd) {
   46.71 +        return (cd == null) ? empty : new DocPath(cd.name() + ".html");
   46.72 +    }
   46.73 +
   46.74 +    /**
   46.75 +     * Return the path for the package of a class.
   46.76 +     * For example, if the class is java.lang.Object,
   46.77 +     * the path is java/lang.
   46.78 +     */
   46.79 +    public static DocPath forPackage(ClassDoc cd) {
   46.80 +        return (cd == null) ? empty : forPackage(cd.containingPackage());
   46.81 +    }
   46.82 +
   46.83 +    /**
   46.84 +     * Return the path for a package.
   46.85 +     * For example, if the package is java.lang,
   46.86 +     * the path is java/lang.
   46.87 +     */
   46.88 +    public static DocPath forPackage(PackageDoc pd) {
   46.89 +        return (pd == null) ? empty : DocPath.create(pd.name().replace('.', '/'));
   46.90 +    }
   46.91 +
   46.92 +    /**
   46.93 +     * Return the inverse path for a package.
   46.94 +     * For example, if the package is java.lang,
   46.95 +     * the inverse path is ../...
   46.96 +     */
   46.97 +    public static DocPath forRoot(PackageDoc pd) {
   46.98 +        String name = (pd == null) ? "" : pd.name();
   46.99 +        if (name.isEmpty())
  46.100 +            return empty;
  46.101 +        return new DocPath(name.replace('.', '/').replaceAll("[^/]+", ".."));
  46.102 +    }
  46.103 +
  46.104 +    /**
  46.105 +     * Return the relative path from one package to another.
  46.106 +     */
  46.107 +    public static DocPath relativePath(PackageDoc from, PackageDoc to) {
  46.108 +        return forRoot(from).resolve(forPackage(to));
  46.109 +    }
  46.110 +
  46.111 +    protected DocPath(String p) {
  46.112 +        path = (p.endsWith("/") ? p.substring(0, p.length() - 1) : p);
  46.113 +    }
  46.114 +
  46.115 +    /** @inheritDoc */
  46.116 +    @Override
  46.117 +    public boolean equals(Object other) {
  46.118 +        return (other instanceof DocPath) && path.equals(((DocPath)other).path);
  46.119 +    }
  46.120 +
  46.121 +    /** @inheritDoc */
  46.122 +    @Override
  46.123 +    public int hashCode() {
  46.124 +        return path.hashCode();
  46.125 +    }
  46.126 +
  46.127 +    public DocPath basename() {
  46.128 +        int sep = path.lastIndexOf("/");
  46.129 +        return (sep == -1) ? this : new DocPath(path.substring(sep + 1));
  46.130 +    }
  46.131 +
  46.132 +    public DocPath parent() {
  46.133 +        int sep = path.lastIndexOf("/");
  46.134 +        return (sep == -1) ? empty : new DocPath(path.substring(0, sep));
  46.135 +    }
  46.136 +
  46.137 +    /**
  46.138 +     * Return the path formed by appending the specified string to the current path.
  46.139 +     */
  46.140 +    public DocPath resolve(String p) {
  46.141 +        if (p == null || p.isEmpty())
  46.142 +            return this;
  46.143 +        if (path.isEmpty())
  46.144 +            return new DocPath(p);
  46.145 +        return new DocPath(path + "/" + p);
  46.146 +    }
  46.147 +
  46.148 +    /**
  46.149 +     * Return the path by appending the specified path to the current path.
  46.150 +     */
  46.151 +    public DocPath resolve(DocPath p) {
  46.152 +        if (p == null || p.isEmpty())
  46.153 +            return this;
  46.154 +        if (path.isEmpty())
  46.155 +            return p;
  46.156 +        return new DocPath(path + "/" + p.getPath());
  46.157 +    }
  46.158 +
  46.159 +    /**
  46.160 +     * Get the file created by evaluating the path against a specified directory.
  46.161 +     */
  46.162 +    // Temporary: this signature should not use String for dir.
  46.163 +    // Eventually, this should involve javax.tools.Location.
  46.164 +    public File resolveAgainst(String dir) {
  46.165 +        return dir.isEmpty() ? new File(path) : new File(dir, path);
  46.166 +    }
  46.167 +
  46.168 +    /**
  46.169 +     * Return the inverse path for this path.
  46.170 +     * For example, if the path is a/b/c, the inverse path is ../../..
  46.171 +     */
  46.172 +    public DocPath invert() {
  46.173 +        return new DocPath(path.replaceAll("[^/]+", ".."));
  46.174 +    }
  46.175 +
  46.176 +    /**
  46.177 +     * Return true if this path is empty.
  46.178 +     */
  46.179 +    public boolean isEmpty() {
  46.180 +        return path.isEmpty();
  46.181 +    }
  46.182 +
  46.183 +    /**
  46.184 +     * Return this path as a string.
  46.185 +     */
  46.186 +    // This is provided instead of using toString() to help catch
  46.187 +    // unintended use of toString() in string concatenation sequences.
  46.188 +    public String getPath() {
  46.189 +        return path;
  46.190 +    }
  46.191 +}
    47.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    47.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPaths.java	Tue Oct 23 13:20:37 2012 -0700
    47.3 @@ -0,0 +1,110 @@
    47.4 +/*
    47.5 + * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
    47.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    47.7 + *
    47.8 + * This code is free software; you can redistribute it and/or modify it
    47.9 + * under the terms of the GNU General Public License version 2 only, as
   47.10 + * published by the Free Software Foundation.  Oracle designates this
   47.11 + * particular file as subject to the "Classpath" exception as provided
   47.12 + * by Oracle in the LICENSE file that accompanied this code.
   47.13 + *
   47.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   47.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   47.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   47.17 + * version 2 for more details (a copy is included in the LICENSE file that
   47.18 + * accompanied this code).
   47.19 + *
   47.20 + * You should have received a copy of the GNU General Public License version
   47.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   47.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   47.23 + *
   47.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   47.25 + * or visit www.oracle.com if you need additional information or have any
   47.26 + * questions.
   47.27 + */
   47.28 +
   47.29 +package com.sun.tools.doclets.internal.toolkit.util;
   47.30 +
   47.31 +/**
   47.32 + * Standard DocPath objects.
   47.33 + *
   47.34 + * @since 8
   47.35 + */
   47.36 +public class DocPaths {
   47.37 +
   47.38 +    /** The name of the file for all classes, using frames. */
   47.39 +    public static final DocPath ALLCLASSES_FRAME = DocPath.create("allclasses-frame.html");
   47.40 +
   47.41 +    /** The name of the file for all classes, without using frames. */
   47.42 +    public static final DocPath ALLCLASSES_NOFRAME = DocPath.create("allclasses-noframe.html");
   47.43 +
   47.44 +    /** The name of the sub-directory for storing class usage info. */
   47.45 +    public static final DocPath CLASS_USE = DocPath.create("class-use");
   47.46 +
   47.47 +    /** The name of the file for constant values. */
   47.48 +    public static final DocPath CONSTANT_VALUES = DocPath.create("constant-values.html");
   47.49 +
   47.50 +    /** The name of the fie for deprecated elements. */
   47.51 +    public static final DocPath DEPRECATED_LIST = DocPath.create("deprecated-list.html");
   47.52 +
   47.53 +    /** The name of the subdirectory for user-provided additional documentation files. */
   47.54 +    public static final DocPath DOC_FILES = DocPath.create("doc-files");
   47.55 +
   47.56 +    /** The name of the file for help info. */
   47.57 +    public static final DocPath HELP_DOC = DocPath.create("help-doc.html");
   47.58 +
   47.59 +    /** The name of the main index file. */
   47.60 +    public static final DocPath INDEX = DocPath.create("index.html");
   47.61 +
   47.62 +    /** The name of the single index file for all classes. */
   47.63 +    public static final DocPath INDEX_ALL = DocPath.create("index-all.html");
   47.64 +
   47.65 +    /** The name of the directory for the split index files. */
   47.66 +    public static final DocPath INDEX_FILES = DocPath.create("index-files");
   47.67 +
   47.68 +    /** Generate the name of one of the files in the split index. */
   47.69 +    public static final DocPath indexN(int n) {
   47.70 +        return DocPath.create("index-" + n + ".html");
   47.71 +    }
   47.72 +
   47.73 +    /** The name of the file for the overview frame. */
   47.74 +    public static final DocPath OVERVIEW_FRAME = DocPath.create("overview-frame.html");
   47.75 +
   47.76 +    /** The name of the file for the overview summary. */
   47.77 +    public static final DocPath OVERVIEW_SUMMARY = DocPath.create("overview-summary.html");
   47.78 +
   47.79 +    /** The name of the file for the overview tree. */
   47.80 +    public static final DocPath OVERVIEW_TREE = DocPath.create("overview-tree.html");
   47.81 +
   47.82 +    /** The name of the file for the package frame. */
   47.83 +    public static final DocPath PACKAGE_FRAME = DocPath.create("package-frame.html");
   47.84 +
   47.85 +    /** The name of the file for the package list. */
   47.86 +    public static final DocPath PACKAGE_LIST = DocPath.create("package-list");
   47.87 +
   47.88 +    /** The name of the file for the package summary. */
   47.89 +    public static final DocPath PACKAGE_SUMMARY = DocPath.create("package-summary.html");
   47.90 +
   47.91 +    /** The name of the file for the package tree. */
   47.92 +    public static final DocPath PACKAGE_TREE = DocPath.create("package-tree.html");
   47.93 +
   47.94 +    /** The name of the file for the package usage info. */
   47.95 +    public static final DocPath PACKAGE_USE = DocPath.create("package-use.html");
   47.96 +
   47.97 +    /** The name of the directory in which resources are generated.
   47.98 +     *  Also the name of the sub-package from which resources are read.
   47.99 +     */
  47.100 +    public static final DocPath RESOURCES = DocPath.create("resources");
  47.101 +
  47.102 +    /** The name of the file for the serialized form info. */
  47.103 +    public static final DocPath SERIALIZED_FORM = DocPath.create("serialized-form.html");
  47.104 +
  47.105 +    /** The name of the directory in which HTML versions of the source code
  47.106 +     *  are generated.
  47.107 +     */
  47.108 +    public static final DocPath SOURCE_OUTPUT = DocPath.create("src-html");
  47.109 +
  47.110 +    /** The name of the default stylesheet. */
  47.111 +    public static final DocPath STYLESHEET = DocPath.create("stylesheet.css");
  47.112 +
  47.113 +}
    48.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletConstants.java	Wed Oct 17 16:43:26 2012 +0100
    48.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletConstants.java	Tue Oct 23 13:20:37 2012 -0700
    48.3 @@ -40,6 +40,16 @@
    48.4  public class DocletConstants {
    48.5  
    48.6      /**
    48.7 +     * The default amount of space between tab stops.
    48.8 +     */
    48.9 +    public static final int DEFAULT_TAB_STOP_LENGTH = 8;
   48.10 +
   48.11 +    /**
   48.12 +     * The line separator for the current operating system.
   48.13 +     */
   48.14 +    public static final String NL = System.getProperty("line.separator");
   48.15 +
   48.16 +    /**
   48.17       * The default package name.
   48.18       */
   48.19      public static final String DEFAULT_PACKAGE_NAME = "&lt;Unnamed&gt;";
   48.20 @@ -53,34 +63,4 @@
   48.21       * The anchor for the default package.
   48.22       */
   48.23      public static final String UNNAMED_PACKAGE_ANCHOR = "unnamed_package";
   48.24 -
   48.25 -    /**
   48.26 -     * The name of the doc files directory.
   48.27 -     */
   48.28 -    public static final String DOC_FILES_DIR_NAME = "doc-files";
   48.29 -
   48.30 -    /**
   48.31 -     * The default amount of space between tab stops.
   48.32 -     */
   48.33 -    public static final int DEFAULT_TAB_STOP_LENGTH = 8;
   48.34 -
   48.35 -    /**
   48.36 -     * The name of the directory where we will copy resource files to.
   48.37 -     */
   48.38 -    public static final String RESOURE_DIR_NAME = "resources";
   48.39 -
   48.40 -    /**
   48.41 -     * The source output directory name
   48.42 -     */
   48.43 -    public static final String SOURCE_OUTPUT_DIR_NAME = "src-html/";
   48.44 -
   48.45 -    /**
   48.46 -     * The name of the package list file.
   48.47 -     */
   48.48 -    public static final String PACKAGE_LIST_FILE_NAME = "package-list";
   48.49 -
   48.50 -    /**
   48.51 -     * The line seperator for the current operating system.
   48.52 -     */
   48.53 -    public static final String NL = System.getProperty("line.separator");
   48.54  }
    49.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java	Wed Oct 17 16:43:26 2012 +0100
    49.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java	Tue Oct 23 13:20:37 2012 -0700
    49.3 @@ -142,12 +142,15 @@
    49.4       * @return if external return converted link else return null
    49.5       */
    49.6      public String getExternalLink(String pkgName,
    49.7 -                                  String relativepath, String link) {
    49.8 +                                  DocPath relativepath, String link) {
    49.9          Item fnd = findPackageItem(pkgName);
   49.10          if (fnd != null) {
   49.11              String externlink = fnd.path + link;
   49.12              if (fnd.relative) {  // it's a relative path.
   49.13 -                return relativepath + externlink;
   49.14 +                if (relativepath.isEmpty())
   49.15 +                    return externlink;
   49.16 +                else
   49.17 +                    return relativepath.getPath() + "/" + externlink;
   49.18              } else {
   49.19                  return externlink;
   49.20              }
    50.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PackageListWriter.java	Wed Oct 17 16:43:26 2012 +0100
    50.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PackageListWriter.java	Tue Oct 23 13:20:37 2012 -0700
    50.3 @@ -52,8 +52,7 @@
    50.4       * @param configuration the current configuration of the doclet.
    50.5       */
    50.6      public PackageListWriter(Configuration configuration) throws IOException {
    50.7 -        super(Util.genWriter(configuration, configuration.destDirName,
    50.8 -            DocletConstants.PACKAGE_LIST_FILE_NAME, configuration.docencoding));
    50.9 +        super(Util.genWriter(configuration, DocPaths.PACKAGE_LIST));
   50.10          this.configuration = configuration;
   50.11      }
   50.12  
   50.13 @@ -71,7 +70,7 @@
   50.14              packgen.close();
   50.15          } catch (IOException exc) {
   50.16              configuration.message.error("doclet.exception_encountered",
   50.17 -                exc.toString(), DocletConstants.PACKAGE_LIST_FILE_NAME);
   50.18 +                exc.toString(), DocPaths.PACKAGE_LIST);
   50.19              throw new DocletAbortException();
   50.20          }
   50.21      }
    51.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourcePath.java	Wed Oct 17 16:43:26 2012 +0100
    51.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourcePath.java	Tue Oct 23 13:20:37 2012 -0700
    51.3 @@ -1,5 +1,5 @@
    51.4  /*
    51.5 - * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
    51.6 + * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
    51.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    51.8   *
    51.9   * This code is free software; you can redistribute it and/or modify it
   51.10 @@ -38,8 +38,7 @@
   51.11   *
   51.12   * @author Atul M Dambalkar
   51.13   */
   51.14 -public
   51.15 -    class SourcePath {
   51.16 +public class SourcePath {
   51.17      private final char dirSeparator = File.pathSeparatorChar;
   51.18  
   51.19      /**
   51.20 @@ -114,9 +113,9 @@
   51.21       * @param name Name of the directory to be searched for in the source path.
   51.22       * @return File Return the directory if found else return null.
   51.23       */
   51.24 -    public File getDirectory(String name) {
   51.25 +    public File getDirectory(DocPath p) {
   51.26          for (int i = 0; i < sourcePath.length; i++) {
   51.27 -            File directoryNeeded = new File(sourcePath[i], name);
   51.28 +            File directoryNeeded = new File(sourcePath[i], p.getPath());
   51.29              if (directoryNeeded.isDirectory()) {
   51.30                  return directoryNeeded;
   51.31              }
    52.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java	Wed Oct 17 16:43:26 2012 +0100
    52.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java	Tue Oct 23 13:20:37 2012 -0700
    52.3 @@ -52,11 +52,6 @@
    52.4      {{"&", "&amp;"}, {"<", "&lt;"}, {">", "&gt;"}};
    52.5  
    52.6      /**
    52.7 -     * Name of the resource directory.
    52.8 -     */
    52.9 -    public static final String RESOURCESDIR = "resources";
   52.10 -
   52.11 -    /**
   52.12       * Return array of class members whose documentation is to be generated.
   52.13       * If the member is deprecated do not include such a member in the
   52.14       * returned array.
   52.15 @@ -236,26 +231,20 @@
   52.16       * @param overwrite Overwrite files if true.
   52.17       */
   52.18      public static void copyDocFiles(Configuration configuration,
   52.19 -            String path, String dir, boolean overwrite) {
   52.20 +            File path, DocPath dir, boolean overwrite) {
   52.21          if (checkCopyDocFilesErrors(configuration, path, dir)) {
   52.22              return;
   52.23          }
   52.24 -        String destname = configuration.docFileDestDirName;
   52.25 -        File srcdir = new File(path + dir);
   52.26 -        if (destname.length() > 0 && !destname.endsWith(
   52.27 -               DirectoryManager.URL_FILE_SEPARATOR)) {
   52.28 -            destname += DirectoryManager.URL_FILE_SEPARATOR;
   52.29 -        }
   52.30 -        String dest = destname + dir;
   52.31 +        File srcdir = new File(path, dir.getPath());
   52.32 +        File destdir = new File(configuration.docFileDestDirName, dir.getPath());
   52.33          try {
   52.34 -            File destdir = new File(dest);
   52.35 -            DirectoryManager.createDirectory(configuration, dest);
   52.36 +            createDirectory(configuration, destdir);
   52.37              String[] files = srcdir.list();
   52.38              for (int i = 0; i < files.length; i++) {
   52.39                  File srcfile = new File(srcdir, files[i]);
   52.40                  File destfile = new File(destdir, files[i]);
   52.41                  if (srcfile.isFile()) {
   52.42 -                    if(destfile.exists() && ! overwrite) {
   52.43 +                    if (destfile.exists() && ! overwrite) {
   52.44                          configuration.message.warning((SourcePosition) null,
   52.45                                  "doclet.Copy_Overwrite_warning",
   52.46                                  srcfile.toString(), destdir.toString());
   52.47 @@ -265,12 +254,11 @@
   52.48                              srcfile.toString(), destdir.toString());
   52.49                          Util.copyFile(destfile, srcfile);
   52.50                      }
   52.51 -                } else if(srcfile.isDirectory()) {
   52.52 -                    if(configuration.copydocfilesubdirs
   52.53 +                } else if (srcfile.isDirectory()) {
   52.54 +                    if (configuration.copydocfilesubdirs
   52.55                          && ! configuration.shouldExcludeDocFileDir(
   52.56                            srcfile.getName())){
   52.57 -                        copyDocFiles(configuration, path, dir +
   52.58 -                                    DirectoryManager.URL_FILE_SEPARATOR + srcfile.getName(),
   52.59 +                        copyDocFiles(configuration, path, dir.resolve(files[i]),
   52.60                                  overwrite);
   52.61                      }
   52.62                  }
   52.63 @@ -290,7 +278,7 @@
   52.64       * @param dirName The original directory name to copy from.
   52.65       */
   52.66      private static boolean checkCopyDocFilesErrors (Configuration configuration,
   52.67 -            String path, String dirName) {
   52.68 +            File path, DocPath dirName) {
   52.69          if ((configuration.sourcepath == null || configuration.sourcepath.length() == 0) &&
   52.70                 (configuration.destDirName == null || configuration.destDirName.length() == 0)) {
   52.71              //The destination path and source path are definitely equal.
   52.72 @@ -309,7 +297,7 @@
   52.73              }
   52.74          }
   52.75          //Make sure the doc-file being copied exists.
   52.76 -        File srcdir = new File(path + dirName);
   52.77 +        File srcdir = new File(path, dirName.getPath());
   52.78          if (! srcdir.exists()) {
   52.79              return true;
   52.80          }
   52.81 @@ -330,8 +318,7 @@
   52.82       */
   52.83      public static void copyResourceFile(Configuration configuration,
   52.84              String resourcefile, boolean overwrite) {
   52.85 -        String destresourcesdir = configuration.destDirName + RESOURCESDIR;
   52.86 -        copyFile(configuration, resourcefile, RESOURCESDIR, destresourcesdir,
   52.87 +        copyFile(configuration, resourcefile, DocPaths.RESOURCES, DocPaths.RESOURCES,
   52.88                  overwrite, false);
   52.89      }
   52.90  
   52.91 @@ -350,15 +337,24 @@
   52.92       * @param replaceNewLine true if the newline needs to be replaced with platform-
   52.93       *                  specific newline.
   52.94       */
   52.95 +    public static void copyFile(Configuration configuration, String file, DocPath source,
   52.96 +            DocPath destination, boolean overwrite, boolean replaceNewLine) {
   52.97 +        copyFile(configuration, file, source.getPath(), destination.getPath(),
   52.98 +                overwrite, replaceNewLine);
   52.99 +    }
  52.100 +
  52.101      public static void copyFile(Configuration configuration, String file, String source,
  52.102              String destination, boolean overwrite, boolean replaceNewLine) {
  52.103 -        DirectoryManager.createDirectory(configuration, destination);
  52.104 -        File destfile = new File(destination, file);
  52.105 -        if(destfile.exists() && (! overwrite)) return;
  52.106 +        File destdir = configuration.destDirName.isEmpty() ?
  52.107 +                (destination.isEmpty() ? null : new File(destination)) :
  52.108 +                new File(configuration.destDirName, destination);
  52.109 +        File destfile = (destdir == null) ? new File(file) : new File(destdir, file);
  52.110 +        createDirectory(configuration, destfile.getParentFile());
  52.111 +        if (destfile.exists() && (! overwrite)) return;
  52.112          try {
  52.113              InputStream in = Configuration.class.getResourceAsStream(
  52.114 -                    source + DirectoryManager.URL_FILE_SEPARATOR + file);
  52.115 -            if(in==null) return;
  52.116 +                    source + '/' + file);
  52.117 +            if (in == null) return;
  52.118              OutputStream out = new FileOutputStream(destfile);
  52.119              try {
  52.120                  if (!replaceNewLine) {
  52.121 @@ -396,26 +392,46 @@
  52.122      }
  52.123  
  52.124      /**
  52.125 +     * Given a path string create all the directories in the path. For example,
  52.126 +     * if the path string is "java/applet", the method will create directory
  52.127 +     * "java" and then "java/applet" if they don't exist. The file separator
  52.128 +     * string "/" is platform dependent system property.
  52.129 +     *
  52.130 +     * @param path Directory path string.
  52.131 +     */
  52.132 +    public static void createDirectory(Configuration configuration, File dir) {
  52.133 +        if (dir == null) {
  52.134 +            return;
  52.135 +        }
  52.136 +        if (dir.exists()) {
  52.137 +            return;
  52.138 +        } else {
  52.139 +            if (dir.mkdirs()) {
  52.140 +                return;
  52.141 +            } else {
  52.142 +                configuration.message.error(
  52.143 +                       "doclet.Unable_to_create_directory_0", dir.getPath());
  52.144 +                throw new DocletAbortException();
  52.145 +            }
  52.146 +        }
  52.147 +    }
  52.148 +
  52.149 +    /**
  52.150       * Given a PackageDoc, return the source path for that package.
  52.151       * @param configuration The Configuration for the current Doclet.
  52.152 -     * @param pkgDoc The package to seach the path for.
  52.153 +     * @param pkgDoc The package to search the path for.
  52.154       * @return A string representing the path to the given package.
  52.155       */
  52.156 -    public static String getPackageSourcePath(Configuration configuration,
  52.157 -            PackageDoc pkgDoc){
  52.158 -        try{
  52.159 -            String pkgPath = DirectoryManager.getDirectoryPath(pkgDoc);
  52.160 -            String completePath = new SourcePath(configuration.sourcepath).
  52.161 -                getDirectory(pkgPath) + DirectoryManager.URL_FILE_SEPARATOR;
  52.162 -            //Make sure that both paths are using the same separators.
  52.163 -            completePath = Util.replaceText(completePath, File.separator,
  52.164 -                    DirectoryManager.URL_FILE_SEPARATOR);
  52.165 -            pkgPath = Util.replaceText(pkgPath, File.separator,
  52.166 -                    DirectoryManager.URL_FILE_SEPARATOR);
  52.167 -            return completePath.substring(0, completePath.lastIndexOf(pkgPath));
  52.168 -        } catch (Exception e){
  52.169 -            return "";
  52.170 -        }
  52.171 +    public static File getPackageSourcePath(Configuration configuration,
  52.172 +            PackageDoc pkgDoc) {
  52.173 +        DocPath pkgPath = DocPath.forPackage(pkgDoc);
  52.174 +        File pkgDir = new SourcePath(configuration.sourcepath).getDirectory(pkgPath);
  52.175 +        if (pkgDir == null)
  52.176 +            return null;
  52.177 +        //Make sure that both paths are using the same separators.
  52.178 +        String completePath = Util.replaceText(pkgDir.getPath(), File.separator, "/");
  52.179 +        String pathForPkg = completePath.substring(0, completePath.lastIndexOf(pkgPath.getPath()));
  52.180 +        return new File(pathForPkg);
  52.181      }
  52.182  
  52.183      /**
  52.184 @@ -552,7 +568,7 @@
  52.185      }
  52.186  
  52.187      /**
  52.188 -     * Given a package, return it's name.
  52.189 +     * Given a package, return its name.
  52.190       * @param packageDoc the package to check.
  52.191       * @return the name of the given package.
  52.192       */
  52.193 @@ -562,7 +578,7 @@
  52.194      }
  52.195  
  52.196      /**
  52.197 -     * Given a package, return it's file name without the extension.
  52.198 +     * Given a package, return its file name without the extension.
  52.199       * @param packageDoc the package to check.
  52.200       * @return the file name of the given package.
  52.201       */
  52.202 @@ -572,7 +588,7 @@
  52.203      }
  52.204  
  52.205      /**
  52.206 -     * Given a string, replace all occurraces of 'newStr' with 'oldStr'.
  52.207 +     * Given a string, replace all occurrences of 'newStr' with 'oldStr'.
  52.208       * @param originalStr the string to modify.
  52.209       * @param oldStr the string to replace.
  52.210       * @param newStr the string to insert in place of the old string.
  52.211 @@ -637,22 +653,15 @@
  52.212       * @see java.io.FileOutputStream
  52.213       * @see java.io.OutputStreamWriter
  52.214       */
  52.215 -    public static Writer genWriter(Configuration configuration,
  52.216 -            String path, String filename,
  52.217 -            String docencoding)
  52.218 -        throws IOException, UnsupportedEncodingException {
  52.219 -        FileOutputStream fos;
  52.220 -        if (path != null) {
  52.221 -            DirectoryManager.createDirectory(configuration, path);
  52.222 -            fos = new FileOutputStream(((path.length() > 0)?
  52.223 -                                                  path + File.separator: "") + filename);
  52.224 -        } else {
  52.225 -            fos = new FileOutputStream(filename);
  52.226 -        }
  52.227 -        if (docencoding == null) {
  52.228 +    public static Writer genWriter(Configuration configuration, DocPath path)
  52.229 +            throws IOException, UnsupportedEncodingException {
  52.230 +        File file = path.resolveAgainst(configuration.destDirName);
  52.231 +        createDirectory(configuration, file.getParentFile());
  52.232 +        FileOutputStream fos = new FileOutputStream(file);
  52.233 +        if (configuration.docencoding == null) {
  52.234              return new BufferedWriter(new OutputStreamWriter(fos));
  52.235          } else {
  52.236 -            return new BufferedWriter(new OutputStreamWriter(fos, docencoding));
  52.237 +            return new BufferedWriter(new OutputStreamWriter(fos, configuration.docencoding));
  52.238          }
  52.239      }
  52.240  
    53.1 --- a/src/share/classes/com/sun/tools/javadoc/SerializedForm.java	Wed Oct 17 16:43:26 2012 +0100
    53.2 +++ b/src/share/classes/com/sun/tools/javadoc/SerializedForm.java	Tue Oct 23 13:20:37 2012 -0700
    53.3 @@ -237,6 +237,9 @@
    53.4  
    53.5          SerialFieldTag[] sfTag = spfDoc.serialFieldTags();
    53.6          for (int i = 0; i < sfTag.length; i++) {
    53.7 +            if (sfTag[i].fieldName() == null || sfTag[i].fieldType() == null) // ignore malformed @serialField tags
    53.8 +                continue;
    53.9 +
   53.10              Name fieldName = names.fromString(sfTag[i].fieldName());
   53.11  
   53.12              // Look for a FieldDocImpl that is documented by serialFieldTagImpl.
    54.1 --- a/test/com/sun/javadoc/testIndex/TestIndex.java	Wed Oct 17 16:43:26 2012 +0100
    54.2 +++ b/test/com/sun/javadoc/testIndex/TestIndex.java	Tue Oct 23 13:20:37 2012 -0700
    54.3 @@ -1,5 +1,5 @@
    54.4  /*
    54.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
    54.6 + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
    54.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    54.8   *
    54.9   * This code is free software; you can redistribute it and/or modify it
   54.10 @@ -53,28 +53,28 @@
   54.11  
   54.12          //Test index-all.html
   54.13          {BUG_ID + FS + "index-all.html",
   54.14 -            "<a href=\"./pkg/C.html\" title=\"class in pkg\"><span class=\"strong\">C</span></a>" +
   54.15 -            " - Class in <a href=\"./pkg/package-summary.html\">pkg</a>"},
   54.16 +            "<a href=\"pkg/C.html\" title=\"class in pkg\"><span class=\"strong\">C</span></a>" +
   54.17 +            " - Class in <a href=\"pkg/package-summary.html\">pkg</a>"},
   54.18          {BUG_ID + FS + "index-all.html",
   54.19 -            "<a href=\"./pkg/Interface.html\" title=\"interface in pkg\">" +
   54.20 +            "<a href=\"pkg/Interface.html\" title=\"interface in pkg\">" +
   54.21              "<span class=\"strong\">Interface</span></a> - Interface in " +
   54.22 -            "<a href=\"./pkg/package-summary.html\">pkg</a>"},
   54.23 +            "<a href=\"pkg/package-summary.html\">pkg</a>"},
   54.24          {BUG_ID + FS + "index-all.html",
   54.25 -            "<a href=\"./pkg/AnnotationType.html\" title=\"annotation in pkg\">" +
   54.26 +            "<a href=\"pkg/AnnotationType.html\" title=\"annotation in pkg\">" +
   54.27              "<span class=\"strong\">AnnotationType</span></a> - Annotation Type in " +
   54.28 -            "<a href=\"./pkg/package-summary.html\">pkg</a>"},
   54.29 +            "<a href=\"pkg/package-summary.html\">pkg</a>"},
   54.30          {BUG_ID + FS + "index-all.html",
   54.31 -            "<a href=\"./pkg/Coin.html\" title=\"enum in pkg\">" +
   54.32 +            "<a href=\"pkg/Coin.html\" title=\"enum in pkg\">" +
   54.33              "<span class=\"strong\">Coin</span></a> - Enum in " +
   54.34 -            "<a href=\"./pkg/package-summary.html\">pkg</a>"},
   54.35 +            "<a href=\"pkg/package-summary.html\">pkg</a>"},
   54.36          {BUG_ID + FS + "index-all.html",
   54.37 -            "Class in <a href=\"./package-summary.html\">&lt;Unnamed&gt;</a>"},
   54.38 +            "Class in <a href=\"package-summary.html\">&lt;Unnamed&gt;</a>"},
   54.39          {BUG_ID + FS + "index-all.html",
   54.40 -            "<dl>" + NL + "<dt><span class=\"strong\"><a href=\"./pkg/C.html#Java\">" +
   54.41 -            "Java</a></span> - Static variable in class pkg.<a href=\"./pkg/C.html\" " +
   54.42 +            "<dl>" + NL + "<dt><span class=\"strong\"><a href=\"pkg/C.html#Java\">" +
   54.43 +            "Java</a></span> - Static variable in class pkg.<a href=\"pkg/C.html\" " +
   54.44              "title=\"class in pkg\">C</a></dt>" + NL + "<dd>&nbsp;</dd>" + NL +
   54.45 -            "<dt><span class=\"strong\"><a href=\"./pkg/C.html#JDK\">JDK</a></span> " +
   54.46 -            "- Static variable in class pkg.<a href=\"./pkg/C.html\" title=\"class in pkg\">" +
   54.47 +            "<dt><span class=\"strong\"><a href=\"pkg/C.html#JDK\">JDK</a></span> " +
   54.48 +            "- Static variable in class pkg.<a href=\"pkg/C.html\" title=\"class in pkg\">" +
   54.49              "C</a></dt>" + NL + "<dd>&nbsp;</dd>" + NL + "</dl>"},
   54.50      };
   54.51      private static final String[][] NEGATED_TEST = NO_TEST;
    55.1 --- a/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java	Wed Oct 17 16:43:26 2012 +0100
    55.2 +++ b/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java	Tue Oct 23 13:20:37 2012 -0700
    55.3 @@ -1,5 +1,5 @@
    55.4  /*
    55.5 - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
    55.6 + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
    55.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    55.8   *
    55.9   * This code is free software; you can redistribute it and/or modify it
   55.10 @@ -663,14 +663,14 @@
   55.11              // TYPE PARAMETER IN INDEX
   55.12              //=================================
   55.13              {BUG_ID + FS + "index-all.html",
   55.14 -                "<span class=\"strong\"><a href=\"./pkg2/Foo.html#method(java.util.Vector)\">" +
   55.15 +                "<span class=\"strong\"><a href=\"pkg2/Foo.html#method(java.util.Vector)\">" +
   55.16                  "method(Vector&lt;Object&gt;)</a></span>"
   55.17              },
   55.18              //=================================
   55.19              // TYPE PARAMETER IN INDEX
   55.20              //=================================
   55.21              {BUG_ID + FS + "index-all.html",
   55.22 -                "<span class=\"strong\"><a href=\"./pkg2/Foo.html#method(java.util.Vector)\">" +
   55.23 +                "<span class=\"strong\"><a href=\"pkg2/Foo.html#method(java.util.Vector)\">" +
   55.24                  "method(Vector&lt;Object&gt;)</a></span>"
   55.25              },
   55.26          };
    56.1 --- a/test/com/sun/javadoc/testPackagePage/TestPackagePage.java	Wed Oct 17 16:43:26 2012 +0100
    56.2 +++ b/test/com/sun/javadoc/testPackagePage/TestPackagePage.java	Tue Oct 23 13:20:37 2012 -0700
    56.3 @@ -1,5 +1,5 @@
    56.4  /*
    56.5 - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
    56.6 + * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
    56.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    56.8   *
    56.9   * This code is free software; you can redistribute it and/or modify it
   56.10 @@ -52,7 +52,7 @@
   56.11              "<li><a href=\"com/pkg/package-summary.html\">Package</a></li>"
   56.12          },
   56.13          {BUG_ID + "-1" + FS + "index-all.html",
   56.14 -            "<li><a href=\"./com/pkg/package-summary.html\">Package</a></li>"
   56.15 +            "<li><a href=\"com/pkg/package-summary.html\">Package</a></li>"
   56.16          },
   56.17          {BUG_ID + "-1" + FS + "help-doc.html",
   56.18              "<li><a href=\"com/pkg/package-summary.html\">Package</a></li>"

mercurial