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

changeset 1747
df4f44800923
parent 1746
bd51ca92c013
child 1748
051b728cfe90
     1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Tue May 14 10:14:55 2013 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Tue May 14 10:14:55 2013 -0700
     1.3 @@ -350,7 +350,7 @@
     1.4              int profileValue) {
     1.5          if(classes.length > 0) {
     1.6              Arrays.sort(classes);
     1.7 -            Content caption = getTableCaption(label);
     1.8 +            Content caption = getTableCaption(new RawHtml(label));
     1.9              Content table = HtmlTree.TABLE(HtmlStyle.packageSummary, 0, 3, 0,
    1.10                      tableSummary, caption);
    1.11              table.addContent(getSummaryTableHeader(tableHeader, "col"));
    1.12 @@ -869,8 +869,7 @@
    1.13       * @param rawText the caption for the table which could be raw Html
    1.14       * @return a content tree for the caption
    1.15       */
    1.16 -    public Content getTableCaption(String rawText) {
    1.17 -        Content title = new RawHtml(rawText);
    1.18 +    public Content getTableCaption(Content title) {
    1.19          Content captionSpan = HtmlTree.SPAN(title);
    1.20          Content space = getSpace();
    1.21          Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, space);
    1.22 @@ -938,7 +937,7 @@
    1.23              String tableSummary, String[] tableHeader, Content contentTree) {
    1.24          if (deprPkgs.size() > 0) {
    1.25              Content table = HtmlTree.TABLE(0, 3, 0, tableSummary,
    1.26 -                    getTableCaption(configuration.getText(headingKey)));
    1.27 +                    getTableCaption(configuration.getResource(headingKey)));
    1.28              table.addContent(getSummaryTableHeader(tableHeader, "col"));
    1.29              Content tbody = new HtmlTree(HtmlTag.TBODY);
    1.30              for (int i = 0; i < deprPkgs.size(); i++) {
    1.31 @@ -1573,7 +1572,7 @@
    1.32       */
    1.33      public Content commentTagsToContent(Tag holderTag, Doc doc, Tag[] tags,
    1.34              boolean isFirstSentence) {
    1.35 -        ContentBuilder result = new ContentBuilder();
    1.36 +        Content result = new ContentBuilder();
    1.37          boolean textTagChange = false;
    1.38          // Array of all possible inline tags for this javadoc run
    1.39          configuration.tagletManager.checkTags(doc, tags, true);
    1.40 @@ -1890,7 +1889,7 @@
    1.41      }
    1.42  
    1.43      /**
    1.44 -     * Adds the annotatation types for the given doc.
    1.45 +     * Adds the annotation types for the given doc.
    1.46       *
    1.47       * @param indent the number of extra spaces to indent the annotations.
    1.48       * @param doc the doc to write annotations for.
    1.49 @@ -1900,16 +1899,14 @@
    1.50       */
    1.51      private boolean addAnnotationInfo(int indent, Doc doc,
    1.52              AnnotationDesc[] descList, boolean lineBreak, Content htmltree) {
    1.53 -        List<String> annotations = getAnnotations(indent, descList, lineBreak);
    1.54 +        List<Content> annotations = getAnnotations(indent, descList, lineBreak);
    1.55          String sep ="";
    1.56 -        if (annotations.size() == 0) {
    1.57 +        if (annotations.isEmpty()) {
    1.58              return false;
    1.59          }
    1.60 -        Content annotationContent;
    1.61 -        for (Iterator<String> iter = annotations.iterator(); iter.hasNext();) {
    1.62 +        for (Content annotation: annotations) {
    1.63              htmltree.addContent(sep);
    1.64 -            annotationContent = new RawHtml(iter.next());
    1.65 -            htmltree.addContent(annotationContent);
    1.66 +            htmltree.addContent(annotation);
    1.67              sep = " ";
    1.68          }
    1.69          return true;
    1.70 @@ -1925,7 +1922,7 @@
    1.71       * @return an array of strings representing the annotations being
    1.72       *         documented.
    1.73       */
    1.74 -    private List<String> getAnnotations(int indent, AnnotationDesc[] descList, boolean linkBreak) {
    1.75 +    private List<Content> getAnnotations(int indent, AnnotationDesc[] descList, boolean linkBreak) {
    1.76          return getAnnotations(indent, descList, linkBreak, true);
    1.77      }
    1.78  
    1.79 @@ -1944,10 +1941,10 @@
    1.80       * @return an array of strings representing the annotations being
    1.81       *         documented.
    1.82       */
    1.83 -    public List<String> getAnnotations(int indent, AnnotationDesc[] descList, boolean linkBreak,
    1.84 +    public List<Content> getAnnotations(int indent, AnnotationDesc[] descList, boolean linkBreak,
    1.85              boolean isJava5DeclarationLocation) {
    1.86 -        List<String> results = new ArrayList<String>();
    1.87 -        StringBuilder annotation;
    1.88 +        List<Content> results = new ArrayList<Content>();
    1.89 +        ContentBuilder annotation;
    1.90          for (int i = 0; i < descList.length; i++) {
    1.91              AnnotationTypeDoc annotationDoc = descList[i].annotationType();
    1.92              // If an annotation is not documented, do not add it to the list. If
    1.93 @@ -1964,7 +1961,7 @@
    1.94              if  (Util.isDeclarationAnnotation(annotationDoc, isJava5DeclarationLocation)) {
    1.95                  continue;
    1.96              }*/
    1.97 -            annotation = new StringBuilder();
    1.98 +            annotation = new ContentBuilder();
    1.99              isAnnotationDocumented = false;
   1.100              LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
   1.101                  LinkInfoImpl.Kind.ANNOTATION, annotationDoc);
   1.102 @@ -1983,8 +1980,8 @@
   1.103                      }
   1.104                      String sep = "";
   1.105                      for (AnnotationValue av : annotationTypeValues) {
   1.106 -                        annotation.append(sep);
   1.107 -                        annotation.append(annotationValueToString(av));
   1.108 +                        annotation.addContent(sep);
   1.109 +                        annotation.addContent(annotationValueToContent(av));
   1.110                          sep = " ";
   1.111                      }
   1.112                  }
   1.113 @@ -2000,8 +1997,8 @@
   1.114                      annotationTypeValues.addAll(Arrays.asList(annotationArray));
   1.115                      String sep = "";
   1.116                      for (AnnotationValue av : annotationTypeValues) {
   1.117 -                        annotation.append(sep);
   1.118 -                        annotation.append(annotationValueToString(av));
   1.119 +                        annotation.addContent(sep);
   1.120 +                        annotation.addContent(annotationValueToContent(av));
   1.121                          sep = " ";
   1.122                      }
   1.123                  }
   1.124 @@ -2016,8 +2013,8 @@
   1.125                  addAnnotations(annotationDoc, linkInfo, annotation, pairs,
   1.126                          indent, linkBreak);
   1.127              }
   1.128 -            annotation.append(linkBreak ? DocletConstants.NL : "");
   1.129 -            results.add(annotation.toString());
   1.130 +            annotation.addContent(linkBreak ? DocletConstants.NL : "");
   1.131 +            results.add(annotation);
   1.132          }
   1.133          return results;
   1.134      }
   1.135 @@ -2033,26 +2030,26 @@
   1.136       * @param linkBreak if true, add new line between each member value
   1.137       */
   1.138      private void addAnnotations(AnnotationTypeDoc annotationDoc, LinkInfoImpl linkInfo,
   1.139 -            StringBuilder annotation, AnnotationDesc.ElementValuePair[] pairs,
   1.140 +            ContentBuilder annotation, AnnotationDesc.ElementValuePair[] pairs,
   1.141              int indent, boolean linkBreak) {
   1.142          linkInfo.label = new StringContent("@" + annotationDoc.name());
   1.143 -        annotation.append(getLink(linkInfo));
   1.144 +        annotation.addContent(getLink(linkInfo));
   1.145          if (pairs.length > 0) {
   1.146 -            annotation.append('(');
   1.147 +            annotation.addContent("(");
   1.148              for (int j = 0; j < pairs.length; j++) {
   1.149                  if (j > 0) {
   1.150 -                    annotation.append(",");
   1.151 +                    annotation.addContent(",");
   1.152                      if (linkBreak) {
   1.153 -                        annotation.append(DocletConstants.NL);
   1.154 +                        annotation.addContent(DocletConstants.NL);
   1.155                          int spaces = annotationDoc.name().length() + 2;
   1.156                          for (int k = 0; k < (spaces + indent); k++) {
   1.157 -                            annotation.append(' ');
   1.158 +                            annotation.addContent(" ");
   1.159                          }
   1.160                      }
   1.161                  }
   1.162 -                annotation.append(getDocLink(LinkInfoImpl.Kind.ANNOTATION,
   1.163 +                annotation.addContent(getDocLink(LinkInfoImpl.Kind.ANNOTATION,
   1.164                          pairs[j].element(), pairs[j].element().name(), false));
   1.165 -                annotation.append('=');
   1.166 +                annotation.addContent("=");
   1.167                  AnnotationValue annotationValue = pairs[j].value();
   1.168                  List<AnnotationValue> annotationTypeValues = new ArrayList<AnnotationValue>();
   1.169                  if (annotationValue.value() instanceof AnnotationValue[]) {
   1.170 @@ -2062,17 +2059,17 @@
   1.171                  } else {
   1.172                      annotationTypeValues.add(annotationValue);
   1.173                  }
   1.174 -                annotation.append(annotationTypeValues.size() == 1 ? "" : "{");
   1.175 +                annotation.addContent(annotationTypeValues.size() == 1 ? "" : "{");
   1.176                  String sep = "";
   1.177                  for (AnnotationValue av : annotationTypeValues) {
   1.178 -                    annotation.append(sep);
   1.179 -                    annotation.append(annotationValueToString(av));
   1.180 +                    annotation.addContent(sep);
   1.181 +                    annotation.addContent(annotationValueToContent(av));
   1.182                      sep = ",";
   1.183                  }
   1.184 -                annotation.append(annotationTypeValues.size() == 1 ? "" : "}");
   1.185 +                annotation.addContent(annotationTypeValues.size() == 1 ? "" : "}");
   1.186                  isContainerDocumented = false;
   1.187              }
   1.188 -            annotation.append(")");
   1.189 +            annotation.addContent(")");
   1.190          }
   1.191      }
   1.192  
   1.193 @@ -2107,7 +2104,7 @@
   1.194          return false;
   1.195      }
   1.196  
   1.197 -    private String annotationValueToString(AnnotationValue annotationValue) {
   1.198 +    private Content annotationValueToContent(AnnotationValue annotationValue) {
   1.199          if (annotationValue.value() instanceof Type) {
   1.200              Type type = (Type) annotationValue.value();
   1.201              if (type.asClassDoc() != null) {
   1.202 @@ -2116,25 +2113,25 @@
   1.203                  linkInfo.label = new StringContent((type.asClassDoc().isIncluded() ?
   1.204                      type.typeName() :
   1.205                      type.qualifiedTypeName()) + type.dimension() + ".class");
   1.206 -                return getLink(linkInfo).toString();
   1.207 +                return getLink(linkInfo);
   1.208              } else {
   1.209 -                return type.typeName() + type.dimension() + ".class";
   1.210 +                return new StringContent(type.typeName() + type.dimension() + ".class");
   1.211              }
   1.212          } else if (annotationValue.value() instanceof AnnotationDesc) {
   1.213 -            List<String> list = getAnnotations(0,
   1.214 +            List<Content> list = getAnnotations(0,
   1.215                  new AnnotationDesc[]{(AnnotationDesc) annotationValue.value()},
   1.216                      false);
   1.217 -            StringBuilder buf = new StringBuilder();
   1.218 -            for (String s: list) {
   1.219 -                buf.append(s);
   1.220 +            ContentBuilder buf = new ContentBuilder();
   1.221 +            for (Content c: list) {
   1.222 +                buf.addContent(c);
   1.223              }
   1.224 -            return buf.toString();
   1.225 +            return buf;
   1.226          } else if (annotationValue.value() instanceof MemberDoc) {
   1.227              return getDocLink(LinkInfoImpl.Kind.ANNOTATION,
   1.228                  (MemberDoc) annotationValue.value(),
   1.229 -                ((MemberDoc) annotationValue.value()).name(), false).toString();
   1.230 +                ((MemberDoc) annotationValue.value()).name(), false);
   1.231           } else {
   1.232 -            return annotationValue.toString();
   1.233 +            return new StringContent(annotationValue.toString());
   1.234           }
   1.235      }
   1.236  

mercurial