JAnnotatedElement, JMemberpublic final class JMethod extends java.lang.Object implements JMember, JAnnotatedElement
| Constructor | Description | 
|---|---|
JMethod(java.lang.String name) | 
 Creates a new JMethod with the given name and "void" return type. 
 | 
JMethod(java.lang.String name,
       JType returnType,
       java.lang.String returnDoc) | 
 Creates a new JMethod with the given name and returnType. 
 | 
| Modifier and Type | Method | Description | 
|---|---|---|
void | 
addAnnotation(JAnnotation annotation) | 
 Adds a JAnnotation to this source element. 
 | 
void | 
addException(JClass exp,
            java.lang.String description) | 
 Adds the given Exception to this JMethod's throws clause. 
 | 
void | 
addParameter(JParameter parameter) | 
 Adds the given parameter to this JMethod's list of parameters. 
 | 
JAnnotation | 
getAnnotation(JAnnotationType annotationType) | 
 Retrieves a JAnnotation for the given JAnnotationType, returns null if no
 annotation has been set. 
 | 
JAnnotation[] | 
getAnnotations() | 
 Returns a list of JAnnotation's already set on this source element. 
 | 
int | 
getExceptionCount() | 
 Returns the amount of exceptions thrown. 
 | 
JClass[] | 
getExceptions() | 
 Returns the exceptions that this JMethod throws. 
 | 
JDocComment | 
getJDocComment() | 
 Returns the JavaDoc comment describing this JMethod. 
 | 
JModifiers | 
getModifiers() | 
 Returns the modifiers for this JMethod. 
 | 
java.lang.String | 
getName() | 
 Returns the name of this JMethod. 
 | 
JParameter | 
getParameter(int index) | 
 Returns the JParameter at the given index. 
 | 
int | 
getParameterCount() | 
 Returns the amount of parameters. 
 | 
JParameter[] | 
getParameters() | 
 Returns the set of JParameters for this JMethod. 
 | 
JType | 
getReturnType() | 
 Returns the JType that represents the return type of the JMethod. 
 | 
JMethodSignature | 
getSignature() | 
 Returns the JMethodSignature for this JMethod. 
 | 
JSourceCode | 
getSourceCode() | 
 Returns the JSourceCode for the method body. 
 | 
boolean | 
hasAnnotations() | 
 Returns true if this source element has any annotations. 
 | 
boolean | 
isAnnotationPresent(JAnnotationType annotationType) | 
 Returns true if a JAnnotation exists for the given JAnnotationType. 
 | 
void | 
print(JSourceWriter jsw) | 
 Prints this JMethod to the given JSourceWriter. 
 | 
JAnnotation | 
removeAnnotation(JAnnotationType annotationType) | 
 Removes the JAnnotation from this source element for the given
 JAnnotationType. 
 | 
void | 
setComment(java.lang.String comment) | 
 Sets the comment describing this JMethod. 
 | 
void | 
setModifiers(JModifiers modifiers) | 
 Sets the JModifiers for this JMethod. 
 | 
void | 
setName(java.lang.String name) | 
 Sets the name of this JMethod. 
 | 
void | 
setSourceCode(java.lang.String source) | 
 Sets the given string as the source code (method body) for this JMethod. 
 | 
void | 
setSourceCode(JSourceCode source) | 
 Sets the given JSourceCode as the source code (method body) for this
 JMethod. 
 | 
java.lang.String | 
toString() | 
public JMethod(java.lang.String name)
name - The method name. Must not be null.public JMethod(java.lang.String name,
               JType returnType,
               java.lang.String returnDoc)
JMethod(String) instead of this constructor.name - The method name. Must not be null.returnType - The return type of the method. Must not be null.returnDoc - Javadoc comment for the @return annotation. If
            null, a default (and mostly useless) javadoc comment will be
            generated.public void addException(JClass exp, java.lang.String description)
exp - The JClass representing the Exception.description - JavaDoc comment explaining when this exception is thrown.public void addParameter(JParameter parameter)
parameter - The parameter to add to the this JMethod's list of
        parameters.public JDocComment getJDocComment()
public JClass[] getExceptions()
public int getExceptionCount()
public JModifiers getModifiers()
getModifiers in interface JMemberpublic java.lang.String getName()
public JParameter getParameter(int index)
index - The index of the JParameter to return.public JParameter[] getParameters()
public int getParameterCount()
public JType getReturnType()
public JMethodSignature getSignature()
public JSourceCode getSourceCode()
public void setName(java.lang.String name)
name - The name of this method.public void setComment(java.lang.String comment)
comment - The comment for this member.public void setModifiers(JModifiers modifiers)
modifiers - The JModifiers to set.public void setSourceCode(java.lang.String source)
source - The String that represents the method body.public void setSourceCode(JSourceCode source)
source - The JSourceCode that represents the method body.public java.lang.String toString()
toString in class java.lang.Objectpublic JAnnotation getAnnotation(JAnnotationType annotationType)
getAnnotation in interface JAnnotatedElementannotationType - Annotation type to retrieve.public JAnnotation[] getAnnotations()
getAnnotations in interface JAnnotatedElementpublic boolean isAnnotationPresent(JAnnotationType annotationType)
isAnnotationPresent in interface JAnnotatedElementannotationType - Annotation type to check for presence or absense.public void addAnnotation(JAnnotation annotation)
addAnnotation in interface JAnnotatedElementannotation - A JAnnotation to add to this source element.public JAnnotation removeAnnotation(JAnnotationType annotationType)
removeAnnotation in interface JAnnotatedElementannotationType - Annotation type to remove.public boolean hasAnnotations()
hasAnnotations in interface JAnnotatedElementpublic void print(JSourceWriter jsw)
jsw - The JSourceWriter to print to.Intalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com