src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java

changeset 1746
bd51ca92c013
parent 1745
937aa020c667
child 1747
df4f44800923
equal deleted inserted replaced
1745:937aa020c667 1746:bd51ca92c013
989 /** 989 /**
990 * Return the link to the given package. 990 * Return the link to the given package.
991 * 991 *
992 * @param pkg the package to link to. 992 * @param pkg the package to link to.
993 * @param label the label for the link. 993 * @param label the label for the link.
994 * @param isStrong true if the label should be strong.
995 * @return the link to the given package.
996 */
997 public String getPackageLinkString(PackageDoc pkg, String label,
998 boolean isStrong) {
999 return getPackageLinkString(pkg, label, isStrong, "");
1000 }
1001
1002 /**
1003 * Return the link to the given package.
1004 *
1005 * @param pkg the package to link to.
1006 * @param label the label for the link.
1007 * @param isStrong true if the label should be strong.
1008 * @param style the font of the package link label.
1009 * @return the link to the given package.
1010 */
1011 public String getPackageLinkString(PackageDoc pkg, String label, boolean isStrong,
1012 String style) {
1013 boolean included = pkg != null && pkg.isIncluded();
1014 if (! included) {
1015 PackageDoc[] packages = configuration.packages;
1016 for (int i = 0; i < packages.length; i++) {
1017 if (packages[i].equals(pkg)) {
1018 included = true;
1019 break;
1020 }
1021 }
1022 }
1023 if (included || pkg == null) {
1024 return getHyperLinkString(pathString(pkg, DocPaths.PACKAGE_SUMMARY),
1025 label, isStrong, style);
1026 } else {
1027 DocLink crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg));
1028 if (crossPkgLink != null) {
1029 return getHyperLinkString(crossPkgLink, label, isStrong, style);
1030 } else {
1031 return label;
1032 }
1033 }
1034 }
1035
1036 /**
1037 * Return the link to the given package.
1038 *
1039 * @param pkg the package to link to.
1040 * @param label the label for the link.
1041 * @return a content tree for the package link. 994 * @return a content tree for the package link.
1042 */ 995 */
1043 public Content getPackageLink(PackageDoc pkg, String label) { 996 public Content getPackageLink(PackageDoc pkg, String label) {
1044 return getPackageLink(pkg, new StringContent(label)); 997 return getPackageLink(pkg, new StringContent(label));
1045 } 998 }
1300 */ 1253 */
1301 public Content getDocLink(LinkInfoImpl.Kind context, ClassDoc classDoc, MemberDoc doc, 1254 public Content getDocLink(LinkInfoImpl.Kind context, ClassDoc classDoc, MemberDoc doc,
1302 String label, boolean strong) { 1255 String label, boolean strong) {
1303 return getDocLink(context, classDoc, doc, label, strong, false); 1256 return getDocLink(context, classDoc, doc, label, strong, false);
1304 } 1257 }
1258 public Content getDocLink(LinkInfoImpl.Kind context, ClassDoc classDoc, MemberDoc doc,
1259 Content label, boolean strong) {
1260 return getDocLink(context, classDoc, doc, label, strong, false);
1261 }
1305 1262
1306 /** 1263 /**
1307 * Return the link for the given member. 1264 * Return the link for the given member.
1308 * 1265 *
1309 * @param context the id of the context where the link will be printed. 1266 * @param context the id of the context where the link will be printed.
1316 * @param isProperty true if the doc parameter is a JavaFX property. 1273 * @param isProperty true if the doc parameter is a JavaFX property.
1317 * @return the link for the given member. 1274 * @return the link for the given member.
1318 */ 1275 */
1319 public Content getDocLink(LinkInfoImpl.Kind context, ClassDoc classDoc, MemberDoc doc, 1276 public Content getDocLink(LinkInfoImpl.Kind context, ClassDoc classDoc, MemberDoc doc,
1320 String label, boolean strong, boolean isProperty) { 1277 String label, boolean strong, boolean isProperty) {
1321 return getDocLink(context, classDoc, doc, new RawHtml(label), strong, isProperty); 1278 return getDocLink(context, classDoc, doc, new StringContent(check(label)), strong, isProperty);
1279 }
1280
1281 String check(String s) {
1282 if (s.matches(".*[&<>].*"))throw new IllegalArgumentException(s);
1283 return s;
1322 } 1284 }
1323 1285
1324 public Content getDocLink(LinkInfoImpl.Kind context, ClassDoc classDoc, MemberDoc doc, 1286 public Content getDocLink(LinkInfoImpl.Kind context, ClassDoc classDoc, MemberDoc doc,
1325 Content label, boolean strong, boolean isProperty) { 1287 Content label, boolean strong, boolean isProperty) {
1326 if (! (doc.isIncluded() || 1288 if (! (doc.isIncluded() ||
1485 } 1447 }
1486 1448
1487 text = plainOrCode(plain, new StringContent(refMemName)); 1449 text = plainOrCode(plain, new StringContent(refMemName));
1488 1450
1489 return getDocLink(LinkInfoImpl.Kind.SEE_TAG, containing, 1451 return getDocLink(LinkInfoImpl.Kind.SEE_TAG, containing,
1490 refMem, (label.isEmpty() ? text: label).toString(), false); 1452 refMem, (label.isEmpty() ? text: label), false);
1491 } 1453 }
1492 } 1454 }
1493 1455
1494 private Content plainOrCode(boolean plain, Content body) { 1456 private Content plainOrCode(boolean plain, Content body) {
1495 return (plain || body.isEmpty()) ? body : HtmlTree.CODE(body); 1457 return (plain || body.isEmpty()) ? body : HtmlTree.CODE(body);

mercurial