polyglot.types
Interface ClassType

All Superinterfaces:
java.lang.Cloneable, Copy, Importable, MemberInstance, Named, Qualifier, ReferenceType, java.io.Serializable, Type, TypeObject
All Known Subinterfaces:
CofferClassType, CofferParsedClassType, CofferSubstType, ParsedClassType
All Known Implementing Classes:
ClassType_c, CofferParsedClassType_c, CofferSubstClassType_c, ParsedClassType_c

public interface ClassType
extends Importable, ReferenceType, MemberInstance

A ClassType represents a class, either loaded from a classpath, parsed from a source file, or obtained from other source. A ClassType is not necessarily named.


Nested Class Summary
static class ClassType.Kind
           
 
Field Summary
static ClassType.Kind ANONYMOUS
           
static ClassType.Kind LOCAL
           
static ClassType.Kind MEMBER
           
static ClassType.Kind TOP_LEVEL
           
 
Method Summary
 java.util.List constructors()
          The class's constructors.
 FieldInstance fieldNamed(java.lang.String name)
          Get a field by name, or null.
 boolean hasEnclosingInstance(ClassType encl)
          Return true if an object of the class has an enclosing instance of encl.
 boolean hasEnclosingInstanceImpl(ClassType encl)
          Implementation of hasEnclosingInstance.
 boolean inStaticContext()
          Return true if the class declaration occurs in a static context.
 boolean isAnonymous()
          Return true if the class is an anonymous class.
 boolean isEnclosed(ClassType outer)
          Return true if the class is strictly contained in outer.
 boolean isEnclosedImpl(ClassType outer)
          Implementation of isEnclosed.
 boolean isInner()
          Deprecated. Was incorrectly defined. Use isNested for nested classes, and isInnerClass for inner classes.
 boolean isInnerClass()
          Return true if the class is an inner class, that is, it is a nested class that is not explicitly or implicitly declared static; an interface is never an inner class.
 boolean isLocal()
          Return true if the class is a local class.
 boolean isMember()
          Return true if the class is a member class.
 boolean isNested()
          Return true if the class is a nested.
 boolean isTopLevel()
          Return true if the class is top-level (i.e., not inner).
 ClassType.Kind kind()
          Get the class's kind.
 java.util.List memberClasses()
          The class's member classes.
 ClassType memberClassNamed(java.lang.String name)
          Returns the member class with the given name, or null.
 ClassType outer()
          The class's outer class if this is a nested class, or null.
 
Methods inherited from interface polyglot.types.Importable
package_
 
Methods inherited from interface polyglot.types.Named
fullName, name
 
Methods inherited from interface polyglot.types.TypeObject
equalsImpl, isCanonical, position, typeSystem
 
Methods inherited from interface polyglot.util.Copy
copy
 
Methods inherited from interface polyglot.types.ReferenceType
fields, hasMethod, hasMethodImpl, interfaces, methods, methods, methodsNamed, superType
 
Methods inherited from interface polyglot.types.Type
arrayOf, arrayOf, descendsFrom, descendsFromImpl, isArray, isBoolean, isByte, isCastValid, isCastValidImpl, isChar, isClass, isComparable, isDouble, isFloat, isImplicitCastValid, isImplicitCastValidImpl, isInt, isIntOrLess, isLong, isLongOrLess, isNull, isNumeric, isPrimitive, isReference, isShort, isSubtype, isSubtypeImpl, isThrowable, isUncheckedException, isVoid, numericConversionValid, numericConversionValid, numericConversionValidImpl, numericConversionValidImpl, toArray, toClass, toNull, toPrimitive, toReference, toString, translate
 
Methods inherited from interface polyglot.types.Qualifier
isPackage, isType, toPackage, toType
 
Methods inherited from interface polyglot.types.MemberInstance
container, flags
 

Field Detail

TOP_LEVEL

public static final ClassType.Kind TOP_LEVEL

MEMBER

public static final ClassType.Kind MEMBER

LOCAL

public static final ClassType.Kind LOCAL

ANONYMOUS

public static final ClassType.Kind ANONYMOUS
Method Detail

kind

public ClassType.Kind kind()
Get the class's kind.


isTopLevel

public boolean isTopLevel()
Return true if the class is top-level (i.e., not inner). Equivalent to kind() == TOP_LEVEL.


isInner

public boolean isInner()
Deprecated. Was incorrectly defined. Use isNested for nested classes, and isInnerClass for inner classes.

Return true if the class is an inner class. Equivalent to kind() == MEMBER || kind() == LOCAL || kind() == ANONYMOUS.


isNested

public boolean isNested()
Return true if the class is a nested. Equivalent to kind() == MEMBER || kind() == LOCAL || kind() == ANONYMOUS.


isInnerClass

public boolean isInnerClass()
Return true if the class is an inner class, that is, it is a nested class that is not explicitly or implicitly declared static; an interface is never an inner class.


isMember

public boolean isMember()
Return true if the class is a member class. Equivalent to kind() == MEMBER.


isLocal

public boolean isLocal()
Return true if the class is a local class. Equivalent to kind() == LOCAL.


isAnonymous

public boolean isAnonymous()
Return true if the class is an anonymous class. Equivalent to kind() == ANONYMOUS.


inStaticContext

public boolean inStaticContext()
Return true if the class declaration occurs in a static context. Is used to determine if a nested class is implicitly static.


constructors

public java.util.List constructors()
The class's constructors. A list of ConstructorInstance.

See Also:
ConstructorInstance

memberClasses

public java.util.List memberClasses()
The class's member classes. A list of ClassType.

See Also:
ClassType

memberClassNamed

public ClassType memberClassNamed(java.lang.String name)
Returns the member class with the given name, or null.


fieldNamed

public FieldInstance fieldNamed(java.lang.String name)
Get a field by name, or null.

Specified by:
fieldNamed in interface ReferenceType

isEnclosed

public boolean isEnclosed(ClassType outer)
Return true if the class is strictly contained in outer.


isEnclosedImpl

public boolean isEnclosedImpl(ClassType outer)
Implementation of isEnclosed. This method should only be called by the TypeSystem or by a subclass.


hasEnclosingInstance

public boolean hasEnclosingInstance(ClassType encl)
Return true if an object of the class has an enclosing instance of encl.


hasEnclosingInstanceImpl

public boolean hasEnclosingInstanceImpl(ClassType encl)
Implementation of hasEnclosingInstance. This method should only be called by the TypeSystem or by a subclass.


outer

public ClassType outer()
The class's outer class if this is a nested class, or null.