uTools-Manuals/docs/java/javax/lang/model/AnnotatedConstruct.html

231 lines
18 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div class="header">
<div class="subTitle">
compact3
</div>
<div class="subTitle">
javax.lang.model
</div>
<h2 class="title" title="Interface AnnotatedConstruct">Interface AnnotatedConstruct</h2>
</div><div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>
All Known Subinterfaces:
</dt>
<dd>
<span><a href="../../../javax/lang/model/type/ArrayType.html" title="javax.lang.model.type中的接口">ArrayType</a> <a href="../../../javax/lang/model/type/DeclaredType.html" title="javax.lang.model.type中的接口">DeclaredType</a> <a href="../../../javax/lang/model/element/Element.html" title="javax.lang.model.element中的接口">Element</a> <a href="../../../javax/lang/model/type/ErrorType.html" title="javax.lang.model.type中的接口">ErrorType</a> <a href="../../../javax/lang/model/element/ExecutableElement.html" title="javax.lang.model.element中的接口">ExecutableElement</a> <a href="../../../javax/lang/model/type/ExecutableType.html" title="javax.lang.model.type中的接口">ExecutableType</a> <a href="../../../javax/lang/model/type/IntersectionType.html" title="javax.lang.model.type中的接口">IntersectionType</a> <a href="../../../javax/lang/model/type/NoType.html" title="javax.lang.model.type中的接口">NoType</a> <a href="../../../javax/lang/model/type/NullType.html" title="javax.lang.model.type中的接口">NullType</a> <a href="../../../javax/lang/model/element/PackageElement.html" title="javax.lang.model.element中的接口">PackageElement</a> <a href="../../../javax/lang/model/element/Parameterizable.html" title="javax.lang.model.element中的接口">Parameterizable</a> <a href="../../../javax/lang/model/type/PrimitiveType.html" title="javax.lang.model.type中的接口">PrimitiveType</a> <a href="../../../javax/lang/model/element/QualifiedNameable.html" title="javax.lang.model.element中的接口">QualifiedNameable</a> <a href="../../../javax/lang/model/type/ReferenceType.html" title="javax.lang.model.type中的接口">ReferenceType</a> <a href="../../../javax/lang/model/element/TypeElement.html" title="javax.lang.model.element中的接口">TypeElement</a> <a href="../../../javax/lang/model/type/TypeMirror.html" title="javax.lang.model.type中的接口">TypeMirror</a> <a href="../../../javax/lang/model/element/TypeParameterElement.html" title="javax.lang.model.element中的接口">TypeParameterElement</a> <a href="../../../javax/lang/model/type/TypeVariable.html" title="javax.lang.model.type中的接口">TypeVariable</a> <a href="../../../javax/lang/model/type/UnionType.html" title="javax.lang.model.type中的接口">UnionType</a> <a href="../../../javax/lang/model/element/VariableElement.html" title="javax.lang.model.element中的接口">VariableElement</a> <a href="../../../javax/lang/model/type/WildcardType.html" title="javax.lang.model.type中的接口">WildcardType</a></span>
</dd>
</dl>
<hr/> <br/> <pre>public interface <span class="typeNameLabel">AnnotatedConstruct</span></pre>
<div class="block">
<span>表示可以注释的构造。</span>
<span>一个构造是<a href="../../../javax/lang/model/element/Element.html" title="javax.lang.model.element中的接口">element</a><a href="../../../javax/lang/model/type/TypeMirror.html" title="javax.lang.model.type中的接口">type</a></span>
<span>元素上的<em>注释位于声明上</em> ,而类型上的<em>注释</em>是特定<em>用途</em>的类型名称。</span>
<span><em>直接呈现</em> <em>呈现</em> <em>间接呈现</em><em>关联的术语</em>在整个<em>界面</em>中被使用以精确描述本文定义的方法返回哪些注释。</span>
<p> <span>在下面的定义中,注释<i>A</i>具有注释类型<i>AT</i></span> <span>如果<i>AT</i>是可重复的注释类型,则包含注释的类型是<i>ATC</i></span> </p>
<p> <span>注释<i>A</i> <em>直接存在</em>于构造<i>C</i>上:</span> </p>
<ul>
<li> <span><i>A</i>被明确或隐含地声明为适用于<i>C</i>的源代码表示。</span> <p> <span>通常,如果类型<i>AT的</i>一个注释出现在<i>C</i>表示的源代码中,则<i>A</i>被明确声明为适用于<i>C。</i></span> <span>如果在<i>C</i>上存在多个类型<i>AT的</i>注释,则如果<i>AT</i>是可重复的注释类型,则在<i>C</i>上隐式声明类型<i>ATC</i>的注释。</span> </p></li>
<li> <span><i>A</i>的表示显示在对<i>C</i>可执行输出,如<code>RuntimeVisibleAnnotations</code><code>RuntimeVisibleParameterAnnotations</code>一个类文件的属性。</span> </li>
</ul>
<p> <span>注释<i>A</i> <em>存在</em>于构造<i>C</i>上:</span> </p>
<ul>
<li> <span><i>A</i>直接出现在<i>C上</i></span> </li>
<li> <span>类型的<i>AT</i>没有注释是直接存在于<i>C</i>以及<i>C</i>是一类和<i>AT</i>是可继承和<i>A</i>为存在于<i>C</i>的超类。</span> </li>
</ul>
<span>注释<i>A</i> <em>间接存在</em>于构造<i>C</i>上:</span>
<ul>
<li> <span><i>AT</i>是具有包含注释类型<i>ATC的</i>可重复注释类型。</span> </li>
<li> <span>类型<i>ATC</i>的注释直接出现在<i>C上</i> <i>A</i>是包含在调用<i>ATC</i>直接注释的<code>value</code>方法的结果中的<code>value</code></span> </li>
</ul>
<span>注释<i>A</i>与构建体<i>C</i>如果任一<em>相关联的</em> </span>
<ul>
<li> <span><i>A</i>直接或间接出现在<i>C上</i></span> </li>
<li> <span>类型的<i>AT</i>没有注释是直接或间接地存在于<i>C</i>以及<i>C</i>是一类,和<i>AT</i>是可继承,和<i>A</i><i>C</i>的超类相关联。</span> </li>
</ul>
</div>
<dl>
<dt>
<span class="simpleTagLabel">从以下版本开始:</span>
</dt>
<dd>
1.8
</dd>
<dt>
<span class="simpleTagLabel">See <cite> The Java™ Language Specification</cite>:</span>
</dt>
<dd>
9.6注释类型9.6.3.3 @继承
</dd>
</dl> </li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method.summary">
<!-- --> </a> <h3>方法摘要</h3>
<table border="0" cellpadding="3" cellspacing="0" class="memberSummary" summary="Method Summary table, listing methods, and an explanation">
<caption>
<span class="activeTableTab" id="t0"><span>所有方法</span><span class="tabEnd"> </span></span>
<span class="tableTab" id="t2"><span><a href="javascript:show(2);">接口方法</a></span><span class="tabEnd"> </span></span>
<span class="tableTab" id="t3"><span><a href="javascript:show(4);">抽象方法</a></span><span class="tabEnd"> </span></span>
</caption>
<tbody>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor" id="i0">
<td class="colFirst"><code>&lt;A extends <a href="../../../java/lang/annotation/Annotation.html" title="interface in java.lang.annotation">Annotation</a>&gt;<br/>A</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../javax/lang/model/AnnotatedConstruct.html#getAnnotation-java.lang.Class-">getAnnotation</a></span>(<a href="../../../java/lang/Class.html" title="class in java.lang"></a>&lt;A&gt; annotationType)</code>
<div class="block">
返回指定类型的这种构造的注解,如果这样的注释
<em>存在</em> ,否则
<code>null</code>
</div> </td>
</tr>
<tr class="rowColor" id="i1">
<td class="colFirst"><code><a href="../../../java/util/List.html" title="interface in java.util">List</a>&lt;? extends <a href="../../../javax/lang/model/element/AnnotationMirror.html" title="interface in javax.lang.model.element">AnnotationMirror</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../javax/lang/model/AnnotatedConstruct.html#getAnnotationMirrors--">getAnnotationMirrors</a></span>()</code>
<div class="block">
返回
<em>直接存在</em>于此构造上的注释。
</div> </td>
</tr>
<tr class="altColor" id="i2">
<td class="colFirst"><code>&lt;A extends <a href="../../../java/lang/annotation/Annotation.html" title="interface in java.lang.annotation">Annotation</a>&gt;<br/>A[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../javax/lang/model/AnnotatedConstruct.html#getAnnotationsByType-java.lang.Class-">getAnnotationsByType</a></span>(<a href="../../../java/lang/Class.html" title="class in java.lang"></a>&lt;A&gt; annotationType)</code>
<div class="block">
返回与此
<em>相关的</em>结构注解。
</div> </td>
</tr>
</tbody>
</table> </li>
</ul> </li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- --> </a> <h3>方法详细信息</h3> <a name="getAnnotationMirrors--">
<!-- --> </a>
<ul class="blockList">
<li class="blockList"> <h4>getAnnotationMirrors</h4> <pre><a href="../../../java/util/List.html" title="interface in java.util">List</a>&lt;? extends <a href="../../../javax/lang/model/element/AnnotationMirror.html" title="interface in javax.lang.model.element">AnnotationMirror</a>&gt; getAnnotationMirrors()</pre>
<div class="block">
返回
<em>直接存在</em>于此构造上的注释。
</div>
<dl>
<dt>
<span class="returnLabel">结果</span>
</dt>
<dd>
<span>该结构上<em>直接出现</em>的注释;</span>
<span>一个空列表,如果没有</span>
</dd>
</dl> </li>
</ul> <a name="getAnnotation-java.lang.Class-">
<!-- --> </a>
<ul class="blockList">
<li class="blockList"> <h4>getAnnotation</h4> <pre>&lt;A extends <a href="../../../java/lang/annotation/Annotation.html" title="interface in java.lang.annotation">Annotation</a>&gt; A getAnnotation(<a href="../../../java/lang/Class.html" title="class in java.lang"></a>&lt;A&gt; annotationType)</pre>
<div class="block">
<span>返回指定类型的这种构造的注解,如果这样的注释<em>存在</em> ,否则<code>null</code></span>
<p> <span>此方法返回的注释可能包含一个值为<code></code></span> <span>此值无法直接返回:查找和加载类(例如要使用的类加载器)所需的信息不可用,并且该类可能无法加载。</span> <span>试图读取一<code></code>通过调用返回的注释相关的方法将导致对象<a href="../../../javax/lang/model/type/MirroredTypeException.html" title="javax.lang.model.type中的类"><code>MirroredTypeException</code></a> ,从该对应的<a href="../../../javax/lang/model/type/TypeMirror.html" title="javax.lang.model.type中的接口"><code>TypeMirror</code></a>可以被提取。</span> <span>类似地,尝试读取一个<code>Class[]</code>元素将导致一个<a href="../../../javax/lang/model/type/MirroredTypesException.html" title="javax.lang.model.type中的类"><code>MirroredTypesException</code></a></span> </p>
<blockquote>
<span><i>Note:</i> This method is unlike others in this and related interfaces. It operates on runtime reflective information — representations of annotation types currently loaded into the VM — rather than on the representations defined by and used throughout these interfaces. Consequently, calling methods on the returned annotation object can throw many of the exceptions that can be thrown when calling methods on an annotation object returned by core reflection. This method is intended for callers that are written to operate on a known, fixed set of annotation types.</span>
</blockquote>
</div>
<dl>
<dt>
<span class="paramLabel">参数类型</span>
</dt>
<dd>
<code>A</code> - 注释类型
</dd>
<dt>
<span class="paramLabel">参数</span>
</dt>
<dd>
<code>annotationType</code> - 对应于注释类型的
<code></code>对象
</dd>
<dt>
<span class="returnLabel">结果</span>
</dt>
<dd>
此构造的注释指定的注释类型(如果存在),否则为
<code>null</code>
</dd>
<dt>
<span class="seeLabel">另请参见:</span>
</dt>
<dd>
<span><a href="../../../javax/lang/model/AnnotatedConstruct.html#getAnnotationMirrors--"><code>getAnnotationMirrors()</code></a> <a href="../../../java/lang/reflect/AnnotatedElement.html#getAnnotation-java.lang.Class-"><code>AnnotatedElement.getAnnotation(java.lang.Class&lt;T&gt;)</code></a> <a href="../../../java/lang/EnumConstantNotPresentException.html" title="java.lang中的类"><code>EnumConstantNotPresentException</code></a> <a href="../../../java/lang/annotation/AnnotationTypeMismatchException.html" title="java.lang.annotation中的类"><code>AnnotationTypeMismatchException</code></a> <a href="../../../java/lang/annotation/IncompleteAnnotationException.html" title="java.lang.annotation中的类"><code>IncompleteAnnotationException</code></a> <a href="../../../javax/lang/model/type/MirroredTypeException.html" title="javax.lang.model.type中的类"><code>MirroredTypeException</code></a> <a href="../../../javax/lang/model/type/MirroredTypesException.html" title="javax.lang.model.type中的类"><code>MirroredTypesException</code></a></span>
</dd>
<dt>
<span class="simpleTagLabel">See <cite> The Java™ Language Specification</cite>:</span>
</dt>
<dd>
9.6.1注释类型元素
</dd>
</dl> </li>
</ul> <a name="getAnnotationsByType-java.lang.Class-">
<!-- --> </a>
<ul class="blockListLast">
<li class="blockList"> <h4>getAnnotationsByType</h4> <pre>&lt;A extends <a href="../../../java/lang/annotation/Annotation.html" title="interface in java.lang.annotation">Annotation</a>&gt; A[] getAnnotationsByType(<a href="../../../java/lang/Class.html" title="class in java.lang"></a>&lt;A&gt; annotationType)</pre>
<div class="block">
<span>返回与此<em>相关的</em>结构注解。</span>
<span>如果没有用该构建体相关联的注释返回值是长度为0注解它们可直接或间接地存在于构建体<i>C</i>被计算为,如果第<i>C</i>间接本注释直接存在第<i>C</i>代替的顺序的阵列的容器注释的顺序,它们在容器注释的值元素中显示的顺序。</span>
<span>该方法与<code>getAnnotation(Class)</code>之间的<a href="../../../javax/lang/model/AnnotatedConstruct.html#getAnnotation-java.lang.Class-">区别</a>在于,该方法检测其参数是否是可<em>重复的注释类型</em> ,如果是,则尝试通过“查看”容器注释来查找该类型的一个或多个注释。</span>
<p> <span>此方法返回的注释可能包含一个值为<code></code></span> <span>此值无法直接返回:查找和加载类(例如要使用的类加载器)所需的信息不可用,并且该类可能无法加载。</span> <span>试图读取一<code></code>通过调用返回的注释相关的方法将导致对象<a href="../../../javax/lang/model/type/MirroredTypeException.html" title="javax.lang.model.type中的类"><code>MirroredTypeException</code></a> ,从该对应的<a href="../../../javax/lang/model/type/TypeMirror.html" title="javax.lang.model.type中的接口"><code>TypeMirror</code></a>可以被提取。</span> <span>类似地,尝试读取一个<code>Class[]</code>值将导致一个<a href="../../../javax/lang/model/type/MirroredTypesException.html" title="javax.lang.model.type中的类"><code>MirroredTypesException</code></a></span> </p>
<blockquote>
<span><i>Note:</i> This method is unlike others in this and related interfaces. It operates on runtime reflective information — representations of annotation types currently loaded into the VM — rather than on the representations defined by and used throughout these interfaces. Consequently, calling methods on the returned annotation object can throw many of the exceptions that can be thrown when calling methods on an annotation object returned by core reflection. This method is intended for callers that are written to operate on a known, fixed set of annotation types.</span>
</blockquote>
</div>
<dl>
<dt>
<span class="paramLabel">参数类型</span>
</dt>
<dd>
<code>A</code> - 注释类型
</dd>
<dt>
<span class="paramLabel">参数</span>
</dt>
<dd>
<code>annotationType</code> - 对应于注释类型的
<code></code>对象
</dd>
<dt>
<span class="returnLabel">结果</span>
</dt>
<dd>
这个构造体对于指定的注释类型的注释,如果存在于此构造上,否则为空数组
</dd>
<dt>
<span class="seeLabel">另请参见:</span>
</dt>
<dd>
<span><a href="../../../javax/lang/model/AnnotatedConstruct.html#getAnnotationMirrors--"><code>getAnnotationMirrors()</code></a> <a href="../../../javax/lang/model/AnnotatedConstruct.html#getAnnotation-java.lang.Class-"><code>getAnnotation(Class)</code></a> <a href="../../../java/lang/reflect/AnnotatedElement.html#getAnnotationsByType-java.lang.Class-"><code>AnnotatedElement.getAnnotationsByType(Class)</code></a> <a href="../../../java/lang/EnumConstantNotPresentException.html" title="java.lang中的类"><code>EnumConstantNotPresentException</code></a> <a href="../../../java/lang/annotation/AnnotationTypeMismatchException.html" title="java.lang.annotation中的类"><code>AnnotationTypeMismatchException</code></a> <a href="../../../java/lang/annotation/IncompleteAnnotationException.html" title="java.lang.annotation中的类"><code>IncompleteAnnotationException</code></a> <a href="../../../javax/lang/model/type/MirroredTypeException.html" title="javax.lang.model.type中的类"><code>MirroredTypeException</code></a> <a href="../../../javax/lang/model/type/MirroredTypesException.html" title="javax.lang.model.type中的类"><code>MirroredTypesException</code></a></span>
</dd>
<dt>
<span class="simpleTagLabel">See <cite> The Java™ Language Specification</cite>:</span>
</dt>
<dd>
9.6注释类型9.6.1注释类型元素
</dd>
</dl> </li>
</ul> </li>
</ul> </li>
</ul>
</div>
</div>