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

Tue, 14 May 2013 10:14:54 -0700

author
jjg
date
Tue, 14 May 2013 10:14:54 -0700
changeset 1744
76a691e3e961
parent 1743
6a5288a298fd
permissions
-rw-r--r--

8012176: reduce use of TagletOutputImpl.toString
Reviewed-by: darcy

duke@1 1 /*
jjg@1743 2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
ohair@554 7 * published by the Free Software Foundation. Oracle designates this
duke@1 8 * particular file as subject to the "Classpath" exception as provided
ohair@554 9 * by Oracle in the LICENSE file that accompanied this code.
duke@1 10 *
duke@1 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 * accompanied this code).
duke@1 16 *
duke@1 17 * You should have received a copy of the GNU General Public License version
duke@1 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 *
ohair@554 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 22 * or visit www.oracle.com if you need additional information or have any
ohair@554 23 * questions.
duke@1 24 */
duke@1 25
duke@1 26 package com.sun.tools.doclets.formats.html;
duke@1 27
jjg@1743 28 import com.sun.tools.doclets.formats.html.markup.ContentBuilder;
jjg@1743 29 import com.sun.tools.doclets.formats.html.markup.RawHtml;
jjg@1743 30 import com.sun.tools.doclets.internal.toolkit.Content;
duke@1 31 import com.sun.tools.doclets.internal.toolkit.taglets.*;
duke@1 32
duke@1 33 /**
duke@1 34 * The output for HTML taglets.
duke@1 35 *
jjg@1359 36 * <p><b>This is NOT part of any supported API.
jjg@1359 37 * If you write code that depends on this, you do so at your own risk.
jjg@1359 38 * This code and its internal interfaces are subject to change or
jjg@1359 39 * deletion without notice.</b>
jjg@1359 40 *
duke@1 41 * @since 1.5
duke@1 42 * @author Jamie Ho
jjg@1743 43 * @author Jonathan Gibbons (rewrite)
duke@1 44 */
duke@1 45
duke@1 46 public class TagletOutputImpl implements TagletOutput {
duke@1 47
jjg@1743 48 private ContentBuilder content;
jjg@1743 49
jjg@1743 50 public TagletOutputImpl() {
jjg@1743 51 content = new ContentBuilder();
jjg@1743 52 }
duke@1 53
duke@1 54 public TagletOutputImpl(String o) {
duke@1 55 setOutput(o);
duke@1 56 }
duke@1 57
jjg@1743 58 public TagletOutputImpl(Content c) {
jjg@1743 59 setOutput(c);
jjg@1743 60 }
jjg@1743 61
jjg@1744 62 Content getContent() {
jjg@1744 63 return content;
jjg@1744 64 }
jjg@1744 65
duke@1 66 /**
duke@1 67 * {@inheritDoc}
duke@1 68 */
duke@1 69 public void setOutput (Object o) {
jjg@1743 70 content = new ContentBuilder();
jjg@1743 71 if (o != null) {
jjg@1743 72 if (o instanceof String)
jjg@1743 73 content.addContent(new RawHtml((String) o));
jjg@1743 74 else if (o instanceof Content)
jjg@1743 75 content.addContent((Content) o);
jjg@1743 76 else if (o instanceof TagletOutputImpl)
jjg@1743 77 content.addContent(((TagletOutputImpl) o).content);
jjg@1743 78 else
jjg@1743 79 throw new IllegalArgumentException(o.getClass().getName());
jjg@1743 80 }
duke@1 81 }
duke@1 82
duke@1 83 /**
duke@1 84 * {@inheritDoc}
duke@1 85 */
duke@1 86 public void appendOutput(TagletOutput o) {
jjg@1743 87 if (o instanceof TagletOutputImpl)
jjg@1743 88 content.addContent(((TagletOutputImpl) o).content);
jjg@1743 89 else
jjg@1743 90 throw new IllegalArgumentException(o.getClass().getName());
duke@1 91 }
duke@1 92
duke@1 93 public String toString() {
jjg@1743 94 return content.toString();
duke@1 95 }
duke@1 96
duke@1 97 }

mercurial