polyglot.types
Interface Type

All Superinterfaces:
java.lang.Cloneable, Copy, Qualifier, java.io.Serializable, TypeObject
All Known Subinterfaces:
ArrayType, ClassType, CofferClassType, CofferParsedClassType, CofferSubstType, InstType, NullType, ParsedClassType, PrimitiveType, ReferenceType, SubstType, UnknownType
All Known Implementing Classes:
ArrayType_c, ClassType_c, CofferParsedClassType_c, CofferSubstClassType_c, NullType_c, PaoParsedClassType_c, PaoPrimitiveType_c, ParsedClassType_c, PrimitiveType_c, ReferenceType_c, SubstClassType_c, Type_c, UnknownType_c

public interface Type
extends Qualifier

A Type is the base type of all classes which represent types.


Method Summary
 ArrayType arrayOf()
          Return an array of this type.
 ArrayType arrayOf(int dims)
          Return a dims-array of this type.
 boolean descendsFrom(Type ancestor)
          Return true if this type descends from ancestor.
 boolean descendsFromImpl(Type t)
          Return true if this type descends from ancestor.
 boolean isArray()
          Return true if an array type.
 boolean isBoolean()
          Return true if boolean.
 boolean isByte()
          Return true if byte.
 boolean isCastValid(Type toType)
          Return true if this type can be cast to toType.
 boolean isCastValidImpl(Type t)
          Return true if this type can be cast to toType.
 boolean isChar()
          Return true if char.
 boolean isClass()
          Return true if a class type.
 boolean isComparable(Type t)
          Return true if the types can be compared; that is, if they have the same type system.
 boolean isDouble()
          Return true if double.
 boolean isFloat()
          Return true if float.
 boolean isImplicitCastValid(Type toType)
          Return true if a value of this type can be assigned to a variable of type toType.
 boolean isImplicitCastValidImpl(Type t)
          Return true if a value of this type can be assigned to a variable of type toType.
 boolean isInt()
          Return true if int.
 boolean isIntOrLess()
          Return true if int, short, byte, or char.
 boolean isLong()
          Return true if long.
 boolean isLongOrLess()
          Return true if long, int, short, byte, or char.
 boolean isNull()
          Return true if a null type.
 boolean isNumeric()
          Return true if double, float, long, int, short, byte, or char.
 boolean isPrimitive()
          Return true if a primitive type.
 boolean isReference()
          Return true if a reference type.
 boolean isShort()
          Return true if short.
 boolean isSubtype(Type ancestor)
          Return true if this type is a subtype of ancestor.
 boolean isSubtypeImpl(Type t)
          Return true if this type is a subtype of ancestor.
 boolean isThrowable()
          Return true if a subclass of Throwable.
 boolean isUncheckedException()
          Return true if an unchecked exception.
 boolean isVoid()
          Return true if void.
 boolean numericConversionValid(long value)
          Return true a literal value can be converted to this type.
 boolean numericConversionValid(java.lang.Object value)
          Return true a literal value can be converted to this type.
 boolean numericConversionValidImpl(long value)
          Return true a literal value can be converted to this type.
 boolean numericConversionValidImpl(java.lang.Object value)
          Return true a literal value can be converted to this type.
 ArrayType toArray()
          Cast the type to an array type, or null.
 ClassType toClass()
          Cast the type to a class type, or null.
 NullType toNull()
          Cast the type to a null type, or null.
 PrimitiveType toPrimitive()
          Cast the type to a primitive type, or null.
 ReferenceType toReference()
          Cast the type to a reference type, or null.
 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 interface polyglot.types.Qualifier
isPackage, isType, toPackage, toType
 
Methods inherited from interface polyglot.types.TypeObject
equalsImpl, isCanonical, position, typeSystem
 
Methods inherited from interface polyglot.util.Copy
copy
 

Method Detail

translate

java.lang.String translate(Resolver c)
Return a string into which to translate the type.

Parameters:
c - A resolver in which to lookup this type to determine if the type is unique in the given resolver.

arrayOf

ArrayType arrayOf()
Return an array of this type.


arrayOf

ArrayType arrayOf(int dims)
Return a dims-array of this type.


toClass

ClassType toClass()
Cast the type to a class type, or null.


toNull

NullType toNull()
Cast the type to a null type, or null.


toReference

ReferenceType toReference()
Cast the type to a reference type, or null.


toPrimitive

PrimitiveType toPrimitive()
Cast the type to a primitive type, or null.


toArray

ArrayType toArray()
Cast the type to an array type, or null.


isSubtype

boolean isSubtype(Type ancestor)
Return true if this type is a subtype of ancestor.


descendsFrom

boolean descendsFrom(Type ancestor)
Return true if this type descends from ancestor.


isCastValid

boolean isCastValid(Type toType)
Return true if this type can be cast to toType.


isImplicitCastValid

boolean isImplicitCastValid(Type toType)
Return true if a value of this type can be assigned to a variable of type toType.


numericConversionValid

boolean numericConversionValid(java.lang.Object value)
Return true a literal value can be converted to this type.


numericConversionValid

boolean numericConversionValid(long value)
Return true a literal value can be converted to this type.


isSubtypeImpl

boolean isSubtypeImpl(Type t)
Return true if this type is a subtype of ancestor.


descendsFromImpl

boolean descendsFromImpl(Type t)
Return true if this type descends from ancestor.


isCastValidImpl

boolean isCastValidImpl(Type t)
Return true if this type can be cast to toType.


isImplicitCastValidImpl

boolean isImplicitCastValidImpl(Type t)
Return true if a value of this type can be assigned to a variable of type toType.


numericConversionValidImpl

boolean numericConversionValidImpl(java.lang.Object value)
Return true a literal value can be converted to this type.


numericConversionValidImpl

boolean numericConversionValidImpl(long value)
Return true a literal value can be converted to this type. This method should be removed. It is kept for backward compatibility.


isPrimitive

boolean isPrimitive()
Return true if a primitive type.


isVoid

boolean isVoid()
Return true if void.


isBoolean

boolean isBoolean()
Return true if boolean.


isChar

boolean isChar()
Return true if char.


isByte

boolean isByte()
Return true if byte.


isShort

boolean isShort()
Return true if short.


isInt

boolean isInt()
Return true if int.


isLong

boolean isLong()
Return true if long.


isFloat

boolean isFloat()
Return true if float.


isDouble

boolean isDouble()
Return true if double.


isIntOrLess

boolean isIntOrLess()
Return true if int, short, byte, or char.


isLongOrLess

boolean isLongOrLess()
Return true if long, int, short, byte, or char.


isNumeric

boolean isNumeric()
Return true if double, float, long, int, short, byte, or char.


isReference

boolean isReference()
Return true if a reference type.


isNull

boolean isNull()
Return true if a null type.


isArray

boolean isArray()
Return true if an array type.


isClass

boolean isClass()
Return true if a class type.


isThrowable

boolean isThrowable()
Return true if a subclass of Throwable.


isUncheckedException

boolean isUncheckedException()
Return true if an unchecked exception.


isComparable

boolean isComparable(Type t)
Return true if the types can be compared; that is, if they have the same type system.


toString

java.lang.String toString()
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.

Overrides:
toString in class java.lang.Object