org.codehaus.modello.plugin.java.javasource

Class JMethodSignature

public final class JMethodSignature extends Object

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: 555 $ $Date: 2006-01-29 16:38:08 -0500 (Sun, 29 Jan 2006) $

Author: Keith Visco

Constructor Summary
JMethodSignature(String name, JType returnType)
Creates a new method with the given name and return type.
Method Summary
voidaddException(JClass exp)
Adds the given Exception to this JMethodSignature's throws clause.
voidaddParameter(JParameter parameter)
Adds the given parameter to this JMethodSignature's list of parameters.
JClass[]getExceptions()
Returns the exceptions that this JMethodSignature lists in it's throws clause.
JDocCommentgetJDocComment()
Returns the JDocComment describing this JMethodSignature
JModifiersgetModifiers()
Returns the modifiers for this JMethodSignature.
StringgetName()
Returns the name of the method.
JParametergetParameter(int index)
Returns the JParameter at the given index.
protected String[]getParameterClassNames()
JParameter[]getParameters()
Returns the set of JParameters for this JMethodSignature
Note: the array is a copy, the params in the array are the actual references.
JTypegetReturnType()
Returns the JType that represents the return type for the method signature.
voidprint(JSourceWriter jsw)
Prints the method signature.
voidprint(JSourceWriter jsw, boolean printJavaDoc)
Prints the method signature.
voidsetComment(String comment)
Sets the comment describing this JMethodSignature.
voidsetModifiers(JModifiers modifiers)
Sets the JModifiers for this method signature.
StringtoString()
Returns the String representation of this JMethod, which is the method prototype.

Constructor Detail

JMethodSignature

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

Parameters: name, the method name. Must not be null. returnType the return type of the method. May 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 Methods list of parameters.

Throws: java.lang.IllegalArgumentException when a parameter already exists for this Method with the same name as the new parameter.

getExceptions

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

Returns: the exceptions that this JMethodSignature lists in it's throws clause.

getJDocComment

public JDocComment getJDocComment()
Returns the JDocComment describing this JMethodSignature

Returns: the JDocComment describing this JMethodSignature

getModifiers

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

Returns: the modifiers for this JMethodSignature.

getName

public 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.

getParameterClassNames

protected String[] getParameterClassNames()

getParameters

public JParameter[] getParameters()
Returns the set of JParameters for this JMethodSignature
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()
Returns the JType that represents the return type for the method signature.

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

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 a boolean that when true prints the JDocComment associated with this method signature.

setComment

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

Parameters: comment the comment for this member

See Also: JMethodSignature

setModifiers

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

Parameters: modifiers the JModifiers for this method signature.

toString

public 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

Copyright © 2001-2009 Codehaus. All Rights Reserved.