Package org.jtool.srcmodel
Class JavaClass
java.lang.Object
org.jtool.srcmodel.JavaElement
org.jtool.srcmodel.JavaClass
An object representing a class, an interface, an enum, or an anonymous class for a lambda expression.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final QualifiedName
The constant value that represents the array class.Fields inherited from class org.jtool.srcmodel.JavaElement
astNode, codeRange
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Create a new empty object for storing nothing.Creates a new object representing a class.Creates a new object representing a class.JavaClass
(org.eclipse.jdt.core.dom.ASTNode node, org.eclipse.jdt.core.dom.ITypeBinding tbinding, JavaFile jfile) Creates a new object representing a class.Creates a new object representing a class.JavaClass
(org.eclipse.jdt.core.dom.LambdaExpression node, org.eclipse.jdt.core.dom.ITypeBinding tbinding, String name, JavaMethod jmethod) Creates a new object representing a class.Creates a new object representing a class. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addInnerClass
(JavaClass jclass) Adds an inner class enclosed in this class.void
addMethod
(JavaMethod jmethod) Adds a method enclosed in this class.void
addUsedClass
(JavaClass jclass) Adds a class used by this class.boolean
boolean
Tests if a given class is equal to this class.Obtains classes requiring this class.Obtains classes requiring this class, which have their corresponding files.Obtains super classes in the distance order.Obtains super interfaces.Obtains ancestors of this class.Obtains child classes of this class.Returns the fully-qualified name of this class.Returns the class that declares this class.Returns the method that declares this class.Obtains descendants of this class.Obtains classes required by this class.Obtains classes required by this class that has its corresponding file.Obtains a field enclosed in this class, having a given name.Obtains fields enclosed in this class.getFile()
Returns the file that declares this class.Obtains a static initializer enclosed in this class.Obtains classes enclosed in this class.Returns the project which this class exists in.Obtains a method enclosed in this class, having a given name.Obtains methods enclosed in this class.int
The the value that stores information on the modifiers of this class.getName()
Returns the name of this class.Obtains classes that are obsolete at the same time when this class is updated.Returns the package that this class belongs to.Returns the fully-qualified name of this class.Obtains fields enclosed in this class, which are sorted in the dictionary order.Obtains classes enclosed in this class, which are sorted in the dictionary order.Obtains methods enclosed in this class, which are sorted in the dictionary order.Returns the super class of this class.Returns the name of the super class of this class.Return the collection of the super interfaces of this class.Obtains super interfaces of this class.org.eclipse.jdt.core.dom.ITypeBinding
Returns the type binding information on this class.Obtains classes used by this class.int
hashCode()
boolean
Tests if this is an abstract class.boolean
Tests if this is an anonymous class.boolean
Tests if this class is a child of a given parent class.boolean
isClass()
Tests if this is a class.boolean
Tests if this class has the default visibility.boolean
isEnum()
Tests if this is a class holding the enum constant declarations.boolean
isFinal()
Tests if this is a final class.boolean
Tests if this class exists inside the target project, which can resent the corresponding source code.boolean
Tests if this is an interface.boolean
isLambda()
Tests if this is an anonymous class for the lambda expression.boolean
Tests if this class has the private visibility.boolean
Tests if this class has the protected visibility.boolean
isPublic()
Tests if this class has the public visibility.boolean
isStatic()
Tests if this is a static class.boolean
Tests if this is a strict-floating-point class.sortClasses
(List<? extends JavaClass> list) Sorts the list of classes.sortFields
(List<? extends JavaField> list) Sorts the list of fields.static List<JavaMethod>
sortMethods
(List<? extends JavaMethod> list) Sorts the list of methods.toString()
Obtains information on this class.Methods inherited from class org.jtool.srcmodel.JavaElement
getASTNode, getCodeRange, getSource
-
Field Details
-
ArrayClassFqn
The constant value that represents the array class.
-
-
Constructor Details
-
JavaClass
protected JavaClass()Create a new empty object for storing nothing. -
JavaClass
public JavaClass(org.eclipse.jdt.core.dom.TypeDeclaration node, JavaFile jfile) throws JavaElementException Creates a new object representing a class. This constructor is not intended to be invoked by clients.- Parameters:
node
- the AST node for this class or interfacejfile
- the file that declares this class- Throws:
JavaElementException
- the exception occurs when the creation of a new object fails
-
JavaClass
public JavaClass(org.eclipse.jdt.core.dom.AnonymousClassDeclaration node, JavaFile jfile) throws JavaElementException Creates a new object representing a class. This constructor is not intended to be invoked by clients.- Parameters:
node
- the AST node for this anonymous classjfile
- the file that declares this class- Throws:
JavaElementException
- the exception occurs when the creation of a new object fails
-
JavaClass
public JavaClass(org.eclipse.jdt.core.dom.EnumDeclaration node, JavaFile jfile) throws JavaElementException Creates a new object representing a class. This constructor is not intended to be invoked by clients.- Parameters:
node
- the AST node for this class holding the enum constant declarationsjfile
- the file that declares this class- Throws:
JavaElementException
- the exception occurs when the creation of a new object fails
-
JavaClass
public JavaClass(org.eclipse.jdt.core.dom.AnnotationTypeDeclaration node, JavaFile jfile) throws JavaElementException Creates a new object representing a class. This constructor is not intended to be invoked by clients.- Parameters:
node
- the AST node for this annotation typejfile
- the file that declares this class- Throws:
JavaElementException
- the exception occurs when the creation of a new object fails
-
JavaClass
public JavaClass(org.eclipse.jdt.core.dom.ASTNode node, org.eclipse.jdt.core.dom.ITypeBinding tbinding, JavaFile jfile) throws JavaElementException Creates a new object representing a class. This constructor is not intended to be invoked by clients.- Parameters:
node
- an AST node for this classtbinding
- type binding information on this classjfile
- a file that declares this class- Throws:
JavaElementException
- the exception occurs when the creation of a new object fails
-
JavaClass
public JavaClass(org.eclipse.jdt.core.dom.LambdaExpression node, org.eclipse.jdt.core.dom.ITypeBinding tbinding, String name, JavaMethod jmethod) Creates a new object representing a class. This constructor is not intended to be invoked by clients.- Parameters:
node
- the AST node for this anonymous class for a lambda expressiontbinding
- type binding information on this classname
- the name of this classjmethod
- a method that encloses this class
-
-
Method Details
-
getJavaProject
Returns the project which this class exists in.- Specified by:
getJavaProject
in classJavaElement
- Returns:
- the project
-
getFile
Returns the file that declares this class.- Specified by:
getFile
in classJavaElement
- Returns:
- the declaring file
-
getQualifiedName
Returns the fully-qualified name of this class.- Specified by:
getQualifiedName
in classJavaElement
- Returns:
- the fully-qualified class name
-
getName
Returns the name of this class.- Returns:
- the class name
-
getClassName
Returns the fully-qualified name of this class.- Returns:
- the fully-qualified class name
-
getModifiers
public int getModifiers()The the value that stores information on the modifiers of this class.- Returns:
- the modifier value of this class
-
getTypeBinding
public org.eclipse.jdt.core.dom.ITypeBinding getTypeBinding()Returns the type binding information on this class.- Returns:
- the type binding information
-
isInProject
public boolean isInProject()Tests if this class exists inside the target project, which can resent the corresponding source code.- Returns:
true
if this class exists inside the target project, otherwisefalse
-
getDeclaringClass
Returns the class that declares this class.- Returns:
- the declaring class, or
null
if this class is not enclosed by any class
-
getDeclaringMethod
Returns the method that declares this class.- Returns:
- the declaring method, or
null
if this class is not enclosed by any method
-
getPackage
Returns the package that this class belongs to.- Returns:
- the package of this class, or
null
if this class does not have its source code
-
isClass
public boolean isClass()Tests if this is a class.- Returns:
true
if this is a class, otherwisefalse
-
isInterface
public boolean isInterface()Tests if this is an interface.- Returns:
true
if this is an interface, otherwisefalse
-
isEnum
public boolean isEnum()Tests if this is a class holding the enum constant declarations.- Returns:
true
if this is an enum, otherwisefalse
-
isAnonymous
public boolean isAnonymous()Tests if this is an anonymous class.- Returns:
true
if this is an anonymous class, otherwisefalse
-
isLambda
public boolean isLambda()Tests if this is an anonymous class for the lambda expression.- Returns:
true
if this is an anonymous class for the lambda expression, otherwisefalse
-
isPublic
public boolean isPublic()Tests if this class has the public visibility.- Returns:
true
if this class has the public visibility, otherwisefalse
-
isProtected
public boolean isProtected()Tests if this class has the protected visibility.- Returns:
true
if this class has the protected visibility, otherwisefalse
-
isPrivate
public boolean isPrivate()Tests if this class has the private visibility.- Returns:
true
if this class has the private visibility, otherwisefalse
-
isDefault
public boolean isDefault()Tests if this class has the default visibility.- Returns:
true
if this class has the default visibility, otherwisefalse
-
isFinal
public boolean isFinal()Tests if this is a final class.- Returns:
true
if this is a final class, otherwisefalse
-
isAbstract
public boolean isAbstract()Tests if this is an abstract class.- Returns:
true
if this is an abstract class, otherwisefalse
-
isStatic
public boolean isStatic()Tests if this is a static class.- Returns:
true
if this is a static class, otherwisefalse
-
isStrictfp
public boolean isStrictfp()Tests if this is a strict-floating-point class.- Returns:
true
if this is a strict-floating-point class, otherwisefalse
-
getSuperClassName
Returns the name of the super class of this class.- Returns:
- the super class name, or
null
if this is an interface
-
getSuperInterfaceNames
Return the collection of the super interfaces of this class.- Returns:
- the super interfaces names
-
getField
Obtains a field enclosed in this class, having a given name.- Parameters:
name
- the name of the field to be retrieved- Returns:
- the found field, or
null
if a corresponding field is not found
-
getFields
Obtains fields enclosed in this class.- Returns:
- the collection of the fields
-
getSortedFields
Obtains fields enclosed in this class, which are sorted in the dictionary order.- Returns:
- the sorted list of the fields
-
addMethod
Adds a method enclosed in this class. This method is not intended to be invoked by clients.- Parameters:
jmethod
- the method to be added
-
getMethod
Obtains a method enclosed in this class, having a given name.- Parameters:
sig
- the signature of the method to be retrieved- Returns:
- the found method, or
null
if a corresponding method is not found
-
getInitializer
Obtains a static initializer enclosed in this class.- Returns:
- the static initializer, or
null
if this class does not have any static initializer
-
getMethods
Obtains methods enclosed in this class.- Returns:
- the collection of the methods
-
getSortedMethods
Obtains methods enclosed in this class, which are sorted in the dictionary order.- Returns:
- the sorted list of the methods
-
addInnerClass
Adds an inner class enclosed in this class. This method is not intended to be invoked by clients.- Parameters:
jclass
- the method to be added
-
getInnerClasses
Obtains classes enclosed in this class.- Returns:
- the collection of the inner classes
-
getSortedInnerClasses
Obtains classes enclosed in this class, which are sorted in the dictionary order.- Returns:
- the sorted list of the classes
-
equals
-
equals
Tests if a given class is equal to this class.- Parameters:
jclass
- the class to be checked- Returns:
- the
true
if the given class is equal to this class
-
hashCode
public int hashCode() -
toString
Obtains information on this class. -
sortFields
Sorts the list of fields.- Parameters:
list
- the field list- Returns:
- the sorted field list
-
sortMethods
Sorts the list of methods.- Parameters:
list
- the method list- Returns:
- the sorted method list
-
sortClasses
Sorts the list of classes.- Parameters:
list
- the class list- Returns:
- the sorted class list
-
addUsedClass
Adds a class used by this class. This method is not intended to be invoked by clients.- Parameters:
jclass
- the class to be added
-
getSuperClass
Returns the super class of this class.- Returns:
- the super class
-
getSuperInterfaces
Obtains super interfaces of this class.- Returns:
- the collection of the super interfaces
-
getUsedClasses
Obtains classes used by this class.- Returns:
- the collection of the used classes, an empty set when this class does not have its corresponding file
-
getEfferentClasses
Obtains classes required by this class.- Returns:
- the collection of the required classes
-
getChildren
Obtains child classes of this class.- Returns:
- the list of the child classes
-
isChildOf
Tests if this class is a child of a given parent class.- Parameters:
jclass
- the possible parent class- Returns:
true
if this class is a child of the given class, otherwisefalse
-
getAllSuperClasses
Obtains super classes in the distance order. The closest ancestor (i.e. parent) is located at the first position.- Returns:
- the ordered list of the super classes
-
getAllSuperInterfaces
Obtains super interfaces.- Returns:
- the collection of the super interfaces
-
getAncestors
Obtains ancestors of this class.- Returns:
- the collection of the ancestors
-
getDescendants
Obtains descendants of this class.- Returns:
- the collection of the descendants
-
getEfferentClassesInProject
Obtains classes required by this class that has its corresponding file.- Returns:
- the collection of the required classes
-
getAfferentClasses
Obtains classes requiring this class.- Returns:
- the collection of the requiring classes
-
getAfferentClassesInProject
Obtains classes requiring this class, which have their corresponding files.- Returns:
- the collection of the requiring classes
-
getObsoleteClasses
Obtains classes that are obsolete at the same time when this class is updated.- Returns:
- the collection of the obsolete classes
-