polyglot.ext.jl.types
Class ClassType_c

java.lang.Object
  extended by polyglot.ext.jl.types.TypeObject_c
      extended by polyglot.ext.jl.types.Type_c
          extended by polyglot.ext.jl.types.ReferenceType_c
              extended by polyglot.ext.jl.types.ClassType_c
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, ClassType, Importable, MemberInstance, Named, Qualifier, ReferenceType, Type, TypeObject, Copy
Direct Known Subclasses:
ParsedClassType_c, SubstClassType_c

public abstract class ClassType_c
extends ReferenceType_c
implements ClassType

A ClassType represents a class -- either loaded from a classpath, parsed from a source file, or obtained from other source.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface polyglot.types.ClassType
ClassType.Kind
 
Field Summary
 
Fields inherited from class polyglot.ext.jl.types.TypeObject_c
position, ts
 
Fields inherited from interface polyglot.types.ClassType
ANONYMOUS, LOCAL, MEMBER, TOP_LEVEL
 
Constructor Summary
protected ClassType_c()
          Used for deserializing types.
  ClassType_c(TypeSystem ts)
           
  ClassType_c(TypeSystem ts, Position pos)
           
 
Method Summary
abstract  java.util.List constructors()
          Get the class's constructors.
 ReferenceType container()
          Get the container class if a member class.
 boolean descendsFromImpl(Type ancestor)
          Return true if this type descends from ancestor.
 FieldInstance fieldNamed(java.lang.String name)
          Get a field of the class by name.
abstract  java.util.List fields()
          Get the class's fields.
abstract  Flags flags()
          Get the class's flags.
 java.lang.String fullName()
          Get the full name of the class, if possible.
 boolean hasEnclosingInstance(ClassType encl)
          Return true if an object of the class has an enclosing instance of encl.
 boolean hasEnclosingInstanceImpl(ClassType encl)
          Return true if an object of the class has an enclosing instance of encl.
abstract  java.util.List interfaces()
          Get the class's interfaces.
 boolean isAnonymous()
          Return true if the class is an anonymous class.
 boolean isCanonical()
          Return true if the type object contains no unknown/ambiguous types.
 boolean isCastValidImpl(Type toType)
          Requires: all type arguments are canonical.
 boolean isClass()
          Return true if a class type.
 boolean isEnclosed(ClassType maybe_outer)
          Return true if the class is strictly contained in outer.
 boolean isEnclosedImpl(ClassType maybe_outer)
          Implementation of isEnclosed.
 boolean isImplicitCastValidImpl(Type toType)
          Return true if a value of this type can be assigned to a variable of type toType.
 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 isThrowable()
          Return true if a subclass of Throwable.
 boolean isTopLevel()
          Return true if the class is top-level (i.e., not inner).
 boolean isUncheckedException()
          Return true if an unchecked exception.
abstract  ClassType.Kind kind()
          Get the class's kind.
abstract  java.util.List memberClasses()
          Get the class's member classes.
 ClassType memberClassNamed(java.lang.String name)
          Get a member class of the class by name.
abstract  java.util.List methods()
          Get the class's methods.
abstract  java.lang.String name()
          Get the short name of the class, if possible.
abstract  ClassType outer()
          Get the class's outer class, or null if a top-level class.
abstract  Package package_()
          Get the class's package.
abstract  Type superType()
          Get the class's super type.
 ClassType toClass()
          Returns a non-null iff isClass() returns true.
 java.lang.String toString()
          Yields a string representing this type.
 java.lang.String translate(Resolver c)
          Return a string into which to translate the type.
 
Methods inherited from class polyglot.ext.jl.types.ReferenceType_c
hasMethod, hasMethodImpl, isReference, methods, methodsNamed, toReference
 
Methods inherited from class polyglot.ext.jl.types.Type_c
arrayOf, arrayOf, descendsFrom, isArray, isBoolean, isByte, isCastValid, isChar, isComparable, isDouble, isFloat, isImplicitCastValid, isInt, isIntOrLess, isLong, isLongOrLess, isNull, isNumeric, isPackage, isPrimitive, isShort, isSubtype, isSubtypeImpl, isType, isVoid, numericConversionValid, numericConversionValid, numericConversionValidImpl, numericConversionValidImpl, toArray, toNull, toPackage, toPrimitive, toType
 
