com.togethersoft.sca.ast
Interface AstType

All Superinterfaces:
AstDbcProvider, AstDeclaration, AstElement, AstMember, AstObject, AstTypeReference

public interface AstType
extends AstMember, AstTypeReference, AstDbcProvider

Represents a type (a class or interface) defined either in a source file or in a binary class file.


Fields inherited from interface com.togethersoft.sca.ast.AstObject
ARRAY_CREATION, ARRAY_INITIALIZER, ARRAY_REFERENCE, ASSERT_STATEMENT, ASSIGNMENT_EXPRESSION, BINARY_EXPRESSION, BREAK_STATEMENT, CASE_LABEL, CAST_EXPRESSION, CATCH_CLAUSE, CLASS_FILE, COMMENT, COMPILATION_UNIT, COMPOUND_STATEMENT, CONDITIONAL_EXPRESSION, CONSTRUCTOR_INVOCATION, CONTINUE_STATEMENT, DBC_RESULT, DECLARATION_STATEMENT, DO_STATEMENT, EMPTY_STATEMENT, EXPRESSION_STATEMENT, FIELD_REFERENCE, FINALLY_CLAUSE, FOR_STATEMENT, IF_STATEMENT, IMPORT, INITIALIZER, JAVADOC_TAG, LITERAL, METHOD, METHOD_CALL_EXPRESSION, N_A, OBJECT_CREATION_EXPRESSION, PACKAGE, PARENTHESIZED_EXPRESSION, RETURN_STATEMENT, SIMPLE_REFERENCE, SUPER_EXPRESSION, SWITCH_GROUP, SWITCH_STATEMENT, SYNCHRONIZED_STATEMENT, THIS_EXPRESSION, THROW_SPECIFIER, THROW_STATEMENT, TRY_STATEMENT, TYPE, TYPE_EXPRESSION, UNARY_EXPRESSION, VARIABLE, VARIABLE_DECLARATION, WHILE_STATEMENT
 
Fields inherited from interface com.togethersoft.sca.ast.AstTypeReference
TID_BAD, TID_BOOLEAN, TID_BYTE, TID_CHAR, TID_CLASS, TID_DOUBLE, TID_FLOAT, TID_INT, TID_INTERFACE, TID_LONG, TID_NULL, TID_SHORT, TID_VOID
 
Method Summary
 AstField findField(java.lang.String name, boolean searchInherited)
          Returns the field with the specified name.
 AstMethod findMethod(java.lang.String name, java.lang.String signature, boolean searchInherited)
          Returns the method with the specified name and signature.
 AstType findType(java.lang.String name, boolean searchInherited)
          Returns the nested type with the specified name declared by this type.
 AstField[] getAllFields()
          Returns all the fields of this type.
 AstMethod[] getAllMethods()
          Returns all the methods of this type.
 AstClassFile getClassFile()
          Returns the binary file in which this type is declared, or null if this type is not declared in a binary type (a source type).
 AstMethod[] getConstructors()
          Returns the constructors declared by this type.
 java.lang.String getElementName()
          Returns the simple name of this type, unqualified by package or enclosing type.
 AstMethod[] getExecutableFragments()
          Returns the methods, constructors, and initializers declared by this type.
 AstType[] getExportCouplings()
          Returns the types that directly depends on this type.
 AstField[] getFields()
          Returns the fields declared by this type.
 AstType[] getImportCouplings()
          Returns the types on which this type directly depends.
 AstInitializer[] getInitializers()
          Returns the initializers declared by this type.
 AstDeclaration[] getMembers()
          Return array of all declarations in the class
 AstMethod[] getMethods()
          Returns the methods declared by this type.
 java.lang.String getQualifiedName()
          Returns the fully qualified name of this type, including qualification for any containing types and packages.
 AstType[] getSubtypes()
          Returns the types that are directly derived from this type.
 AstType getSuperClass()
          Returns this type's superclass, or null for the "java/lang/Object" type.
 AstType[] getSuperInterfaces()
          Returns the interfaces that this type implements or extends, in the order in which they are listed in the source.
 java.lang.String getTypeQualifiedName()
          Returns the type-qualified name of this type, including qualification for any enclosing types, but not including package qualification.
 AstType[] getTypes()
          Returns the immediate member types declared by this type.
 AstVarDeclaration[] getVarDeclarations()
          Return array of class variables declaraions (for declaration "int x,y,z;" this method will return the single declaration)
 boolean isBinary()
          Returns true if this type was loaded from a class file, otherwise false.
 boolean isClass()
          Returns true if this type represents a class, otherwise false.
 boolean isDerivedFrom(AstType type)
          Determines if the class or interface represented by this AstType object is derived from the class or interface represented by the specified AstType parameter.
 boolean isDerivedFrom(java.lang.String typeName)
          Determines if the class or interface represented by this AstType object is derived from the class or interface represented by the specified String parameter.
 boolean isInterface()
          Returns true if this type represents an interface, otherwise false.
 boolean isSource()
          Returns true if this type was loaded from a Java source, otherwise false.
 
