org.exolab.javasource
Class JMethod
java.lang.Object
org.exolab.javasource.JMethod
- JMember
public class JMethod
extends java.lang.Object
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.
$Revision: 1.1.1.1 $ $Date: 2003/03/03 07:09:55 $JMethod(String name) - Creates a new JMethod with the given name and "void" return type.
|
JMethod(JType returnType, String name) - Creates a new JMethod with the given name and returnType.
|
JMethod
public JMethod(String name)
Creates a new JMethod with the given name and "void" return type.
JMethod
public JMethod(JType returnType,
String name)
Creates a new JMethod with the given name and returnType.
For "void" return types, simply pass in null as the returnType.
returnType
- the return type of the method. May be null.
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)
Adds the given Exception to this Method's throws clause.
exp
- the JClass representing the Exception
addParameter
public void addParameter(JParameter parameter)
throws IllegalArgumentException
Adds the given parameter to this JMethod's list of parameters.
parameter
- the parameter to add to the this Methods
list of parameters.
getExceptions
public JClass[] getExceptions()
Returns the exceptions that this JMember throws.
- the exceptions that this JMember throws.
getJDocComment
public JDocComment getJDocComment()
Returns the JDocComment describing this member.
- the JDocComment describing this member.
getModifiers
public JModifiers getModifiers()
Returns the modifiers for this JMember.
- getModifiers in interface JMember
- the modifiers for this JMember.
getName
public String getName()
Returns the name of this JMember.
- getName in interface JMember
- the name of this JMember.
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()
getParameters
public JParameter[] getParameters()
Returns the set of JParameters for this JMethod.
Note: the array is a copy, the params 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 method.
- the JType that represents the return type of the method.
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 add as one of
the JClasses that contain this method.
setComment
public void setComment(String comment)
Sets the comment describing this member. The comment
will be printed when this member is printed with the
Class Printer.
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.
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
Intalio Inc. (C) 1999-2003. All rights reserved http://www.intalio.com