Package org.jtool.srcmodel
Class JavaMethod
java.lang.Object
org.jtool.srcmodel.JavaElement
org.jtool.srcmodel.JavaMethod
An object representing a method, a constructor, a static initializer, or a lambda expression.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Set<JavaMethod>
The collection of methods that invoke this method.protected Set<JavaMethod>
The collection of methods that this method overrides.Fields inherited from class org.jtool.srcmodel.JavaElement
astNode, codeRange
-
Constructor Summary
ConstructorsConstructorDescriptionJavaMethod
(org.eclipse.jdt.core.dom.Initializer node, JavaClass jclass) Creates a new object representing a method.JavaMethod
(org.eclipse.jdt.core.dom.LambdaExpression node, org.eclipse.jdt.core.dom.IMethodBinding mbinding, JavaClass jclass) Creates a new object representing a method.JavaMethod
(org.eclipse.jdt.core.dom.MethodDeclaration node, JavaClass jclass) Creates a new object representing a method. -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
equals
(JavaMethod jmethod) Tests if a given method is equal to this method.Obtains fields that this method accesses.Obtains fields that this method accesses, which are enclosed in the target project.Obtains fields that call this method in their declaration.Obtains fields that call this method in their declaration, which are enclosed in the target project.Obtains methods that this method invokes.Obtains methods that this method invokes, which are enclosed in the target project.Obtains methods that invoke this method.Obtains methods that invoke this method, which are enclosed in the target project.Returns the name of this method.A class that declares (and encloses the declaration of) this method.Obtains classes corresponding to the types of exceptions.org.eclipse.jdt.core.dom.ASTNode
getExceptionTypeNode
(String type) Obtains the AST node corresponding to the type of an exception.Collection<org.eclipse.jdt.core.dom.Type>
Returns the collection of AST nodes corresponding to the types of exceptions that this method might throw.getFile()
Returns the file that declares this method.Returns the project which this method exists in.getLocalVariable
(String name, int id) Obtains a local variable having a given name and identification number.Obtains the list of local variables used in this method.org.eclipse.jdt.core.dom.IMethodBinding
Returns the method binding information on this method.int
The the value that stores information on the modifiers of this variable.getName()
Returns the name of this method.Obtains methods that this method overrides.Obtains methods that override this method.getParameter
(int index) Obtains a parameter specified by the index for the parameter list.getParameter
(String name) Obtains a parameter having a given name for the parameter list.int
getParameterIndex
(String name) Obtains the index value of a parameter having a given name for the parameter list.Obtains the list of all parameters of this method.int
Obtains the number of parameters of this method.static String
getParameterString
(org.eclipse.jdt.core.dom.IMethodBinding mbinding) Obtains the string that represents parameters of a method having a given method binding information.Returns the fully-qualified name of this method.Returns the return type of this method.Returns the signature of this method.static String
getSignature
(org.eclipse.jdt.core.dom.IMethodBinding mbinding) Obtains the signature of a method having a given method binding information.int
hashCode()
boolean
Tests if this is an abstract method.boolean
Tests if this is a constructor.boolean
Tests if this method has the default visibility.boolean
isFinal()
Tests if this is a final method.boolean
Tests if this is a static initializer.boolean
Tests if this method exists inside the target project, which can resent the corresponding source code.boolean
isLambda()
Tests if this is a lambda expression.boolean
isMethod()
Tests if this is a method.boolean
isNative()
Tests if this is a native method.boolean
Tests if the return type of this method is primitive.boolean
Tests if this method has the private visibility.boolean
Tests if this method has the protected visibility.boolean
isPublic()
Tests if this method has the public visibility.boolean
isStatic()
Tests if this is a static method.boolean
Tests if this is a strict-floating-point method.boolean
Tests if this is a synchronized method.boolean
Tests if this is a synthetic method that was made up by the compiler.boolean
isVoid()
Tests if the return type of this method is void, that is, it does not have the return type.toString()
Obtains information on this field.Obtains information on all parameters of this method.Methods inherited from class org.jtool.srcmodel.JavaElement
getASTNode, getCodeRange, getSource
-
Field Details
-
callingMethods
The collection of methods that invoke this method. -
overriddenMethods
The collection of methods that this method overrides.
-
-
Constructor Details
-
JavaMethod
public JavaMethod(org.eclipse.jdt.core.dom.MethodDeclaration node, JavaClass jclass) throws JavaElementException Creates a new object representing a method. This constructor is not intended to be invoked by clients.- Parameters:
node
- the AST node for this methodjclass
- the class that declares this method- Throws:
JavaElementException
- the exception occurs when the creation of a new object fails
-
JavaMethod
Creates a new object representing a method. This constructor is not intended to be invoked by clients.- Parameters:
node
- the AST node for this static initializerjclass
- the class that declares this method
-
JavaMethod
public JavaMethod(org.eclipse.jdt.core.dom.LambdaExpression node, org.eclipse.jdt.core.dom.IMethodBinding mbinding, JavaClass jclass) Creates a new object representing a method. This constructor is not intended to be invoked by clients.- Parameters:
node
- the AST node for this method for a lambda expressionmbinding
- the binding information on this methodjclass
- the class that declares this method
-
-
Method Details
-
getJavaProject
Returns the project which this method exists in.- Specified by:
getJavaProject
in classJavaElement
- Returns:
- the project
-
getFile
Returns the file that declares this method.- Specified by:
getFile
in classJavaElement
- Returns:
- the declaring file
-
getQualifiedName
Returns the fully-qualified name of this method.- Specified by:
getQualifiedName
in classJavaElement
- Returns:
- the fully-qualified method name
-
getName
Returns the name of this method.- Returns:
- the method name
-
getClassName
Returns the name of this method.- Returns:
- the class name
-
getSignature
Returns the signature of this method.- Returns:
- the method signature
-
getReturnType
Returns the return type of this method.- Returns:
- the type name
-
isPrimitiveReturnType
public boolean isPrimitiveReturnType()Tests if the return type of this method is primitive.- Returns:
true
if the return type of this method is primitive, otherwisefalse
-
isVoid
public boolean isVoid()Tests if the return type of this method is void, that is, it does not have the return type.- Returns:
true
if the return type of this method is void, otherwisefalse
-
getModifiers
public int getModifiers()The the value that stores information on the modifiers of this variable.- Returns:
- the modifier value of this variable
-
getMethodBinding
public org.eclipse.jdt.core.dom.IMethodBinding getMethodBinding()Returns the method binding information on this method.- Returns:
- the method binding information
-
isInProject
public boolean isInProject()Tests if this method exists inside the target project, which can resent the corresponding source code.- Returns:
true
if this method exists inside the target project, otherwisefalse
-
getDeclaringClass
A class that declares (and encloses the declaration of) this method.- Returns:
- the declaring class
-
isMethod
public boolean isMethod()Tests if this is a method.- Returns:
true
if this is a method, otherwisefalse
-
isConstructor
public boolean isConstructor()Tests if this is a constructor.- Returns:
true
if this is a constructor, otherwisefalse
-
isInitializer
public boolean isInitializer()Tests if this is a static initializer.- Returns:
true
if this is a static initializer, otherwisefalse
-
isLambda
public boolean isLambda()Tests if this is a lambda expression.- Returns:
true
if this is lambda expression, otherwisefalse
-
isSynthetic
public boolean isSynthetic()Tests if this is a synthetic method that was made up by the compiler.- Returns:
true
if this is a synthetic method, otherwisefalse
-
getParameters
Obtains the list of all parameters of this method.- Returns:
- the parameter list
-
getParameterSize
public int getParameterSize()Obtains the number of parameters of this method.- Returns:
- the number of the parameters
-
getParameter
Obtains a parameter specified by the index for the parameter list.- Parameters:
index
- the index number of the parameter of this method- Returns:
- the local variable of the found parameter
-
getParameter
Obtains a parameter having a given name for the parameter list.- Parameters:
name
- the parameter name- Returns:
- the local variable of the found parameter
-
getParameterIndex
Obtains the index value of a parameter having a given name for the parameter list.- Parameters:
name
- the parameter name- Returns:
- the local variable of the found parameter
-
getLocalVariables
Obtains the list of local variables used in this method.- Returns:
- the local variable list
-
getLocalVariable
Obtains a local variable having a given name and identification number.- Parameters:
name
- the name of the local variable to be retrievedid
- the identification number of the local variable to be retrieved- Returns:
- the found local variable, or
null
if any local variable is not found
-
getExceptionTypeNodes
Returns the collection of AST nodes corresponding to the types of exceptions that this method might throw.- Returns:
- the collection of type nodes for the thrown exceptions
-
getExceptionTypeNode
Obtains the AST node corresponding to the type of an exception.- Parameters:
type
- the type of the thrown exception- Returns:
- the type node for the the thrown exception, or
null
if there is no corresponding type node
-
isPublic
public boolean isPublic()Tests if this method has the public visibility.- Returns:
true
if this method has the public visibility, otherwisefalse
-
isProtected
public boolean isProtected()Tests if this method has the protected visibility.- Returns:
true
if this method has the protected visibility, otherwisefalse
-
isPrivate
public boolean isPrivate()Tests if this method has the private visibility.- Returns:
true
if this method has the private visibility, otherwisefalse
-
isDefault
public boolean isDefault()Tests if this method has the default visibility.- Returns:
true
if this method has the default visibility, otherwisefalse
-
isFinal
public boolean isFinal()Tests if this is a final method.- Returns:
true
if this is a final method, otherwisefalse
-
isAbstract
public boolean isAbstract()Tests if this is an abstract method.- Returns:
true
if this is an abstract method, otherwisefalse
-
isStatic
public boolean isStatic()Tests if this is a static method.- Returns:
true
if this is a static method, otherwisefalse
-
isSynchronized
public boolean isSynchronized()Tests if this is a synchronized method.- Returns:
true
if this is a synchronized method, otherwisefalse
-
isNative
public boolean isNative()Tests if this is a native method.- Returns:
true
if this is a native method, otherwisefalse
-
isStrictfp
public boolean isStrictfp()Tests if this is a strict-floating-point method.- Returns:
true
if this is a strict-floating-point method, otherwisefalse
-
getSignature
Obtains the signature of a method having a given method binding information.- Parameters:
mbinding
- the method binding information- Returns:
- the string representing the signature
-
getParameterString
Obtains the string that represents parameters of a method having a given method binding information.- Parameters:
mbinding
- the method binding information- Returns:
- the string representing the parameters
-
equals
-
equals
Tests if a given method is equal to this method.- Parameters:
jmethod
- the method to be checked- Returns:
- the
true
if the given method is equal to this method
-
hashCode
public int hashCode() -
toString
Obtains information on this field. -
toStringForParameters
Obtains information on all parameters of this method.- Returns:
- the string representing the information
-
getExceptions
Obtains classes corresponding to the types of exceptions.- Returns:
- the collection of the corresponding classes
-
getCalledMethods
Obtains methods that this method invokes.- Returns:
- the collection of the called methods
-
getCalledMethodsInProject
Obtains methods that this method invokes, which are enclosed in the target project.- Returns:
- the collection of the called methods
-
getCallingMethods
Obtains methods that invoke this method.- Returns:
- the collection of the calling methods
-
getCallingMethodsInProject
Obtains methods that invoke this method, which are enclosed in the target project.- Returns:
- the collection of the calling methods
-
getAccessedFields
Obtains fields that this method accesses.- Returns:
- the collection of the accessed fields
-
getAccessedFieldsInProject
Obtains fields that this method accesses, which are enclosed in the target project.- Returns:
- the collection of the accessed fields
-
getAccessingFields
Obtains fields that call this method in their declaration.- Returns:
- the collection of the accessing fields
-
getAccessingFieldsInProject
Obtains fields that call this method in their declaration, which are enclosed in the target project.- Returns:
- the collection of the accessing fields
-
getOverriddenMethods
Obtains methods that this method overrides.- Returns:
- the collection of the overridden methods
-
getOverridingMethods
Obtains methods that override this method.- Returns:
- the collection of the overriding methods
-