Methods inherited from interface com.togethersoft.sca.ast.AstDeclaration
getDeclaredModifiers, getModifiers, getModifiersList, getReferences, isAbstract, isFinal, isNative, isPackage, isPrivate, isProtected, isPublic, isStatic, isStrictfp, isSynchronized, isTransient, isVolatile, setDeclaredModifiers, swapWith
 
Methods inherited from interface com.togethersoft.sca.ast.AstObject
addComment, getChildren, getComments, getCompilationUnit, getDeclaringMethod, getDeclaringType, getObjectKind, getPackage, getParent, getPosition, isDeleted, remove, replaceWith, replaceWith, setPosition, setPositionAfter, visitExpressions, visitStatements
 
Methods inherited from interface com.togethersoft.sca.ast.AstTypeReference
getBaseType, getKind, getSignature, getTypeName, isAssignableTo, isDerivedFrom, numDimensions
 
Methods inherited from interface com.togethersoft.sca.ast.AstDbcProvider
getInvariants, getPostconditions, getPreconditions
 

Method Detail

findField

public AstField findField(java.lang.String name,
                          boolean searchInherited)
Returns the field with the specified name. Returns null, if the field with the specified name does not exist.
Parameters:
name - specifies name of the field, for example "table".
searchInherited - specifies whether inherited fields will be included in search.
Returns:
a field that is a member of this type

findMethod

public AstMethod findMethod(java.lang.String name,
                            java.lang.String signature,
                            boolean searchInherited)
Returns the method with the specified name and signature. Returns null, if the method with the specified name and signature does not exist. The signature format is the same as specified for AstMethod.getSignature().
Parameters:
name - specifies name of the method, for example "compareTo".
signature - specifies signature of the method, for example "(Ljava/lang/String)I".
searchInherited - specifies whether inherited methods will be included in search.
See Also:
AstMethod.getSignature()

findType

public AstType findType(java.lang.String name,
                        boolean searchInherited)
Returns the nested type with the specified name declared by this type. Returns null, if the type with the specified name does not exist.
Parameters:
name - specifies simple name of the type, for example "Entry".
searchInherited - specifies whether inherited members will be included in search.

getAllFields

public AstField[] getAllFields()
Returns all the fields of this type. This includes both declared and inherited fields.

getAllMethods

public AstMethod[] getAllMethods()
Returns all the methods of this type. This includes both declared and inherited methods.

getClassFile

public AstClassFile getClassFile()
Returns the binary file in which this type is declared, or null if this type is not declared in a binary type (a source type).

getConstructors

public AstMethod[] getConstructors()
Returns the constructors declared by this type. If this is a source type, the results are listed in the order in which they appear in the source, otherwise, the results are in no particular order.

getElementName

public java.lang.String getElementName()
Returns the simple name of this type, unqualified by package or enclosing type.
Specified by:
getElementName in interface AstElement
Following copied from interface: com.togethersoft.sca.ast.AstElement
Returns:
the name of this element.

getExecutableFragments

public AstMethod[] getExecutableFragments()
Returns the methods, constructors, and initializers declared by this type.

