0N/A/*
553N/A * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
553N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
553N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
553N/A * or visit www.oracle.com if you need additional information or have any
553N/A * questions.
0N/A */
0N/A
0N/Apackage com.sun.tools.javadoc;
0N/A
0N/Aimport com.sun.javadoc.*;
0N/A
0N/A/**
0N/A * Represents a documentation tag, e.g. @since, @author, @version.
0N/A * Given a tag (e.g. "@since 1.2"), holds tag name (e.g. "@since")
0N/A * and tag text (e.g. "1.2"). TagImpls with structure or which require
0N/A * special processing are handled by subclasses (ParamTagImpl, SeeTagImpl,
0N/A * and ThrowsTagImpl
0N/A *
0N/A * @author Robert Field
0N/A * @author Atul M Dambalkar
0N/A * @author Neal M Gafter
0N/A * @see SeeTagImpl
0N/A * @see ParamTagImpl
0N/A * @see ThrowsTagImpl
0N/A * @see Doc#tags()
0N/A *
0N/A */
0N/Aclass TagImpl implements Tag {
0N/A
0N/A protected final String text;
0N/A protected final String name;
0N/A protected final DocImpl holder;
0N/A
0N/A /**
0N/A * Cached first sentence.
0N/A */
0N/A private Tag[] firstSentence;
0N/A
0N/A /**
0N/A * Cached inline tags.
0N/A */
0N/A private Tag[] inlineTags;
0N/A
0N/A /**
0N/A * Constructor
0N/A */
0N/A TagImpl(DocImpl holder, String name, String text) {
0N/A this.holder = holder;
0N/A this.name = name;
0N/A this.text = text;
0N/A }
0N/A
0N/A /**
0N/A * Return the name of this tag.
0N/A */
0N/A public String name() {
0N/A return name;
0N/A }
0N/A
0N/A /**
0N/A * Return the containing {@link Doc} of this Tag element.
0N/A */
0N/A public Doc holder() {
0N/A return holder;
0N/A }
0N/A
0N/A /**
0N/A * Return the kind of this tag.
0N/A */
0N/A public String kind() {
0N/A return name;
0N/A }
0N/A
0N/A /**
0N/A * Return the text of this tag, that is, portion beyond tag name.
0N/A */
0N/A public String text() {
0N/A return text;
0N/A }
0N/A
0N/A DocEnv docenv() {
0N/A return holder.env;
0N/A }
0N/A
0N/A /**
0N/A * for use by subclasses which have two part tag text.
0N/A */
0N/A String[] divideAtWhite() {
0N/A String[] sa = new String[2];
0N/A int len = text.length();
0N/A // if no white space found
0N/A sa[0] = text;
0N/A sa[1] = "";
0N/A for (int inx = 0; inx < len; ++inx) {
0N/A char ch = text.charAt(inx);
0N/A if (Character.isWhitespace(ch)) {
0N/A sa[0] = text.substring(0, inx);
0N/A for (; inx < len; ++inx) {
0N/A ch = text.charAt(inx);
0N/A if (!Character.isWhitespace(ch)) {
0N/A sa[1] = text.substring(inx, len);
0N/A break;
0N/A }
0N/A }
0N/A break;
0N/A }
0N/A }
0N/A return sa;
0N/A }
0N/A
0N/A /**
0N/A * convert this object to a string.
0N/A */
0N/A public String toString() {
0N/A return name + ":" + text;
0N/A }
0N/A
0N/A /**
0N/A * For documentation comment with embedded @link tags, return the array of
0N/A * TagImpls consisting of SeeTagImpl(s) and text containing TagImpl(s).
0N/A * Within a comment string "This is an example of inline tags for a
0N/A * documentation comment {@link Doc {@link Doc commentlabel}}",
0N/A * where inside the inner braces, the first "Doc" carries exctly the same
0N/A * syntax as a SeeTagImpl and the second "commentlabel" is label for the Html
0N/A * Link, will return an array of TagImpl(s) with first element as TagImpl with
0N/A * comment text "This is an example of inline tags for a documentation
0N/A * comment" and second element as SeeTagImpl with referenced class as "Doc"
0N/A * and the label for the Html Link as "commentlabel".
0N/A *
0N/A * @return TagImpl[] Array of tags with inline SeeTagImpls.
0N/A * @see ParamTagImpl
0N/A * @see ThrowsTagImpl
0N/A */
0N/A public Tag[] inlineTags() {
0N/A if (inlineTags == null) {
0N/A inlineTags = Comment.getInlineTags(holder, text);
0N/A }
0N/A return inlineTags;
0N/A }
0N/A
0N/A /**
0N/A * Return array of tags for the first sentence in the doc comment text.
0N/A */
0N/A public Tag[] firstSentenceTags() {
0N/A if (firstSentence == null) {
0N/A //Parse all sentences first to avoid duplicate warnings.
0N/A inlineTags();
0N/A try {
0N/A docenv().setSilent(true);
0N/A firstSentence = Comment.firstSentenceTags(holder, text);
0N/A } finally {
0N/A docenv().setSilent(false);
0N/A }
0N/A }
0N/A return firstSentence;
0N/A }
0N/A
0N/A /**
0N/A * Return the doc item to which this tag is attached.
0N/A * @return the doc item to which this tag is attached.
0N/A */
0N/A public SourcePosition position() {
0N/A return holder.position();
0N/A }
0N/A}