org.exolab.javasource
Class JMethodSignature

java.lang.Object
  extended by org.exolab.javasource.JAnnotatedElementHelper
      extended by org.exolab.javasource.JMethodSignature
All Implemented Interfaces:
JAnnotatedElement

public final class JMethodSignature
extends JAnnotatedElementHelper

A class which holds information about the signtaure of a JMethod. The code in this package was modelled after the Java Reflection API as much as possible to reduce the learning curve.

Version:
$Revision: 6677 $ $Date: 2004-12-03 11:57:33 -0700 (Fri, 03 Dec 2004) $
Author:
Keith Visco

Constructor Summary
JMethodSignature(java.lang.String name)
          Creates a new method with the given name and "void" return type.
JMethodSignature(java.lang.String name, JType returnType)
          Creates a new method with the given name and return type.
 
Method Summary
 void addException(JClass exp)
          Adds the given Exception to this JMethodSignature's throws clause.
 void addParameter(JParameter parameter)
          Adds the given parameter to this JMethodSignature's list of parameters.
 JClass[] getExceptions()
          Returns the exceptions that this JMethodSignature lists in its throws clause.
 JDocComment getJDocComment()
          Returns the JavaDoc comment describing this JMethodSignature.
 JModifiers getModifiers()
          Returns the modifiers for this JMethodSignature.
 java.lang.String getName()
          Returns the name of the method.
 JParameter getParameter(int index)
          Returns the JParameter at the given index.
protected  java.lang.String[] getParameterClassNames()
          Returns an array containing the names of the classes of the parameters in this JMethodSignature.
 JParameter[] getParameters()
          Returns the set of JParameters in this JMethodSignature.
 JType getReturnType()
          Returns the JType that represents the return type for the method signature.
 void print(JSourceWriter jsw)
          Prints the method signature.
 void print(JSourceWriter jsw, boolean printJavaDoc)
          Prints the method signature.
 void setComment(java.lang.String comment)
          Sets the JavaDoc comment describing this JMethodSignature.
 void setModifiers(JModifiers modifiers)
          Sets the JModifiers for this method signature.
 void setName(java.lang.String name)
          Sets the name of the method.
 java.lang.String toString()
          
 
Methods inherited from class org.exolab.javasource.JAnnotatedElementHelper
addAnnotation, getAnnotation, getAnnotations, hasAnnotations, isAnnotationPresent, printAnnotations, removeAnnotation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JMethodSignature

public JMethodSignature(java.lang.String name)
Creates a new method with the given name and "void" return type.

Parameters:
name - The method name. Must not be null.

JMethodSignature

public JMethodSignature(java.lang.String name,
                        JType returnType)
Creates a new method with the given name and return type.

Parameters:
name - The method name. Must not be null.
returnType - The return type of the method. Must not be null.
Method Detail

addException

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

Parameters:
exp - The JClass representing the Exception.

addParameter

public void addParameter(JParameter parameter)
Adds the given parameter to this JMethodSignature's list of parameters.

Parameters:
parameter - The parameter to add to the this JMethodSignature's list of parameters.

getExceptions

public JClass[] getExceptions()
Returns the exceptions that this JMethodSignature lists in its throws clause.

Returns:
The exceptions that this JMethodSignature lists in its throws clause.

getJDocComment

public JDocComment getJDocComment()
Returns the JavaDoc comment describing this JMethodSignature.

Returns:
The JavaDoc comment describing this JMethodSignature.

getModifiers

public JModifiers getModifiers()
Returns the modifiers for this JMethodSignature.

Returns:
The modifiers for this JMethodSignature.

getName

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

Returns:
The name of the method.

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 in this JMethodSignature.
Note: the array is a copy, the parameters in the array are the actual references.

Returns:
The set of JParameters in this JMethodSignature.

getReturnType

public JType getReturnType()
Returns the JType that represents the return type for the method signature.

Returns:
The JType that represents the return type for the method signature.

setName

public void setName(java.lang.String name)
Sets the name of the method.

Parameters:
name - The name of the method.

setComment

public void setComment(java.lang.String comment)
Sets the JavaDoc comment describing this JMethodSignature.

Parameters:
comment - The JavaDoc comment for this member.

setModifiers

public void setModifiers(JModifiers modifiers)
Sets the JModifiers for this method signature.

Parameters:
modifiers - The JModifiers for this method signature.

getParameterClassNames

protected java.lang.String[] getParameterClassNames()
Returns an array containing the names of the classes of the parameters in this JMethodSignature. For Arrays, the class name of the object type stored in the Array is what is returned. Parameters that are primitive types (and Arrays of primitive types) are not represented in the array of names returned.

Returns:
An array containing the names of the classes of the parameters in this JMethodSignature.

print

public void print(JSourceWriter jsw)
Prints the method signature. A semi-colon (end-of-statement terminator ';') will not be printed.

Parameters:
jsw - The JSourceWriter to print to.

print

public void print(JSourceWriter jsw,
                  boolean printJavaDoc)
Prints the method signature. A semi-colon (end-of-statement terminator ';') will not be printed.

Parameters:
jsw - The JSourceWriter to print to.
printJavaDoc - If true, print the JDocComment associated with this method signature before we print the method signature.

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object


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