public interface JMethod extends JMember
| Modifier and Type | Method and Description |
|---|---|
void |
addException(java.lang.String exceptionType)
Adds the given exception to the end of the list of exceptions this method
is declared to throw.
|
java.lang.String |
getBody()
Returns the body of this method.
|
java.lang.String[] |
getExceptions()
Returns the type signatures of the exceptions this method throws,
in the order declared in the source.
|
java.lang.String[] |
getFullParameterTypes()
Returns the full types for the parameters of this method in the order
they are declared, or an empty array if no parameters are declared.
|
java.lang.String[] |
getParameterNames()
Returns the names of parameters in this method in the order they are declared,
or an empty array if no parameters are declared.
|
java.lang.String[] |
getParameters()
Returns the parameters of this method in the order they are declared,
or empty array if no parameters are declared.
|
java.lang.String[] |
getParameterTypes()
Returns the erased type names for the parameters of this method in the order
they are declared, or an empty array if no parameters are declared.
|
java.lang.String |
getReturnType()
Returns the return type name, or
null. |
java.lang.String[] |
getTypeParameters()
Returns the formal type parameters for this method.
|
boolean |
isConstructor()
Returns whether this method is a constructor.
|
void |
setBody(java.lang.String body)
Sets the body of this method.
|
void |
setExceptions(java.lang.String[] exceptionTypes)
Sets the names of the exception types this method throws,
in the order in which they are declared in the source.
|
void |
setParameterNames(java.lang.String[] names)
Sets the names of parameters in this method in the order they are
to be declared.
|
void |
setParameters(java.lang.String[] parameters)
Sets the parameters in this method in the order they are
to be declared.
|
void |
setReturnType(java.lang.String type)
Sets the return type name.
|
void |
setTypeParameters(java.lang.String[] typeParameters)
Sets the formal type parameters for this method.
|
getComment, setCommentgetChildren, getContents, getFlags, getName, getParent, getQualifiedName, setFlags, setNameboolean isConstructor()
true for constructors, and false for methodsjava.lang.String getReturnType()
null.
Returns null for constructors.
The syntax for return type name corresponds to ReturnType in
MethodDeclaration (JLS2 8.4). Names are returned as they appear in the source
code; for example: "File", "java.io.File",
"int[]", or "void".void setReturnType(java.lang.String type)
"File", "java.io.File",
"int[]", or "void".type - the return typejava.lang.String[] getTypeParameters()
Formal type parameters are as they appear in the source
code; for example:
"X extends List<String> & Serializable".
void setTypeParameters(java.lang.String[] typeParameters)
typeParameters - in the order declared in the source, or an empty array if no type parameters
are declaredjava.lang.String[] getParameterNames()
java.lang.String[] getParameterTypes()
"File", "java.io.File", or
"int[]".java.lang.String[] getFullParameterTypes()
"File", "java.io.File", or
"int[]".void setParameterNames(java.lang.String[] names)
throws java.lang.IllegalArgumentException
names - the list of parameter namesjava.lang.IllegalArgumentExceptionjava.lang.String[] getParameters()
"File file", "java.io.File file", or
"int[][] n[]", or final @Annotation int[]... n.void setParameters(java.lang.String[] parameters)
"File file", "java.io.File file", or
"int[][] n[]", or final @Annotation int[]... n.parameters - the list of parameters, or or an empty array if no parameters
are declaredjava.lang.String[] getExceptions()
For example, a source method declaring "throws IOException",
would return the array {"QIOException;"}.
The type signatures may be either unresolved (for source types) or resolved (for binary types), and either basic (for basic types) or rich (for parameterized types).
void setExceptions(java.lang.String[] exceptionTypes)
"IOException" or "java.io.IOException".exceptionTypes - the list of exception typesvoid addException(java.lang.String exceptionType)
"IOException" or "java.io.IOException".
This is a convenience method for setExceptions.exceptionType - the exception typesetExceptions(String[])java.lang.String getBody()
null if the method has no body (for
example, for an abstract or native method)void setBody(java.lang.String body)
body - the body, or null indicating the method has no body (for
example, for an abstract or native method)Copyright © 2021. Licensed under the Eclipse Public License v2.0. All rights reserved.
Submit a bug or feature