A class which holds information about the methods of a JClass. Modelled
closely after the Java Reflection API. This class is part of package which
is used to create source code.
addDeclaringClass
protected void addDeclaringClass(JClass jClass)
Adds the given JClass to the set of classes that contain this method.
jClass
- the JClass to add as one of the JClasses that contain this
method
addException
public void addException(JClass exp,
String description)
Adds the given Exception to this JMethod's throws clause.
exp
- the JClass representing the Exceptiondescription
- JavaDoc comment explaining when this exception is thrown
addParameter
public void addParameter(JParameter parameter)
Adds the given parameter to this JMethod's list of parameters.
parameter
- the parameter to add to the this JMethod's list of
parameters.
getExceptions
public JClass[] getExceptions()
Returns the exceptions that this JMethod throws.
- the exceptions that this JMethod throws.
getJDocComment
public JDocComment getJDocComment()
Returns the JavaDoc comment describing this JMethod.
- the JavaDoc comment describing this JMethod.
getModifiers
public JModifiers getModifiers()
Returns the modifiers for this JMethod.
- getModifiers in interface JMember
- the modifiers for this JMethod.
getName
public String getName()
Returns the name of this JMethod.
- getName in interface JMember
- the name of this JMethod.
getParameter
public JParameter getParameter(int index)
Returns the JParameter at the given index.
index
- the index of the JParameter to return
- the JParameter at the given index.
getParameterClassNames
protected String[] getParameterClassNames()
Return the list of class names representing the parameters.
- the list of class names representing the parameters
getParameters
public JParameter[] getParameters()
Returns the set of JParameters for this JMethod.
Note: the array is a copy, the parameters in the array are the
actual references
- the set of JParameters for this JMethod.
getReturnType
public JType getReturnType()
Returns the JType that represents the return type of the JMethod.
- the JType that represents the return type of the JMethod.
getSignature
public JMethodSignature getSignature()
Returns the JMethodSignature for this JMethod.
- the JMethodSignature for this JMethod.
getSourceCode
public JSourceCode getSourceCode()
Returns the JSourceCode for the method body.
- the JSourceCode for the method body.
print
public void print(JSourceWriter jsw)
Prints this JMethod to the given JSourceWriter.
jsw
- the JSourceWriter to print to
removeDeclaringClass
protected void removeDeclaringClass(JClass jClass)
Removes the given JClass from the set of classes that contain this method.
jClass
- the JClass to remove as one of the JClasses that contain
this method
setComment
public void setComment(String comment)
Sets the comment describing this JMethod. The comment will be printed
when this JMethod is printed.
comment
- the comment for this member
setModifiers
public void setModifiers(JModifiers modifiers)
Sets the JModifiers for this JMethod. This JMethod will use only a copy
of the JModifiers.
Note: The JModifiers will be set in the containing
JMethodSignature. If the JMethodSignature is used by other methods, keep
in mind that it will be changed.
modifiers
- the JModifiers to set.
setName
public void setName(String name)
Sets the name of this JMethod.
name
- the name of this method
setSourceCode
public void setSourceCode(String source)
Sets the given string as the source code (method body) for this JMethod.
source
- the String that represents the method body
setSourceCode
public void setSourceCode(JSourceCode source)
Sets the given JSourceCode as the source code (method body) for this
JMethod.
source
- the JSourceCode that represents the method body
toString
public String toString()
Returns the String representation of this JMethod, which is the method
prototype.
- the String representation of this JMethod, which is simply the
method prototype