001: /*
002: * @(#)TypeDeclaration.java 1.4 04/04/30
003: *
004: * Copyright (c) 2004, Sun Microsystems, Inc.
005: * All rights reserved.
006: *
007: * Redistribution and use in source and binary forms, with or without
008: * modification, are permitted provided that the following conditions are met:
009: *
010: * * Redistributions of source code must retain the above copyright
011: * notice, this list of conditions and the following disclaimer.
012: * * Redistributions in binary form must reproduce the above copyright
013: * notice, this list of conditions and the following disclaimer in the
014: * documentation and/or other materials provided with the distribution.
015: * * Neither the name of the Sun Microsystems, Inc. nor the names of
016: * its contributors may be used to endorse or promote products derived from
017: * this software without specific prior written permission.
018: *
019: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
020: * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
021: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
022: * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
023: * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
024: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
025: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
026: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
027: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
028: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
029: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
030: */
031:
032: package com.sun.mirror.declaration;
033:
034: import java.util.Collection;
035:
036: import com.sun.mirror.type.*;
037:
038: /**
039: * Represents the declaration of a class or interface.
040: * Provides access to information about the type and its members.
041: * Note that an {@linkplain EnumDeclaration enum} is a kind of class,
042: * and an {@linkplain AnnotationTypeDeclaration annotation type} is
043: * a kind of interface.
044: *
045: * <p> <a name="DECL_VS_TYPE"></a>
046: * While a <tt>TypeDeclaration</tt> represents the <i>declaration</i>
047: * of a class or interface, a {@link DeclaredType} represents a class
048: * or interface <i>type</i>, the latter being a use
049: * (or <i>invocation</i>) of the former.
050: * The distinction is most apparent with generic types,
051: * for which a single declaration can define a whole
052: * family of types. For example, the declaration of
053: * {@code java.util.Set} corresponds to the parameterized types
054: * {@code java.util.Set<String>} and {@code java.util.Set<Number>}
055: * (and many others), and to the raw type {@code java.util.Set}.
056: *
057: * <p> {@link com.sun.mirror.util.DeclarationFilter}
058: * provides a simple way to select just the items of interest
059: * when a method returns a collection of declarations.
060: *
061: * @author Joseph D. Darcy
062: * @author Scott Seligman
063: * @version 1.4 04/04/30
064: *
065: * @see DeclaredType
066: * @since 1.5
067: */
068:
069: public interface TypeDeclaration extends MemberDeclaration {
070:
071: /**
072: * Returns the package within which this type is declared.
073: *
074: * @return the package within which this type is declared
075: */
076: PackageDeclaration getPackage();
077:
078: /**
079: * Returns the fully qualified name of this class or interface
080: * declaration. More precisely, it returns the <i>canonical</i>
081: * name.
082: * The name of a generic type does not include any reference
083: * to its formal type parameters.
084: * For example, the the fully qualified name of the interface declaration
085: * {@code java.util.Set<E>} is <tt>"java.util.Set"</tt>.
086: *
087: * @return the fully qualified name of this class or interface declaration
088: */
089: String getQualifiedName();
090:
091: /**
092: * Returns the formal type parameters of this class or interface.
093: *
094: * @return the formal type parameters, or an empty collection
095: * if there are none
096: */
097: Collection<TypeParameterDeclaration> getFormalTypeParameters();
098:
099: /**
100: * Returns the interface types directly implemented by this class
101: * or extended by this interface.
102: *
103: * @return the interface types directly implemented by this class
104: * or extended by this interface, or an empty collection if there are none
105: *
106: * @see com.sun.mirror.util.DeclarationFilter
107: */
108: Collection<InterfaceType> getSuperinterfaces();
109:
110: /**
111: * Returns the fields that are directly declared by this class or
112: * interface. Includes enum constants.
113: *
114: * @return the fields that are directly declared,
115: * or an empty collection if there are none
116: *
117: * @see com.sun.mirror.util.DeclarationFilter
118: */
119: Collection<FieldDeclaration> getFields();
120:
121: /**
122: * Returns the methods that are directly declared by this class or
123: * interface. Includes annotation type elements. Excludes
124: * implicitly declared methods of an interface, such as
125: * <tt>toString</tt>, that correspond to the methods of
126: * <tt>java.lang.Object</tt>.
127: *
128: * @return the methods that are directly declared,
129: * or an empty collection if there are none
130: *
131: * @see com.sun.mirror.util.DeclarationFilter
132: */
133: Collection<? extends MethodDeclaration> getMethods();
134:
135: /**
136: * Returns the declarations of the nested classes and interfaces
137: * that are directly declared by this class or interface.
138: *
139: * @return the declarations of the nested classes and interfaces,
140: * or an empty collection if there are none
141: *
142: * @see com.sun.mirror.util.DeclarationFilter
143: */
144: Collection<TypeDeclaration> getNestedTypes();
145: }
|