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

changeset 2212
4cb9de4dd420
parent 2163
8746caa5cf80
child 2218
2d0a0ae7fa9c
     1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Tue Dec 03 18:13:18 2013 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Tue Dec 03 14:21:45 2013 -0800
     1.3 @@ -148,43 +148,28 @@
     1.4          StringBuilder buf = new StringBuilder();
     1.5          int previndex = 0;
     1.6          while (true) {
     1.7 -            if (configuration.docrootparent.length() > 0) {
     1.8 -                final String docroot_parent = "{@docroot}/..";
     1.9 -                // Search for lowercase version of {@docRoot}/..
    1.10 -                index = lowerHtml.indexOf(docroot_parent, previndex);
    1.11 -                // If next {@docRoot}/.. pattern not found, append rest of htmlstr and exit loop
    1.12 -                if (index < 0) {
    1.13 -                    buf.append(htmlstr.substring(previndex));
    1.14 -                    break;
    1.15 -                }
    1.16 -                // If next {@docroot}/.. pattern found, append htmlstr up to start of tag
    1.17 -                buf.append(htmlstr.substring(previndex, index));
    1.18 -                previndex = index + docroot_parent.length();
    1.19 -                // Insert docrootparent absolute path where {@docRoot}/.. was located
    1.20 -
    1.21 +            final String docroot = "{@docroot}";
    1.22 +            // Search for lowercase version of {@docRoot}
    1.23 +            index = lowerHtml.indexOf(docroot, previndex);
    1.24 +            // If next {@docRoot} tag not found, append rest of htmlstr and exit loop
    1.25 +            if (index < 0) {
    1.26 +                buf.append(htmlstr.substring(previndex));
    1.27 +                break;
    1.28 +            }
    1.29 +            // If next {@docroot} tag found, append htmlstr up to start of tag
    1.30 +            buf.append(htmlstr.substring(previndex, index));
    1.31 +            previndex = index + docroot.length();
    1.32 +            if (configuration.docrootparent.length() > 0 && htmlstr.startsWith("/..", previndex)) {
    1.33 +                // Insert the absolute link if {@docRoot} is followed by "/..".
    1.34                  buf.append(configuration.docrootparent);
    1.35 -                // Append slash if next character is not a slash
    1.36 -                if (previndex < htmlstr.length() && htmlstr.charAt(previndex) != '/') {
    1.37 -                    buf.append('/');
    1.38 -                }
    1.39 +                previndex += 3;
    1.40              } else {
    1.41 -                final String docroot = "{@docroot}";
    1.42 -                // Search for lowercase version of {@docRoot}
    1.43 -                index = lowerHtml.indexOf(docroot, previndex);
    1.44 -                // If next {@docRoot} tag not found, append rest of htmlstr and exit loop
    1.45 -                if (index < 0) {
    1.46 -                    buf.append(htmlstr.substring(previndex));
    1.47 -                    break;
    1.48 -                }
    1.49 -                // If next {@docroot} tag found, append htmlstr up to start of tag
    1.50 -                buf.append(htmlstr.substring(previndex, index));
    1.51 -                previndex = index + docroot.length();
    1.52                  // Insert relative path where {@docRoot} was located
    1.53                  buf.append(pathToRoot.isEmpty() ? "." : pathToRoot.getPath());
    1.54 -                // Append slash if next character is not a slash
    1.55 -                if (previndex < htmlstr.length() && htmlstr.charAt(previndex) != '/') {
    1.56 -                    buf.append('/');
    1.57 -                }
    1.58 +            }
    1.59 +            // Append slash if next character is not a slash
    1.60 +            if (previndex < htmlstr.length() && htmlstr.charAt(previndex) != '/') {
    1.61 +                buf.append('/');
    1.62              }
    1.63          }
    1.64          return buf.toString();
    1.65 @@ -1604,26 +1589,30 @@
    1.66                  result.addContent(seeTagToContent((SeeTag) tagelem));
    1.67              } else if (! tagName.equals("Text")) {
    1.68                  boolean wasEmpty = result.isEmpty();
    1.69 -                Content output = TagletWriter.getInlineTagOuput(
    1.70 -                    configuration.tagletManager, holderTag,
    1.71 -                    tagelem, getTagletWriterInstance(isFirstSentence));
    1.72 +                Content output;
    1.73 +                if (configuration.docrootparent.length() > 0
    1.74 +                        && tagelem.name().equals("@docRoot")
    1.75 +                        && ((tags[i + 1]).text()).startsWith("/..")) {
    1.76 +                    // If Xdocrootparent switch ON, set the flag to remove the /.. occurrence after
    1.77 +                    // {@docRoot} tag in the very next Text tag.
    1.78 +                    textTagChange = true;
    1.79 +                    // Replace the occurrence of {@docRoot}/.. with the absolute link.
    1.80 +                    output = new StringContent(configuration.docrootparent);
    1.81 +                } else {
    1.82 +                    output = TagletWriter.getInlineTagOuput(
    1.83 +                            configuration.tagletManager, holderTag,
    1.84 +                            tagelem, getTagletWriterInstance(isFirstSentence));
    1.85 +                }
    1.86                  if (output != null)
    1.87                      result.addContent(output);
    1.88                  if (wasEmpty && isFirstSentence && tagelem.name().equals("@inheritDoc") && !result.isEmpty()) {
    1.89                      break;
    1.90 -                } else if (configuration.docrootparent.length() > 0 &&
    1.91 -                        tagelem.name().equals("@docRoot") &&
    1.92 -                        ((tags[i + 1]).text()).startsWith("/..")) {
    1.93 -                    //If Xdocrootparent switch ON, set the flag to remove the /.. occurance after
    1.94 -                    //{@docRoot} tag in the very next Text tag.
    1.95 -                    textTagChange = true;
    1.96 -                    continue;
    1.97                  } else {
    1.98                      continue;
    1.99                  }
   1.100              } else {
   1.101                  String text = tagelem.text();
   1.102 -                //If Xdocrootparent switch ON, remove the /.. occurance after {@docRoot} tag.
   1.103 +                //If Xdocrootparent switch ON, remove the /.. occurrence after {@docRoot} tag.
   1.104                  if (textTagChange) {
   1.105                      text = text.replaceFirst("/..", "");
   1.106                      textTagChange = false;

mercurial