Methods inherited from class polyglot.ext.jl.types.TypeObject_c
copy, equals, equalsImpl, hashCode, position, typeSystem
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface polyglot.types.ClassType
inStaticContext
 
Methods inherited from interface polyglot.types.ReferenceType
hasMethod, hasMethodImpl, methods, methodsNamed
 
Methods inherited from interface polyglot.types.Type
arrayOf, arrayOf, descendsFrom, isArray, isBoolean, isByte, isCastValid, isChar, isComparable, isDouble, isFloat, isImplicitCastValid, isInt, isIntOrLess, isLong, isLongOrLess, isNull, isNumeric, isPrimitive, isReference, isShort, isSubtype, isSubtypeImpl, isVoid, numericConversionValid, numericConversionValid, numericConversionValidImpl, numericConversionValidImpl, toArray, toNull, toPrimitive, toReference
 
Methods inherited from interface polyglot.types.Qualifier
isPackage, isType, toPackage, toType
 

Constructor Detail

ClassType_c

protected ClassType_c()
Used for deserializing types.


ClassType_c

public ClassType_c(TypeSystem ts)

ClassType_c

public ClassType_c(TypeSystem ts,
                   Position pos)
Method Detail

kind

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

Specified by:
kind in interface ClassType

outer

public abstract ClassType outer()
Get the class's outer class, or null if a top-level class.

Specified by:
outer in interface ClassType

name

public abstract java.lang.String name()
Get the short name of the class, if possible.

Specified by:
name in interface Named

container

public ReferenceType container()
Get the container class if a member class.

Specified by:
container in interface MemberInstance

fullName

public java.lang.String fullName()
Get the full name of the class, if possible.

Specified by:
fullName in interface Named

isTopLevel

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

Specified by:
isTopLevel in interface ClassType

isMember

public boolean isMember()
Description copied from interface: ClassType
Return true if the class is a member class. Equivalent to kind() == MEMBER.

Specified by:
isMember in interface ClassType

isLocal

public boolean isLocal()
Description copied from interface: ClassType
Return true if the class is a local class. Equivalent to kind() == LOCAL.

Specified by:
isLocal in interface ClassType

isAnonymous

public boolean isAnonymous()
Description copied from interface: ClassType
Return true if the class is an anonymous class. Equivalent to kind() == ANONYMOUS.

Specified by:
isAnonymous in interface ClassType

isInner

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

Description copied from interface: ClassType
Return true if the class is an inner class. Equivalent to kind() == MEMBER || kind() == LOCAL || kind() == ANONYMOUS.

Specified by:
isInner in interface ClassType

isNested

public boolean isNested()
Description copied from interface: ClassType
Return true if the class is a nested. Equivalent to kind() == MEMBER || kind() == LOCAL || kind() == ANONYMOUS.

Specified by:
isNested in interface ClassType

isInnerClass

public boolean isInnerClass()
Description copied from interface: ClassType
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.

Specified by:
isInnerClass in interface ClassType

isCanonical

public boolean isCanonical()
Description copied from interface: TypeObject
Return true if the type object contains no unknown/ambiguous types.

Specified by:
isCanonical in interface TypeObject
Overrides:
isCanonical in class Type_c

isClass

public boolean isClass()
Description copied from interface: Type
Return true if a class type.

Specified by:
isClass in interface Type
Overrides:
isClass in class Type_c

toClass

public ClassType toClass()
Description copied from class: Type_c
Returns a non-null iff isClass() returns true.

Specified by:
toClass in interface Type
Overrides:
toClass in class Type_c

package_

public abstract Package package_()
Get the class's package.

Specified by:
package_ in interface Importable

flags

public abstract Flags flags()
Get the class's flags.

Specified by:
flags in interface MemberInstance

constructors

public abstract java.util.List constructors()
Get the class's constructors.

Specified by:
constructors in interface ClassType
See Also:
ConstructorInstance

memberClasses

public abstract java.util.List memberClasses()
Get the class's member classes.

