|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.exolab.javasource.JMethod
public 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(JType returnType,
java.lang.String name)
Creates a new JMethod with the given name and returnType. |
|
JMethod(java.lang.String name)
Creates a new JMethod with the given name and "void" return type. |
Method Summary | |
---|---|
void |
addAnnotation(JAnnotation annotation)
Adds a JAnnotation to this source element. |
protected void |
addDeclaringClass(JClass jClass)
Adds the given JClass to the set of classes that contain this method. |
void |
addException(JClass exp)
Adds the given Exception to this Method'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 JMember throws. |
JDocComment |
getJDocComment()
Returns the JDocComment describing this member. |
JModifiers |
getModifiers()
Returns the modifiers for this JMember. |
java.lang.String |
getName()
Returns the name of this JMember. |
JParameter |
getParameter(int index)
Returns the JParameter at the given index. |
protected java.lang.String[] |
getParameterClassNames()
|
JParameter[] |
getParameters()
Returns the set of JParameters for this JMethod. |
JType |
getReturnType()
Returns the JType that represents the return type of the method. |
JMethodSignature |
getSignature()
Returns the JMethodSignature for this JMethod. |
JSourceCode |
getSourceCode()
Returns the JSourceCode for the method body. |
boolean |
hasAnnotations()
Returns true if annotations have been added to this source element |
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, throws a IllegalArgumentException if no JAnnotation has been added. |
protected void |
removeDeclaringClass(JClass jClass)
Removes the given JClass from the set of classes that contain this method. |
void |
setComment(java.lang.String comment)
Sets the comment describing this member. |
void |
setModifiers(JModifiers modifiers)
Sets the JModifiers for this JMethod. |
void |
setName(java.lang.String name)
Sets the name of this JMember. |
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()
Returns the String representation of this JMethod, which is the method prototype. |
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(JType returnType, java.lang.String name)
name,
- the method name. Must not be null.returnType
- the return type of the method. May be null.Method Detail |
---|
public void addException(JClass exp)
exp
- the JClass representing the Exceptionpublic void addParameter(JParameter parameter) throws java.lang.IllegalArgumentException
parameter
- the parameter to add to the this Methods
list of parameters.
java.lang.IllegalArgumentException
- when a parameter already
exists for this Method with the same name as the new parameterpublic 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 methodpublic void setComment(java.lang.String comment)
comment
- the comment for this membergetJDocComment()
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 void print(JSourceWriter jsw)
jsw
- the JSourceWriter to print to.public java.lang.String toString()
toString
in class java.lang.Object
public JAnnotation getAnnotation(JAnnotationType annotationType)
JAnnotatedElement
getAnnotation
in interface JAnnotatedElement
public JAnnotation[] getAnnotations()
JAnnotatedElement
getAnnotations
in interface JAnnotatedElement
public boolean isAnnotationPresent(JAnnotationType annotationType)
JAnnotatedElement
isAnnotationPresent
in interface JAnnotatedElement
public void addAnnotation(JAnnotation annotation) throws java.lang.IllegalArgumentException
JAnnotatedElement
addAnnotation
in interface JAnnotatedElement
java.lang.IllegalArgumentException
public JAnnotation removeAnnotation(JAnnotationType annotationType) throws java.lang.IllegalArgumentException
JAnnotatedElement
removeAnnotation
in interface JAnnotatedElement
java.lang.IllegalArgumentException
public boolean hasAnnotations()
JAnnotatedElement
hasAnnotations
in interface JAnnotatedElement
protected void addDeclaringClass(JClass jClass)
jClass
- the JClass to add as one of
the JClasses that contain this method.protected void removeDeclaringClass(JClass jClass)
jClass
- the JClass to add as one of
the JClasses that contain this method.protected java.lang.String[] getParameterClassNames()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |