|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.exolab.javasource.JMethod
public final class JMethod
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.
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
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. |
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. |
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(JSourceCode source)
Sets the given JSourceCode as the source code (method body) for this JMethod. |
void |
setSourceCode(java.lang.String source)
Sets the given string as the source code (method body) for this JMethod. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
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.Method Detail |
---|
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 JModifiers getModifiers()
getModifiers
in interface JMember
public java.lang.String getName()
getName
in interface JMember
public JParameter getParameter(int index)
index
- The index of the JParameter to return.
public JParameter[] getParameters()
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.Object
public JAnnotation getAnnotation(JAnnotationType annotationType)
getAnnotation
in interface JAnnotatedElement
annotationType
- Annotation type to retrieve.
public JAnnotation[] getAnnotations()
getAnnotations
in interface JAnnotatedElement
public boolean isAnnotationPresent(JAnnotationType annotationType)
isAnnotationPresent
in interface JAnnotatedElement
annotationType
- Annotation type to check for presence or absense.
public void addAnnotation(JAnnotation annotation)
addAnnotation
in interface JAnnotatedElement
annotation
- A JAnnotation to add to this source element.public JAnnotation removeAnnotation(JAnnotationType annotationType)
removeAnnotation
in interface JAnnotatedElement
annotationType
- Annotation type to remove.
public boolean hasAnnotations()
hasAnnotations
in interface JAnnotatedElement
public void print(JSourceWriter jsw)
jsw
- The JSourceWriter to print to.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |