org.exolab.javasource
Class JMethod

java.lang.Object
  extended byorg.exolab.javasource.JMethod
All Implemented Interfaces:
JMember

public class JMethod
extends java.lang.Object
implements JMember

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.

Version:
$Revision: 1.9 $ $Date: 2001/09/07 02:03:56 $
Author:
Keith Visco

Constructor Summary
JMethod(JType returnType, java.lang.String name)
          Creates a new method with the given name and returnType.
 
Method Summary
 void addException(JClass exp)
          Adds the given Exception to this Method's throws clause
 void addParameter(JParameter parameter)
          Adds the given parameter to this Methods list of parameters
 JClass getDeclaringClass()
          Returns the class in which this JMember has been declared
 JClass[] getExceptions()
          Returns the exceptions that this JMember throws
 JDocComment getJDocComment()
          Returns the JDocComment describing this member.
 JModifiers getModifiers()
          Returns the modifiers for this JMember
 java.lang.String getName()
          Returns the name of this JMember
 JParameter getParameter(int index)
          Returns the JParameter at the given index
protected  java.lang.String[] getParameterClassNames()
           
 JParameter[] getParameters()
          Returns the set of JParameters for this JMethod.
 JType getReturnType()
           
 JSourceCode getSourceCode()
           
 void print(JSourceWriter jsw)
           
 void setComment(java.lang.String comment)
          Sets the comment describing this member.
protected  void setDeclaringClass(JClass declaringClass)
           
 void setModifiers(JModifiers modifiers)
           
 void setName(java.lang.String name)
          Sets the name of this JMember
 void setSourceCode(JSourceCode source)
           
 void setSourceCode(java.lang.String source)
           
 java.lang.String toString()
          Returns the String representation of this JMethod, which is the method prototype.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JMethod

public JMethod(JType returnType,
               java.lang.String name)
Creates a new method with the given name and returnType. For "void" return types, simply pass in null as the returnType

Method Detail

addException

public void addException(JClass exp)
Adds the given Exception to this Method's throws clause

Parameters:
exp - the JClass representing the Exception

addParameter

public void addParameter(JParameter parameter)
                  throws java.lang.IllegalArgumentException
Adds the given parameter to this Methods list of parameters

Parameters:
parameter - the parameter to add to the this Methods list of parameters.
Throws:
java.lang.IllegalArgumentException - when a parameter already exists for this Method with the same name as the new parameter

getJDocComment

public JDocComment getJDocComment()
Returns the JDocComment describing this member.

Returns:
the JDocComment describing this member.

getDeclaringClass

public JClass getDeclaringClass()
Returns the class in which this JMember has been declared

Specified by:
getDeclaringClass in interface JMember
Returns:
the class in which this JMember has been declared

getExceptions

public JClass[] getExceptions()
Returns the exceptions that this JMember throws

Returns:
the exceptions that this JMember throws

getModifiers

public JModifiers getModifiers()
Returns the modifiers for this JMember

Specified by:
getModifiers in interface JMember
Returns:
the modifiers for this JMember

getName

public java.lang.String getName()
Returns the name of this JMember

Specified by:
getName in interface JMember
Returns:
the name of this JMember

getParameter

public JParameter getParameter(int index)
Returns the JParameter at the given index

Parameters:
index - the index of the JParameter to return
Returns:
the JParameter at the given index

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.

Returns:
the set of JParameters for this JMethod

getReturnType

public JType getReturnType()

getSourceCode

public JSourceCode getSourceCode()

setComment

public void setComment(java.lang.String comment)
Sets the comment describing this member. The comment will be printed when this member is printed with the Class Printer

Parameters:
comment - the comment for this member
See Also:
getJDocComment()

setName

public void setName(java.lang.String name)
             throws java.lang.IllegalArgumentException
Sets the name of this JMember

Parameters:
name - the name of this JMember
Throws:
java.lang.IllegalArgumentException - when the name is not a valid Java member name, or if a member with the given name already exists in the declaring class

setModifiers

public void setModifiers(JModifiers modifiers)

setDeclaringClass

protected void setDeclaringClass(JClass declaringClass)

setSourceCode

public void setSourceCode(java.lang.String source)

setSourceCode

public void setSourceCode(JSourceCode source)

print

public void print(JSourceWriter jsw)

toString

public java.lang.String toString()
Returns the String representation of this JMethod, which is the method prototype.

Returns:
the String representation of this JMethod, which is simply the method prototype

getParameterClassNames

protected java.lang.String[] getParameterClassNames()


Intalio Inc. (C) 1999-2001. All rights reserved http://www.intalio.com