ua.gradsoft.javachecker.models
Class JavaClassTypeModel

java.lang.Object
  extended by ua.gradsoft.javachecker.models.JavaTypeModel
      extended by ua.gradsoft.javachecker.models.JavaClassTypeModel
All Implemented Interfaces:
AttributedEntity

public class JavaClassTypeModel
extends JavaTypeModel

TypeModel, based on java class

Author:
Ruslan Shevchenko

Constructor Summary
JavaClassTypeModel(java.lang.Class theClass)
          Creates a new instance of JavaClassTypeModel
 
Method Summary
static JavaTypeModel createTypeModel(java.lang.reflect.Type type)
           
 JavaMemberVariableModel findMemberVariableModel(java.lang.String name)
           
 java.util.List<JavaMethodModel> findMethodModels(java.lang.String name)
           
static java.lang.Class forName(java.lang.String className)
           
 JavaAnnotationInstanceModel getAnnotation(java.lang.String annotationName)
          return annottation instance, if one exists.
 java.util.Map<java.lang.String,JavaAnnotationInstanceModel> getAnnotationsMap()
          get map of annotations, declared in source code.
 Term getASTTerm()
          return AST term, if exoists, otherwise - null
 java.lang.String getCanonicalName()
          get canonical name, siutable for use in JVM
 java.util.List<JavaConstructorModel> getConstructorModels()
          get list of constructor models.
 JavaAnnotationInstanceModel getDefaultAnnotationInstanceModel()
          if this is annotation, get annotation instance model, otherwise return null;
 JavaExpressionModel getDefaultInitializerExpression()
           
 JavaStatementModel getEnclosedStatement()
          if this is local or anonimous class and it is possible to get enclosing statement - return enclosed statement, otherwise - null
 JavaTypeModel getEnclosedType()
          return enclosed class
 java.util.Map<java.lang.String,JavaEnumConstantModel> getEnumConstantModels()
          key of return values are names of enum constants.
 java.lang.String getErasedName()
          all classes from reflection are already erased
 Term getFullNameAsTerm()
           
 java.util.List<JavaInitializerModel> getInitializerModels()
          get list of initializer models
 java.lang.Class<?> getJavaClass()
           
 java.util.Map<java.lang.String,JavaMemberVariableModel> getMemberVariableModels()
          key of return values are names of member variables.
 java.util.Map<java.lang.String,java.util.List<JavaMethodModel>> getMethodModels()
          key of return values is name of methods.
 Term getModelTerm()
          return "ClassTypeModel(context)"
 JavaTermModifiersModel getModifiersModel()
          get modifiers moder
 java.lang.String getName()
           
 java.util.Map<java.lang.String,JavaTypeModel> getNestedTypeModels()
           
 JavaTypeModel getReferencedType()
          Nullable
 Term getShortNameAsTerm()
           
 JavaTypeModel getSuperClass()
          get superclass.
 java.util.List<JavaTypeModel> getSuperInterfaces()
          get all superinterfaces.
 java.util.List<JavaTypeVariableAbstractModel> getTypeParameters()
          return type parameters.
 boolean hasAnnotation(java.lang.String annotationName)
          return true, if this type is annotated by annotation with type annotationTypeName, otherwise false
 boolean hasASTTerm()
          return true, if type model have AST Term
 boolean hasMemberVariableModels()
           
 boolean hasMethodModels()
           
 boolean hasNestedTypeModels()
          when return true, getNestedTypeModels() returns set of nested types.
 boolean hasTypeParameters()
          if this type hase type parameters ?
 boolean isAnnotationType()
           
 boolean isAnonimous()
          true, if this is anonimous type.
 boolean isArray()
           
 boolean isClass()
           
 boolean isEnum()
           
 boolean isInterface()
           
 boolean isLocal()
          true, if this is local type
 boolean isNested()
          return true if this type is nested inside some other type.
 boolean isNull()
           
 boolean isPrimitiveType()
           
 boolean isTypeVariable()
           
 boolean isUnknown()
          return true, if this is unknown typemodel.
 boolean isWildcardBounds()
           
static int translateModifiers(int jm)
          translate modifiers from java.lang.reflect modifiers to our ModifiersModel
 
Methods inherited from class ua.gradsoft.javachecker.models.JavaTypeModel
findNestedTypeModel, getAttribute, getAttributes, getAttributesData, getChildAttributes, getErasedFullName, getFullName, getJavaFacts, getPackageModel, getUnitModel, setAttribute, setUnitModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaClassTypeModel

public JavaClassTypeModel(java.lang.Class theClass)
Creates a new instance of JavaClassTypeModel

Method Detail

getName

public java.lang.String getName()
Specified by:
getName in class JavaTypeModel

getErasedName

