1 /* 2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.tools.javadoc.main; 27 28 import com.sun.javadoc.*; 29 30 /** 31 * Represents a @throws or @exception documentation tag. 32 * Parses and holds the exception name and exception comment. 33 * The exception name my be the name of a type variable. 34 * Note: @exception is a backwards compatible synonymy for @throws. 35 * 36 * <p><b>This is NOT part of any supported API. 37 * If you write code that depends on this, you do so at your own risk. 38 * This code and its internal interfaces are subject to change or 39 * deletion without notice.</b> 40 * 41 * @author Robert Field 42 * @author Atul M Dambalkar 43 * @see ExecutableMemberDocImpl#throwsTags() 44 * 45 */ 46 @Deprecated(since="9", forRemoval=true) 47 @SuppressWarnings("removal") 48 class ThrowsTagImpl extends TagImpl implements ThrowsTag { 49 50 private final String exceptionName; 51 private final String exceptionComment; 52 53 /** 54 * Cached inline tags. 55 */ 56 private Tag[] inlineTags; 57 ThrowsTagImpl(DocImpl holder, String name, String text)58 ThrowsTagImpl(DocImpl holder, String name, String text) { 59 super(holder, name, text); 60 String[] sa = divideAtWhite(); 61 exceptionName = sa[0]; 62 exceptionComment = sa[1]; 63 } 64 65 /** 66 * Return the exception name. 67 */ exceptionName()68 public String exceptionName() { 69 return exceptionName; 70 } 71 72 /** 73 * Return the exception comment. 74 */ exceptionComment()75 public String exceptionComment() { 76 return exceptionComment; 77 } 78 79 /** 80 * Return the exception as a ClassDocImpl. 81 */ exception()82 public ClassDoc exception() { 83 ClassDocImpl exceptionClass; 84 if (!(holder instanceof ExecutableMemberDoc)) { 85 exceptionClass = null; 86 } else { 87 ExecutableMemberDocImpl emd = (ExecutableMemberDocImpl)holder; 88 ClassDocImpl con = (ClassDocImpl)emd.containingClass(); 89 exceptionClass = (ClassDocImpl)con.findClass(exceptionName); 90 } 91 return exceptionClass; 92 } 93 94 /** 95 * Return the type that represents the exception. 96 * This may be a <code>ClassDoc</code> or a <code>TypeVariable</code>. 97 */ exceptionType()98 public Type exceptionType() { 99 //###(gj) TypeVariable not yet supported. 100 return exception(); 101 } 102 103 104 /** 105 * Return the kind of this tag. Always "@throws" for instances 106 * of ThrowsTagImpl. 107 */ 108 @Override kind()109 public String kind() { 110 return "@throws"; 111 } 112 113 /** 114 * For the exception comment with embedded @link tags return the array of 115 * TagImpls consisting of SeeTagImpl(s) and text containing TagImpl(s). 116 * 117 * @return TagImpl[] Array of tags with inline SeeTagImpls. 118 * @see TagImpl#inlineTags() 119 * @see ParamTagImpl#inlineTags() 120 */ 121 @Override inlineTags()122 public Tag[] inlineTags() { 123 if (inlineTags == null) { 124 inlineTags = Comment.getInlineTags(holder, exceptionComment()); 125 } 126 return inlineTags; 127 } 128 } 129