001: /*
002: * Copyright 1997-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:
026: package com.sun.tools.javadoc;
027:
028: import com.sun.javadoc.*;
029:
030: /**
031: * Represents a @throws or @exception documentation tag.
032: * Parses and holds the exception name and exception comment.
033: * The exception name my be the name of a type variable.
034: * Note: @exception is a backwards compatible synonymy for @throws.
035: *
036: * @author Robert Field
037: * @author Atul M Dambalkar
038: * @see ExecutableMemberDocImpl#throwsTags()
039: *
040: */
041: class ThrowsTagImpl extends TagImpl implements ThrowsTag {
042:
043: private final String exceptionName;
044: private final String exceptionComment;
045:
046: ThrowsTagImpl(DocImpl holder, String name, String text) {
047: super (holder, name, text);
048: String[] sa = divideAtWhite();
049: exceptionName = sa[0];
050: exceptionComment = sa[1];
051: }
052:
053: /**
054: * Return the exception name.
055: */
056: public String exceptionName() {
057: return exceptionName;
058: }
059:
060: /**
061: * Return the exception comment.
062: */
063: public String exceptionComment() {
064: return exceptionComment;
065: }
066:
067: /**
068: * Return the exception as a ClassDocImpl.
069: */
070: public ClassDoc exception() {
071: ClassDocImpl exceptionClass;
072: if (!(holder instanceof ExecutableMemberDoc)) {
073: exceptionClass = null;
074: } else {
075: ExecutableMemberDocImpl emd = (ExecutableMemberDocImpl) holder;
076: ClassDocImpl con = (ClassDocImpl) emd.containingClass();
077: exceptionClass = (ClassDocImpl) con
078: .findClass(exceptionName);
079: }
080: return exceptionClass;
081: }
082:
083: /**
084: * Return the type that represents the exception.
085: * This may be a <code>ClassDoc</code> or a <code>TypeVariable</code>.
086: */
087: public Type exceptionType() {
088: //###(gj) TypeVariable not yet supported.
089: return exception();
090: }
091:
092: /**
093: * Return the kind of this tag. Always "@throws" for instances
094: * of ThrowsTagImpl.
095: */
096: public String kind() {
097: return "@throws";
098: }
099:
100: /**
101: * For the exception comment with embedded @link tags return the array of
102: * TagImpls consisting of SeeTagImpl(s) and text containing TagImpl(s).
103: *
104: * @return TagImpl[] Array of tags with inline SeeTagImpls.
105: * @see TagImpl#inlineTagImpls()
106: * @see ParamTagImpl#inlineTagImpls()
107: */
108: public Tag[] inlineTags() {
109: return Comment.getInlineTags(holder, exceptionComment());
110: }
111: }
|