Specified by:
memberClasses in interface ClassType
See Also:
ClassType

methods

public abstract java.util.List methods()
Get the class's methods.

Specified by:
methods in interface ReferenceType
Specified by:
methods in class ReferenceType_c
Returns:
A list of MethodInstance.
See Also:
MethodInstance

fields

public abstract java.util.List fields()
Get the class's fields.

Specified by:
fields in interface ReferenceType
Specified by:
fields in class ReferenceType_c
Returns:
A list of FieldInstance.
See Also:
FieldInstance

interfaces

public abstract java.util.List interfaces()
Get the class's interfaces.

Specified by:
interfaces in interface ReferenceType
Specified by:
interfaces in class ReferenceType_c
Returns:
A list of Type.
See Also:
Type

superType

public abstract Type superType()
Get the class's super type.

Specified by:
superType in interface ReferenceType
Specified by:
superType in class ReferenceType_c

fieldNamed

public FieldInstance fieldNamed(java.lang.String name)
Get a field of the class by name.

Specified by:
fieldNamed in interface ClassType
Specified by:
fieldNamed in interface ReferenceType

memberClassNamed

public ClassType memberClassNamed(java.lang.String name)
Get a member class of the class by name.

Specified by:
memberClassNamed in interface ClassType

descendsFromImpl

public boolean descendsFromImpl(Type ancestor)
Description copied from class: Type_c
Return true if this type descends from ancestor.

Specified by:
descendsFromImpl in interface Type
Overrides:
descendsFromImpl in class ReferenceType_c

isThrowable

public boolean isThrowable()
Description copied from class: Type_c
Return true if a subclass of Throwable.

Specified by:
isThrowable in interface Type
Overrides:
isThrowable in class Type_c

isUncheckedException

public boolean isUncheckedException()
Description copied from class: Type_c
Return true if an unchecked exception.

Specified by:
isUncheckedException in interface Type
Overrides:
isUncheckedException in class Type_c

isImplicitCastValidImpl

public boolean isImplicitCastValidImpl(Type toType)
Description copied from class: Type_c
Return true if a value of this type can be assigned to a variable of type toType.

Specified by:
isImplicitCastValidImpl in interface Type
Overrides:
isImplicitCastValidImpl in class ReferenceType_c

isCastValidImpl

public boolean isCastValidImpl(Type toType)
Requires: all type arguments are canonical. ToType is not a NullType. Returns true iff a cast from this to toType is valid; in other words, some non-null members of this are also members of toType.

Specified by:
isCastValidImpl in interface Type
Overrides:
isCastValidImpl in class ReferenceType_c

isEnclosed

public final boolean isEnclosed(ClassType maybe_outer)
Description copied from interface: ClassType
Return true if the class is strictly contained in outer.

Specified by:
isEnclosed in interface ClassType

hasEnclosingInstance

public final boolean hasEnclosingInstance(ClassType encl)
Description copied from interface: ClassType
Return true if an object of the class has an enclosing instance of encl.

Specified by:
hasEnclosingInstance in interface ClassType

translate

public java.lang.String translate(Resolver c)
Description copied from class: Type_c
Return a string into which to translate the type.

Specified by:
translate in interface Type
Specified by:
translate in class Type_c
Parameters:
c - A resolver in which to lookup this type to determine if the type is unique in the given resolver.

toString

public java.lang.String toString()
Description copied from class: Type_c
Yields a string representing this type. The string should be consistent with equality. That is, if this.equals(anotherType), then it should be that this.toString().equals(anotherType.toString()). The string does not have to be a legal Java identifier. It is suggested, but not required, that it be an easily human readable representation, and thus useful in error messages and generated output.

Specified by:
toString in interface Type
Specified by:
toString in class Type_c

isEnclosedImpl

public boolean isEnclosedImpl(ClassType maybe_outer)
Description copied from interface: ClassType
Implementation of isEnclosed. This method should only be called by the TypeSystem or by a subclass.

Specified by:
isEnclosedImpl in interface ClassType

hasEnclosingInstanceImpl

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

Specified by:
hasEnclosingInstanceImpl in interface ClassType