public java.lang.String getErasedName()
all classes from reflection are already erased

Specified by:
getErasedName in class JavaTypeModel

getShortNameAsTerm

public Term getShortNameAsTerm()
                        throws TermWareException
Specified by:
getShortNameAsTerm in class JavaTypeModel
Throws:
TermWareException

getFullNameAsTerm

public Term getFullNameAsTerm()
                       throws TermWareException
Specified by:
getFullNameAsTerm in class JavaTypeModel
Throws:
TermWareException

getCanonicalName

public java.lang.String getCanonicalName()
get canonical name, siutable for use in JVM

Overrides:
getCanonicalName in class JavaTypeModel

isClass

public boolean isClass()
Specified by:
isClass in class JavaTypeModel

isInterface

public boolean isInterface()
Specified by:
isInterface in class JavaTypeModel

isEnum

public boolean isEnum()
Specified by:
isEnum in class JavaTypeModel

isAnnotationType

public boolean isAnnotationType()
Specified by:
isAnnotationType in class JavaTypeModel

isPrimitiveType

public boolean isPrimitiveType()
Specified by:
isPrimitiveType in class JavaTypeModel

isArray

public boolean isArray()
Specified by:
isArray in class JavaTypeModel

isTypeVariable

public boolean isTypeVariable()
Specified by:
isTypeVariable in class JavaTypeModel

isWildcardBounds

public boolean isWildcardBounds()
Specified by:
isWildcardBounds in class JavaTypeModel

isNull

public boolean isNull()
Specified by:
isNull in class JavaTypeModel

isUnknown

public boolean isUnknown()
Description copied from class: JavaTypeModel
return true, if this is unknown typemodel. (clients of library can create Unknonwn model, when it is not possible to resolve entity, but resolving is not critical in context)

Specified by:
isUnknown in class JavaTypeModel

getModifiersModel

public JavaTermModifiersModel getModifiersModel()
Description copied from class: JavaTypeModel
get modifiers moder

Specified by:
getModifiersModel in class JavaTypeModel
Returns:
Modifiers model

getSuperClass

public JavaTypeModel getSuperClass()
                            throws TermWareException
Description copied from class: JavaTypeModel
get superclass. does not supported for primitive types, type arguments, wildcard bounds

Specified by:
getSuperClass in class JavaTypeModel
Throws:
TermWareException

getSuperInterfaces

public java.util.List<JavaTypeModel> getSuperInterfaces()
                                                 throws TermWareException
Description copied from class: JavaTypeModel
get all superinterfaces. does not supported for primitive types, type arguments, wildcard bounds, arrays.

Specified by:
getSuperInterfaces in class JavaTypeModel
Returns:
all direct superinterfaces.
Throws:
TermWareException

getEnclosedType

public JavaTypeModel getEnclosedType()
                              throws TermWareException
return enclosed class

Specified by:
getEnclosedType in class JavaTypeModel
Throws:
TermWareException

getReferencedType

public JavaTypeModel getReferencedType()
                                throws TermWareException
Description copied from class: JavaTypeModel
Nullable

Specified by:
getReferencedType in class JavaTypeModel
Returns:
referenced type. Works only if isArray()==true, otherwise return null
Throws:
TermWareException

hasMethodModels

public boolean hasMethodModels()
Specified by:
hasMethodModels in class JavaTypeModel
Returns:
true if type has methods.

getMethodModels

public java.util.Map<java.lang.String,java.util.List<JavaMethodModel>> getMethodModels()
key of return values is name of methods.

Specified by:
getMethodModels in class JavaTypeModel

findMethodModels

public java.util.List<JavaMethodModel> findMethodModels(java.lang.String name)
                                                 throws EntityNotFoundException
Overrides:
findMethodModels in class JavaTypeModel
Throws:
EntityNotFoundException

hasMemberVariableModels

public boolean hasMemberVariableModels()
Specified by:
hasMemberVariableModels in class JavaTypeModel

getMemberVariableModels

public java.util.Map<java.lang.String,JavaMemberVariableModel> getMemberVariableModels()
Description copied from class: JavaTypeModel
key of return values are names of member variables. When type is unappropriative for methods - return empty map

Specified by:
getMemberVariableModels in class JavaTypeModel

findMemberVariableModel

public JavaMemberVariableModel findMemberVariableModel(java.lang.String name)
                                                throws EntityNotFoundException
Overrides:
findMemberVariableModel in class JavaTypeModel
Throws:
EntityNotFoundException

getEnumConstantModels

public java.util.Map<java.lang.String,JavaEnumConstantModel> getEnumConstantModels()
Description copied from class: JavaTypeModel
key of return values are names of enum constants. When type is not enum - return empty map.

Specified by:
getEnumConstantModels in class JavaTypeModel

getConstructorModels

