langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java
changeset 14357 faf9cde2817b
parent 14266 69453558960d
child 14358 9eda9239cba0
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java	Wed Oct 17 16:43:26 2012 +0100
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java	Tue Oct 23 13:20:37 2012 -0700
@@ -31,6 +31,8 @@
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.formats.html.ConfigurationImpl;
 import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.DocPath;
+import com.sun.tools.doclets.internal.toolkit.util.DocPaths;
 
 
 /**
@@ -56,25 +58,11 @@
      *
      * @param filename String file name.
      */
-    public HtmlDocWriter(Configuration configuration,
-                         String filename) throws IOException {
-        super(configuration,
-              null, configuration.destDirName + filename,
-              configuration.docencoding);
-        // use File to normalize file separators
+    public HtmlDocWriter(Configuration configuration, DocPath filename)
+            throws IOException {
+        super(configuration, filename);
         configuration.message.notice("doclet.Generating_0",
-            new File(configuration.destDirName, filename));
-    }
-
-    public HtmlDocWriter(Configuration configuration,
-                         String path, String filename) throws IOException {
-        super(configuration,
-              configuration.destDirName + path, filename,
-              configuration.docencoding);
-        // use File to normalize file separators
-        configuration.message.notice("doclet.Generating_0",
-            new File(configuration.destDirName,
-                    ((path.length() > 0)? path + File.separator: "") + filename));
+            filename.resolveAgainst(configuration.destDirName));
     }
 
     /**
@@ -92,7 +80,7 @@
      * @param strong       Boolean that sets label to strong.
      * @return String    Hyper Link.
      */
-    public String getHyperLinkString(String link, String where,
+    public String getHyperLinkString(DocPath link, String where,
                                String label, boolean strong) {
         return getHyperLinkString(link, where, label, strong, "", "", "");
     }
@@ -108,7 +96,7 @@
      * @param stylename  String style of text defined in style sheet.
      * @return String    Hyper Link.
      */
-    public String getHyperLinkString(String link, String where,
+    public String getHyperLinkString(DocPath link, String where,
                                String label, boolean strong,
                                String stylename) {
         return getHyperLinkString(link, where, label, strong, stylename, "", "");
@@ -117,13 +105,26 @@
     /**
      * Get Html Hyper Link string.
      *
+     * @param where      Position of the link in the file. Character '#' is not
+     *                   needed.
+     * @param label      Tag for the link.
+     * @return a content tree for the hyper link
+     */
+    public Content getHyperLink(String where,
+                               Content label) {
+        return getHyperLink(DocPath.empty, where, label, "", "");
+    }
+
+    /**
+     * Get Html Hyper Link string.
+     *
      * @param link       String name of the file.
      * @param where      Position of the link in the file. Character '#' is not
      *                   needed.
      * @param label      Tag for the link.
      * @return a content tree for the hyper link
      */
-    public Content getHyperLink(String link, String where,
+    public Content getHyperLink(DocPath link, String where,
                                Content label) {
         return getHyperLink(link, where, label, "", "");
     }
@@ -141,6 +142,13 @@
      * @param target     Target frame.
      * @return String    Hyper Link.
      */
+    public String getHyperLinkString(DocPath link, String where,
+                               String label, boolean strong,
+                               String stylename, String title, String target) {
+        return getHyperLinkString(link.getPath(), where, label, strong,
+                stylename, title, target);
+    }
+
     public String getHyperLinkString(String link, String where,
                                String label, boolean strong,
                                String stylename, String title, String target) {
@@ -189,8 +197,13 @@
      * @param target     Target frame.
      * @return a content tree for the hyper link.
      */
+    public Content getHyperLink(DocPath link, String where,
+            Content label, String title, String target) {
+        return getHyperLink(link.getPath(), where, label, title, target);
+    }
     public Content getHyperLink(String link, String where,
             Content label, String title, String target) {
+        if (link.startsWith("/")) Thread.dumpStack();
         if (where != null && where.length() != 0) {
             link += "#" + where;
         }
@@ -211,7 +224,7 @@
      * @param label Label for the link
      * @return a content for the hyperlink to the file
      */
-    public Content getHyperLink(String link, Content label) {
+    public Content getHyperLink(DocPath link, Content label) {
         return getHyperLink(link, "", label);
     }
 
@@ -222,7 +235,7 @@
      * @param label      Tag for the link.
      * @return Strign    Hyper link.
      */
-    public String getHyperLinkString(String link, String label) {
+    public String getHyperLinkString(DocPath link, String label) {
         return getHyperLinkString(link, "", label, false);
     }