765N/A/*
765N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
765N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
765N/A *
765N/A * This code is free software; you can redistribute it and/or modify it
765N/A * under the terms of the GNU General Public License version 2 only, as
765N/A * published by the Free Software Foundation. Oracle designates this
765N/A * particular file as subject to the "Classpath" exception as provided
765N/A * by Oracle in the LICENSE file that accompanied this code.
765N/A *
765N/A * This code is distributed in the hope that it will be useful, but WITHOUT
765N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
765N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
765N/A * version 2 for more details (a copy is included in the LICENSE file that
765N/A * accompanied this code).
765N/A *
765N/A * You should have received a copy of the GNU General Public License version
765N/A * 2 along with this work; if not, write to the Free Software Foundation,
765N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
765N/A *
765N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
765N/A * or visit www.oracle.com if you need additional information or have any
765N/A * questions.
765N/A */
765N/A
765N/Apackage com.sun.tools.doclets.formats.html.markup;
765N/A
765N/Aimport com.sun.tools.doclets.internal.toolkit.Content;
765N/Aimport com.sun.tools.doclets.internal.toolkit.util.*;
765N/A
765N/A/**
765N/A * Class for generating string content for HTML tags of javadoc output.
765N/A *
765N/A * @author Bhavesh Patel
765N/A */
765N/Apublic class StringContent extends Content{
765N/A
765N/A private StringBuilder stringContent;
765N/A
765N/A /**
765N/A * Constructor to construct StringContent object.
765N/A */
765N/A public StringContent() {
765N/A stringContent = new StringBuilder();
765N/A }
765N/A
765N/A /**
765N/A * Constructor to construct StringContent object with some initial content.
765N/A *
765N/A * @param initialContent initial content for the object
765N/A */
765N/A public StringContent(String initialContent) {
765N/A stringContent = new StringBuilder(
765N/A Util.escapeHtmlChars(nullCheck(initialContent)));
765N/A }
765N/A
765N/A /**
765N/A * This method is not supported by the class.
765N/A *
765N/A * @param content content that needs to be added
765N/A * @throws DocletAbortException this method will always throw a
765N/A * DocletAbortException because it
765N/A * is not supported.
765N/A */
765N/A public void addContent(Content content) {
765N/A throw new DocletAbortException();
765N/A }
765N/A
765N/A /**
765N/A * Adds content for the StringContent object. The method escapes
765N/A * HTML characters for the string content that is added.
765N/A *
765N/A * @param strContent string content to be added
765N/A */
765N/A public void addContent(String strContent) {
765N/A stringContent.append(Util.escapeHtmlChars(nullCheck(strContent)));
765N/A }
765N/A
765N/A /**
765N/A * {@inheritDoc}
765N/A */
765N/A public boolean isEmpty() {
765N/A return (stringContent.length() == 0);
765N/A }
765N/A
765N/A /**
765N/A * {@inheritDoc}
765N/A */
765N/A public String toString() {
765N/A return stringContent.toString();
765N/A }
765N/A
765N/A /**
765N/A * {@inheritDoc}
765N/A */
765N/A public void write(StringBuilder contentBuilder) {
765N/A contentBuilder.append(stringContent);
765N/A }
765N/A}