Class JMethodSignature
java.lang.Object
org.codehaus.modello.plugin.java.javasource.JMethodSignature
A class which holds information about the signature
of a JMethod.
The code in this package was modelled after the Java Reflection API
as much as possible to reduce the learning curve.
- Author:
- Keith Visco
-
Constructor Summary
ConstructorDescriptionJMethodSignature
(String name, JType returnType) Creates a new method with the given name and return type. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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[]
Returns the exceptions that this JMethodSignature lists in it's throws clause.Returns the JDocComment describing this JMethodSignatureReturns the modifiers for this JMethodSignature.getName()
Returns the name of the method.getParameter
(int index) Returns the JParameter at the given index.protected String[]
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 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
(String comment) Sets the comment describing this JMethodSignature.void
setModifiers
(JModifiers modifiers) Sets the JModifiers for this method signature.toString()
Returns the String representation of this JMethod, which is the method prototype.
-
Constructor Details
-
JMethodSignature
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 Details
-
addException
Adds the given Exception to this JMethodSignature's throws clause.- Parameters:
exp
- the JClass representing the Exception
-
addParameter
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:
IllegalArgumentException
- when a parameter already exists for this Method with the same name as the new parameter.
-
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
Returns the JDocComment describing this JMethodSignature- Returns:
- the JDocComment describing this JMethodSignature
-
getModifiers
Returns the modifiers for this JMethodSignature.- Returns:
- the modifiers for this JMethodSignature.
-
getName
Returns the name of the method.- Returns:
- the name of the method.
-
getParameter
Returns the JParameter at the given index.- Parameters:
index
- the index of the JParameter to return.- Returns:
- the JParameter at the given index.
-
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
Returns the JType that represents the return type for the method signature.- Returns:
- the JType that represents the return type for the method signature.
-
setComment
Sets the comment describing this JMethodSignature.- Parameters:
comment
- the comment for this member- See Also:
-
setModifiers
Sets the JModifiers for this method signature.- Parameters:
modifiers
- the JModifiers for this method signature.
-
print
Prints the method signature. A semi-colon (end-of-statement terminator ';') will Not be printed.- Parameters:
jsw
- the JSourceWriter to print to.
-
print
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.
-
toString
Returns the String representation of this JMethod, which is the method prototype. -
getParameterClassNames
-