< prev index next >

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java

Print this page




  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.javadoc.internal.doclets.formats.html;
  27 
  28 import java.util.List;
  29 
  30 import javax.lang.model.element.Element;



  31 import javax.lang.model.element.TypeElement;
  32 import javax.lang.model.element.VariableElement;
  33 import javax.lang.model.type.TypeMirror;
  34 import javax.lang.model.util.SimpleElementVisitor9;
  35 
  36 import com.sun.source.doctree.DocTree;

  37 import com.sun.source.doctree.IndexTree;
  38 import com.sun.source.doctree.SystemPropertyTree;
  39 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
  40 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
  41 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
  42 import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
  43 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
  44 import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
  45 import jdk.javadoc.internal.doclets.toolkit.Content;
  46 import jdk.javadoc.internal.doclets.toolkit.DocletElement;
  47 import jdk.javadoc.internal.doclets.toolkit.Resources;
  48 import jdk.javadoc.internal.doclets.toolkit.builders.SerializedFormBuilder;
  49 import jdk.javadoc.internal.doclets.toolkit.taglets.TagletWriter;
  50 import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
  51 import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
  52 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
  53 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
  54 import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
  55 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
  56 


 252         if (utils.isClass(holder) && utils.isSerializable((TypeElement)holder)) {
 253             //Automatically add link to serialized form page for serializable classes.
 254             if (SerializedFormBuilder.serialInclude(utils, holder) &&
 255                       SerializedFormBuilder.serialInclude(utils, utils.containingPackage(holder))) {
 256                 appendSeparatorIfNotEmpty(body);
 257                 DocPath serialPath = htmlWriter.pathToRoot.resolve(DocPaths.SERIALIZED_FORM);
 258                 DocLink link = serialPath.fragment(utils.getFullyQualifiedName(holder));
 259                 body.add(htmlWriter.links.createLink(link,
 260                         new StringContent(resources.getText("doclet.Serialized_Form"))));
 261             }
 262         }
 263         if (body.isEmpty())
 264             return body;
 265 
 266         ContentBuilder result = new ContentBuilder();
 267         result.add(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.seeLabel,
 268                 new StringContent(resources.getText("doclet.See_Also")))));
 269         result.add(HtmlTree.DD(body));
 270         return result;
 271 




















 272     }
 273 
 274     private void appendSeparatorIfNotEmpty(ContentBuilder body) {
 275         if (!body.isEmpty()) {
 276             body.add(", ");
 277             body.add(DocletConstants.NL);
 278         }
 279     }
 280 
 281     /**
 282      * {@inheritDoc}
 283      */
 284     public Content simpleTagOutput(Element element, List<? extends DocTree> simpleTags, String header) {
 285         CommentHelper ch = utils.getCommentHelper(element);
 286         ContentBuilder result = new ContentBuilder();
 287         result.add(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.simpleTagLabel, new RawHtml(header))));
 288         ContentBuilder body = new ContentBuilder();
 289         boolean many = false;
 290         for (DocTree simpleTag : simpleTags) {
 291             if (many) {




  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.javadoc.internal.doclets.formats.html;
  27 
  28 import java.util.List;
  29 
  30 import javax.lang.model.element.Element;
  31 import javax.lang.model.element.ExecutableElement;
  32 import javax.lang.model.element.ModuleElement;
  33 import javax.lang.model.element.PackageElement;
  34 import javax.lang.model.element.TypeElement;
  35 import javax.lang.model.element.VariableElement;
  36 import javax.lang.model.type.TypeMirror;
  37 import javax.lang.model.util.SimpleElementVisitor9;
  38 
  39 import com.sun.source.doctree.DocTree;
  40 import com.sun.source.doctree.DocTree.Kind;
  41 import com.sun.source.doctree.IndexTree;
  42 import com.sun.source.doctree.SystemPropertyTree;
  43 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
  44 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
  45 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
  46 import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
  47 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
  48 import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
  49 import jdk.javadoc.internal.doclets.toolkit.Content;
  50 import jdk.javadoc.internal.doclets.toolkit.DocletElement;
  51 import jdk.javadoc.internal.doclets.toolkit.Resources;
  52 import jdk.javadoc.internal.doclets.toolkit.builders.SerializedFormBuilder;
  53 import jdk.javadoc.internal.doclets.toolkit.taglets.TagletWriter;
  54 import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
  55 import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
  56 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
  57 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
  58 import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
  59 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
  60 


 256         if (utils.isClass(holder) && utils.isSerializable((TypeElement)holder)) {
 257             //Automatically add link to serialized form page for serializable classes.
 258             if (SerializedFormBuilder.serialInclude(utils, holder) &&
 259                       SerializedFormBuilder.serialInclude(utils, utils.containingPackage(holder))) {
 260                 appendSeparatorIfNotEmpty(body);
 261                 DocPath serialPath = htmlWriter.pathToRoot.resolve(DocPaths.SERIALIZED_FORM);
 262                 DocLink link = serialPath.fragment(utils.getFullyQualifiedName(holder));
 263                 body.add(htmlWriter.links.createLink(link,
 264                         new StringContent(resources.getText("doclet.Serialized_Form"))));
 265             }
 266         }
 267         if (body.isEmpty())
 268             return body;
 269 
 270         ContentBuilder result = new ContentBuilder();
 271         result.add(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.seeLabel,
 272                 new StringContent(resources.getText("doclet.See_Also")))));
 273         result.add(HtmlTree.DD(body));
 274         return result;
 275 
 276     }
 277 
 278     public Content accessorTagOutput(Element holder, List<? extends DocTree> tags) {
 279         if (!tags.isEmpty()) {
 280             //Todo: check that there's only one tag
 281             DocTree.Kind kind = tags.get(0).getKind();
 282             ExecutableElement accessor = utils.findAccessorFor((VariableElement)holder, kind);
 283             //add reference to getter/setter
 284             Content body = htmlWriter.getDocLink(LinkInfoImpl.Kind.SEE_TAG, (TypeElement)holder.getEnclosingElement(),
 285                     accessor, accessor.getSimpleName() + utils.makeSignature(accessor, true), false, false);
 286             ContentBuilder result = new ContentBuilder();
 287             String key = kind == Kind.GETTER ?
 288                     "doclet.getter" : "doclet.setter";
 289             result.add(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.seeLabel,
 290                     new StringContent(resources.getText(key)))));
 291             result.add(HtmlTree.DD(body));
 292             return result;
 293         } else {
 294             return new ContentBuilder();
 295         }
 296     }
 297 
 298     private void appendSeparatorIfNotEmpty(ContentBuilder body) {
 299         if (!body.isEmpty()) {
 300             body.add(", ");
 301             body.add(DocletConstants.NL);
 302         }
 303     }
 304 
 305     /**
 306      * {@inheritDoc}
 307      */
 308     public Content simpleTagOutput(Element element, List<? extends DocTree> simpleTags, String header) {
 309         CommentHelper ch = utils.getCommentHelper(element);
 310         ContentBuilder result = new ContentBuilder();
 311         result.add(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.simpleTagLabel, new RawHtml(header))));
 312         ContentBuilder body = new ContentBuilder();
 313         boolean many = false;
 314         for (DocTree simpleTag : simpleTags) {
 315             if (many) {


< prev index next >