getExportCouplings

public AstType[] getExportCouplings()
Returns the types that directly depends on this type. A type depends on another type if it calls methods, accesses attributes, or extends that type. The types are returned in no particular order.

getFields

public AstField[] getFields()
Returns the fields declared by this type. If this is a source type, the results are listed in the order in which they appear in the source, otherwise, the results are in no particular order. For binary types, this includes synthetic fields.

getImportCouplings

public AstType[] getImportCouplings()
Returns the types on which this type directly depends. A type depends on another type if it calls methods, accesses attributes, or extends that type. The types are returned in no particular order.

getInitializers

public AstInitializer[] getInitializers()
Returns the initializers declared by this type. For binary types this is an empty collection. If this is a source type, the results are listed in the order in which they appear in the source.

getMembers

public AstDeclaration[] getMembers()
Return array of all declarations in the class
Returns:
AstType

getMethods

public AstMethod[] getMethods()
Returns the methods declared by this type. For binary types, this may include the special <clinit>; method and synthetic methods. If this is a source type, the results are listed in the order in which they appear in the source, otherwise, the results are in no particular order.

getQualifiedName

public java.lang.String getQualifiedName()
Returns the fully qualified name of this type, including qualification for any containing types and packages. This is the name of the package, followed by '/', followed by the type-qualified name.
Specified by:
getQualifiedName in interface AstMember
Following copied from interface: com.togethersoft.sca.ast.AstMember
Returns:
the qualified name of this member.

getSubtypes

public AstType[] getSubtypes()
Returns the types that are directly derived from this type. For classes, this gives the classes that extends this class. For interfaces, this gives the interfaces that extend this interface, and classes that implement it.

An empty array is returned if no type is derived from this type.


getSuperClass

public AstType getSuperClass()
Returns this type's superclass, or null for the "java/lang/Object" type. For interfaces, the superclass is always "java/lang/Object".

getSuperInterfaces

public AstType[] getSuperInterfaces()
Returns the interfaces that this type implements or extends, in the order in which they are listed in the source. For classes, this gives the interfaces that this class implements. For interfaces, this gives the interfaces that this interface extends. An empty collection is returned if this type does not implement or extend any interfaces.

getTypeQualifiedName

public java.lang.String getTypeQualifiedName()
Returns the type-qualified name of this type, including qualification for any enclosing types, but not including package qualification. For source types, this consists of the simple names of any enclosing types, separated by "$", followed by the simple name of this type. For binary types, this is the name of the class file without the ".class" suffix.

getTypes

public AstType[] getTypes()
Returns the immediate member types declared by this type. The results are listed in the order in which they appear in the source or class file.

getVarDeclarations

public AstVarDeclaration[] getVarDeclarations()
Return array of class variables declaraions (for declaration "int x,y,z;" this method will return the single declaration)
Returns:
AstVarDeclaration[]

isBinary

public boolean isBinary()
Returns true if this type was loaded from a class file, otherwise false.

isClass

public boolean isClass()
Returns true if this type represents a class, otherwise false.

isDerivedFrom

public boolean isDerivedFrom(AstType type)
Determines if the class or interface represented by this AstType object is derived from the class or interface represented by the specified AstType parameter. For classes, isDerivedFrom returns true if this class extends the specified class, or implements the specified interface. For interface, isDerivedFrom returns true if this interface extends the specified interface.
Parameters:
type - the AstType object to be checked.
Returns:
true if this type is derived from type.

isDerivedFrom

public boolean isDerivedFrom(java.lang.String typeName)
Determines if the class or interface represented by this AstType object is derived from the class or interface represented by the specified String parameter. For classes, isDerivedFrom returns true if this class extends the specified class, or implements the specified interface. For interface, isDerivedFrom returns true if this interface extends the specified interface.
Parameters:
type - the name of the type to be checked, for example java/lang/Runnable.
Returns:
true if this type is derived from type.

isInterface

public boolean isInterface()
Returns true if this type represents an interface, otherwise false.

isSource

public boolean isSource()
Returns true if this type was loaded from a Java source, otherwise false.