001: /*
002: * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025: package com.sun.tools.doclets.internal.toolkit.util;
026:
027: import com.sun.javadoc.*;
028:
029: /**
030: * A tag that holds nothing but plain text. This is useful for passing
031: * text to methods that only accept inline tags as a parameter.
032: *
033: * This code is not part of an API.
034: * It is implementation that is subject to change.
035: * Do not use it as an API
036: *
037: * @author Jamie Ho
038: * @since 1.5
039: */
040: public class TextTag implements Tag {
041: protected final String text;
042: protected final String name = "Text";
043: protected final Doc holder;
044:
045: /**
046: * Constructor
047: */
048: public TextTag(Doc holder, String text) {
049: super ();
050: this .holder = holder;
051: this .text = text;
052: }
053:
054: /**
055: * {@inheritDoc}
056: */
057: public String name() {
058: return name;
059: }
060:
061: /**
062: * {@inheritDoc}
063: */
064: public Doc holder() {
065: return holder;
066: }
067:
068: /**
069: * {@inheritDoc}
070: */
071: public String kind() {
072: return name;
073: }
074:
075: /**
076: * {@inheritDoc}
077: */
078: public String text() {
079: return text;
080: }
081:
082: /**
083: * {@inheritDoc}
084: */
085: public String toString() {
086: return name + ":" + text;
087: }
088:
089: /**
090: * {@inheritDoc}
091: */
092: public Tag[] inlineTags() {
093: return new Tag[] { this };
094: }
095:
096: /**
097: * {@inheritDoc}
098: */
099: public Tag[] firstSentenceTags() {
100: return new Tag[] { this };
101: }
102:
103: /**
104: * {@inheritDoc}
105: */
106: public SourcePosition position() {
107: return holder.position();
108: }
109: }
|