public java.util.List<JavaConstructorModel> getConstructorModels()
Description copied from class: JavaTypeModel
get list of constructor models.

Specified by:
getConstructorModels in class JavaTypeModel

getInitializerModels

public java.util.List<JavaInitializerModel> getInitializerModels()
Description copied from class: JavaTypeModel
get list of initializer models

Specified by:
getInitializerModels in class JavaTypeModel

getDefaultAnnotationInstanceModel

public JavaAnnotationInstanceModel getDefaultAnnotationInstanceModel()
                                                              throws TermWareException,
                                                                     EntityNotFoundException
Description copied from class: JavaTypeModel
if this is annotation, get annotation instance model, otherwise return null;

Specified by:
getDefaultAnnotationInstanceModel in class JavaTypeModel
Throws:
TermWareException
EntityNotFoundException

isNested

public boolean isNested()
Description copied from class: JavaTypeModel
return true if this type is nested inside some other type.

Specified by:
isNested in class JavaTypeModel

hasNestedTypeModels

public boolean hasNestedTypeModels()
Description copied from class: JavaTypeModel
when return true, getNestedTypeModels() returns set of nested types. Otherwise getNestedTypeModels throws NotSupportedException

Specified by:
hasNestedTypeModels in class JavaTypeModel

getNestedTypeModels

public java.util.Map<java.lang.String,JavaTypeModel> getNestedTypeModels()
                                                                  throws TermWareException
Specified by:
getNestedTypeModels in class JavaTypeModel
Returns:
set of nested types.
Throws:
TermWareException

hasTypeParameters

public boolean hasTypeParameters()
Description copied from class: JavaTypeModel
if this type hase type parameters ?

Specified by:
hasTypeParameters in class JavaTypeModel

isLocal

public boolean isLocal()
Description copied from class: JavaTypeModel
true, if this is local type

Specified by:
isLocal in class JavaTypeModel

isAnonimous

public boolean isAnonimous()
Description copied from class: JavaTypeModel
true, if this is anonimous type.

Specified by:
isAnonimous in class JavaTypeModel

getEnclosedStatement

public JavaStatementModel getEnclosedStatement()
Description copied from class: JavaTypeModel
if this is local or anonimous class and it is possible to get enclosing statement - return enclosed statement, otherwise - null

Specified by:
getEnclosedStatement in class JavaTypeModel

getJavaClass

public java.lang.Class<?> getJavaClass()

getTypeParameters

public java.util.List<JavaTypeVariableAbstractModel> getTypeParameters()
return type parameters. (i. e. for class { ... } definitions are )

Specified by:
getTypeParameters in class JavaTypeModel

hasAnnotation

public boolean hasAnnotation(java.lang.String annotationName)
Description copied from class: JavaTypeModel
return true, if this type is annotated by annotation with type annotationTypeName, otherwise false

Overrides:
hasAnnotation in class JavaTypeModel

getAnnotation

public JavaAnnotationInstanceModel getAnnotation(java.lang.String annotationName)
Description copied from class: JavaTypeModel
return annottation instance, if one exists. Otherwise - null.

Overrides:
getAnnotation in class JavaTypeModel

getAnnotationsMap

public java.util.Map<java.lang.String,JavaAnnotationInstanceModel> getAnnotationsMap()
                                                                              throws TermWareException
Description copied from class: JavaTypeModel
get map of annotations, declared in source code.

Specified by:
getAnnotationsMap in class JavaTypeModel
Throws:
TermWareException

hasASTTerm

public boolean hasASTTerm()
Description copied from class: JavaTypeModel
return true, if type model have AST Term

Specified by:
hasASTTerm in class JavaTypeModel

getASTTerm

public Term getASTTerm()
Description copied from class: JavaTypeModel
return AST term, if exoists, otherwise - null

Specified by:
getASTTerm in class JavaTypeModel

getModelTerm

public Term getModelTerm()
                  throws TermWareException
return "ClassTypeModel(context)"

Specified by:
getModelTerm in class JavaTypeModel
Throws:
TermWareException

getDefaultInitializerExpression

public JavaExpressionModel getDefaultInitializerExpression()
                                                    throws TermWareException
Specified by:
getDefaultInitializerExpression in class JavaTypeModel
Returns:
default initializer erxpression, if entity is not initialized. (i.e. null for complex types, and so on)
Throws:
TermWareException

createTypeModel

public static JavaTypeModel createTypeModel(java.lang.reflect.Type type)
                                     throws TermWareException
Throws:
TermWareException

forName

public static java.lang.Class forName(java.lang.String className)
                               throws TermWareException
Throws:
TermWareException

translateModifiers

public static int translateModifiers(int jm)
translate modifiers from java.lang.reflect modifiers to our ModifiersModel