1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java Tue Nov 30 09:38:48 2010 -0800 1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java Wed Dec 01 11:02:38 2010 -0800 1.3 @@ -87,7 +87,7 @@ 1.4 */ 1.5 public void printHyperLink(String link, String where, 1.6 String label, boolean strong) { 1.7 - print(getHyperLink(link, where, label, strong, "", "", "")); 1.8 + print(getHyperLinkString(link, where, label, strong, "", "", "")); 1.9 } 1.10 1.11 /** 1.12 @@ -115,7 +115,7 @@ 1.13 public void printHyperLink(String link, String where, 1.14 String label, boolean strong, 1.15 String stylename) { 1.16 - print(getHyperLink(link, where, label, strong, stylename, "", "")); 1.17 + print(getHyperLinkString(link, where, label, strong, stylename, "", "")); 1.18 } 1.19 1.20 /** 1.21 @@ -128,9 +128,9 @@ 1.22 * @param strong Boolean that sets label to strong. 1.23 * @return String Hyper Link. 1.24 */ 1.25 - public String getHyperLink(String link, String where, 1.26 + public String getHyperLinkString(String link, String where, 1.27 String label, boolean strong) { 1.28 - return getHyperLink(link, where, label, strong, "", "", ""); 1.29 + return getHyperLinkString(link, where, label, strong, "", "", ""); 1.30 } 1.31 1.32 /** 1.33 @@ -144,10 +144,24 @@ 1.34 * @param stylename String style of text defined in style sheet. 1.35 * @return String Hyper Link. 1.36 */ 1.37 - public String getHyperLink(String link, String where, 1.38 + public String getHyperLinkString(String link, String where, 1.39 String label, boolean strong, 1.40 String stylename) { 1.41 - return getHyperLink(link, where, label, strong, stylename, "", ""); 1.42 + return getHyperLinkString(link, where, label, strong, stylename, "", ""); 1.43 + } 1.44 + 1.45 + /** 1.46 + * Get Html Hyper Link string. 1.47 + * 1.48 + * @param link String name of the file. 1.49 + * @param where Position of the link in the file. Character '#' is not 1.50 + * needed. 1.51 + * @param label Tag for the link. 1.52 + * @return a content tree for the hyper link 1.53 + */ 1.54 + public Content getHyperLink(String link, String where, 1.55 + Content label) { 1.56 + return getHyperLink(link, where, label, "", ""); 1.57 } 1.58 1.59 /** 1.60 @@ -163,11 +177,11 @@ 1.61 * @param target Target frame. 1.62 * @return String Hyper Link. 1.63 */ 1.64 - public String getHyperLink(String link, String where, 1.65 + public String getHyperLinkString(String link, String where, 1.66 String label, boolean strong, 1.67 String stylename, String title, String target) { 1.68 StringBuffer retlink = new StringBuffer(); 1.69 - retlink.append("<A HREF=\""); 1.70 + retlink.append("<a href=\""); 1.71 retlink.append(link); 1.72 if (where != null && where.length() != 0) { 1.73 retlink.append("#"); 1.74 @@ -187,27 +201,54 @@ 1.75 retlink.append("\">"); 1.76 } 1.77 if (strong) { 1.78 - retlink.append("<STRONG>"); 1.79 + retlink.append("<span class=\"strong\">"); 1.80 } 1.81 retlink.append(label); 1.82 if (strong) { 1.83 - retlink.append("</STRONG>"); 1.84 + retlink.append("</span>"); 1.85 } 1.86 if (stylename != null && stylename.length() != 0) { 1.87 retlink.append("</FONT>"); 1.88 } 1.89 - retlink.append("</A>"); 1.90 + retlink.append("</a>"); 1.91 return retlink.toString(); 1.92 } 1.93 1.94 /** 1.95 - * Print link without positioning in the file. 1.96 + * Get Html Hyper Link. 1.97 * 1.98 * @param link String name of the file. 1.99 + * @param where Position of the link in the file. Character '#' is not 1.100 + * needed. 1.101 * @param label Tag for the link. 1.102 + * @param title String that describes the link's content for accessibility. 1.103 + * @param target Target frame. 1.104 + * @return a content tree for the hyper link. 1.105 */ 1.106 - public void printHyperLink(String link, String label) { 1.107 - print(getHyperLink(link, "", label, false)); 1.108 + public Content getHyperLink(String link, String where, 1.109 + Content label, String title, String target) { 1.110 + if (where != null && where.length() != 0) { 1.111 + link += "#" + where; 1.112 + } 1.113 + HtmlTree anchor = HtmlTree.A(link, label); 1.114 + if (title != null && title.length() != 0) { 1.115 + anchor.addAttr(HtmlAttr.TITLE, title); 1.116 + } 1.117 + if (target != null && target.length() != 0) { 1.118 + anchor.addAttr(HtmlAttr.TARGET, target); 1.119 + } 1.120 + return anchor; 1.121 + } 1.122 + 1.123 + /** 1.124 + * Get a hyperlink to a file. 1.125 + * 1.126 + * @param link String name of the file 1.127 + * @param label Label for the link 1.128 + * @return a content for the hyperlink to the file 1.129 + */ 1.130 + public Content getHyperLink(String link, Content label) { 1.131 + return getHyperLink(link, "", label); 1.132 } 1.133 1.134 /** 1.135 @@ -217,8 +258,8 @@ 1.136 * @param label Tag for the link. 1.137 * @return Strign Hyper link. 1.138 */ 1.139 - public String getHyperLink(String link, String label) { 1.140 - return getHyperLink(link, "", label, false); 1.141 + public String getHyperLinkString(String link, String label) { 1.142 + return getHyperLinkString(link, "", label, false); 1.143 } 1.144 1.145 /** 1.146 @@ -273,54 +314,32 @@ 1.147 * Print the frameset version of the Html file header. 1.148 * Called only when generating an HTML frameset file. 1.149 * 1.150 - * @param title Title of this HTML document. 1.151 + * @param title Title of this HTML document 1.152 + * @param noTimeStamp If true, don't print time stamp in header 1.153 + * @param frameset the frameset to be added to the HTML document 1.154 */ 1.155 - public void printFramesetHeader(String title) { 1.156 - printFramesetHeader(title, false); 1.157 - } 1.158 - 1.159 - /** 1.160 - * Print the frameset version of the Html file header. 1.161 - * Called only when generating an HTML frameset file. 1.162 - * 1.163 - * @param title Title of this HTML document. 1.164 - * @param noTimeStamp If true, don't print time stamp in header. 1.165 - */ 1.166 - public void printFramesetHeader(String title, boolean noTimeStamp) { 1.167 - println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 " + 1.168 - "Frameset//EN\" " + 1.169 - "\"http://www.w3.org/TR/html4/frameset.dtd\">"); 1.170 - println("<!--NewPage-->"); 1.171 - html(); 1.172 - head(); 1.173 + public void printFramesetDocument(String title, boolean noTimeStamp, 1.174 + Content frameset) { 1.175 + Content htmlDocType = DocType.Frameset(); 1.176 + Content htmlComment = new Comment(configuration.getText("doclet.New_Page")); 1.177 + Content head = new HtmlTree(HtmlTag.HEAD); 1.178 if (! noTimeStamp) { 1.179 - print("<!-- Generated by javadoc on "); 1.180 - print(today()); 1.181 - println("-->"); 1.182 + Content headComment = new Comment("Generated by javadoc on " + today()); 1.183 + head.addContent(headComment); 1.184 } 1.185 if (configuration.charset.length() > 0) { 1.186 - println("<META http-equiv=\"Content-Type\" content=\"text/html; " 1.187 - + "charset=" + configuration.charset + "\">"); 1.188 + Content meta = HtmlTree.META("Content-Type", "text/html", 1.189 + configuration.charset); 1.190 + head.addContent(meta); 1.191 } 1.192 - title(); 1.193 - println(title); 1.194 - titleEnd(); 1.195 - //Script to set the classFrame if necessary. 1.196 - script(); 1.197 - println(" targetPage = \"\" + window.location.search;"); 1.198 - println(" if (targetPage != \"\" && targetPage != \"undefined\")"); 1.199 - println(" targetPage = targetPage.substring(1);"); 1.200 - println(" if (targetPage.indexOf(\":\") != -1)"); 1.201 - println(" targetPage = \"undefined\";"); 1.202 - 1.203 - println(" function loadFrames() {"); 1.204 - println(" if (targetPage != \"\" && targetPage != \"undefined\")"); 1.205 - println(" top.classFrame.location = top.targetPage;"); 1.206 - println(" }"); 1.207 - scriptEnd(); 1.208 - noScript(); 1.209 - noScriptEnd(); 1.210 - headEnd(); 1.211 + Content windowTitle = HtmlTree.TITLE(new StringContent(title)); 1.212 + head.addContent(windowTitle); 1.213 + head.addContent(getFramesetJavaScript()); 1.214 + Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(), 1.215 + head, frameset); 1.216 + Content htmlDocument = new HtmlDocument(htmlDocType, 1.217 + htmlComment, htmlTree); 1.218 + print(htmlDocument.toString()); 1.219 } 1.220 1.221 /**