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.
org.exolab.javasource.JMethod.JMethod | ( | String | name | ) |
Creates a new JMethod with the given name and "void" return type.
name,the | method name. Must not be null. |
org.exolab.javasource.JMethod.JMethod | ( | JType | returnType, | |
String | name | |||
) |
Creates a new JMethod with the given name and returnType. For "void" return types, simply pass in null as the returnType.
name,the | method name. Must not be null. | |
returnType | the return type of the method. May be null. |
References org.exolab.javasource.JDocComment.appendComment(), and org.exolab.javasource.JMethodSignature.getJDocComment().
void org.exolab.javasource.JMethod.addAnnotation | ( | JAnnotation | annotation | ) | throws IllegalArgumentException |
Adds a JAnnotation to this source element. An IllegalArgumentException is thrown if one already exists for the associated JAnnotationType.
annotation |
Implements org.exolab.javasource.JAnnotatedElement.
void org.exolab.javasource.JMethod.addDeclaringClass | ( | JClass | jClass | ) | [protected] |
void org.exolab.javasource.JMethod.addException | ( | JClass | exp | ) |
Adds the given Exception to this Method's throws clause.
exp | the JClass representing the Exception |
References org.exolab.javasource.JMethodSignature.addException().
Referenced by org.exolab.castor.builder.CollectionInfoJ2.createAccessMethods(), org.exolab.castor.builder.CollectionInfo.createAccessMethods(), and org.exolab.castor.builder.SourceFactory.createTestableMethods().
void org.exolab.javasource.JMethod.addParameter | ( | JParameter | parameter | ) | throws IllegalArgumentException |
Adds the given parameter to this JMethod's list of parameters.
parameter | the parameter to add to the this Methods list of parameters. |
IllegalArgumentException | when a parameter already exists for this Method with the same name as the new parameter |
References org.exolab.javasource.JMethodSignature.addParameter(), org.exolab.javasource.JType.getComponentType(), org.exolab.javasource.JStructure.getName(), org.exolab.javasource.JType.isArray(), and org.exolab.javasource.JType.isPrimitive().
Referenced by org.exolab.castor.builder.IdentityInfo.createAccessMethods(), org.exolab.castor.builder.FieldInfo.createAccessMethods(), org.exolab.castor.builder.CollectionInfoJ2.createAccessMethods(), org.exolab.castor.builder.CollectionInfo.createAccessMethods(), and org.exolab.castor.builder.SourceFactory.createEqualsMethod().
JAnnotation org.exolab.javasource.JMethod.getAnnotation | ( | JAnnotationType | annotationType | ) |
Retrieves a JAnnotation for the given JAnnotationType, returns null if no annotation has been set.
annotationType |
Implements org.exolab.javasource.JAnnotatedElement.
JAnnotation [] org.exolab.javasource.JMethod.getAnnotations | ( | ) |
Returns a list of JAnnotation's already set on this source element
Implements org.exolab.javasource.JAnnotatedElement.
JClass [] org.exolab.javasource.JMethod.getExceptions | ( | ) |
Returns the class in which this JMember has been declared
public JClass getDeclaringClass() { return _declaringClass; } //-- getDeclaringClass Returns the exceptions that this JMember throws.
References org.exolab.javasource.JMethodSignature.getExceptions().
JDocComment org.exolab.javasource.JMethod.getJDocComment | ( | ) |
Returns the JDocComment describing this member.
Referenced by org.exolab.castor.builder.FieldInfo.createAccessMethods(), org.exolab.castor.builder.CollectionInfoJ2.createGetCollectionReferenceMethod(), org.exolab.castor.builder.CollectionInfo.createGetCollectionReferenceMethod(), org.exolab.castor.builder.CollectionInfoJ2.createSetCollectionMethod(), org.exolab.castor.builder.CollectionInfo.createSetCollectionMethod(), org.exolab.castor.builder.CollectionInfoJ2.createSetCollectionReferenceMethod(), and org.exolab.castor.builder.CollectionInfo.createSetCollectionReferenceMethod().
JModifiers org.exolab.javasource.JMethod.getModifiers | ( | ) |
Returns the modifiers for this JMember.
References org.exolab.javasource.JMethodSignature.getModifiers().
Referenced by org.exolab.javasource.JClass.addMethod().
String org.exolab.javasource.JMethod.getName | ( | ) |
Returns the name of this JMember.
References org.exolab.javasource.JMethodSignature.getName().
Referenced by org.exolab.javasource.JClass.addMember(), org.exolab.javasource.JClass.addMethod(), and org.exolab.javasource.JClass.getMethod().
JParameter org.exolab.javasource.JMethod.getParameter | ( | int | index | ) |
Returns the JParameter at the given index.
index | the index of the JParameter to return. |
References org.exolab.javasource.JMethodSignature.getParameter().
Referenced by org.exolab.castor.builder.CollectionInfoODMG30.createSetArrayMethod(), org.exolab.castor.builder.CollectionInfoJ2.createSetArrayMethod(), org.exolab.castor.builder.CollectionInfo.createSetArrayMethod(), org.exolab.castor.builder.CollectionInfoJ2.createSetCollectionMethod(), org.exolab.castor.builder.CollectionInfo.createSetCollectionMethod(), org.exolab.castor.builder.CollectionInfoJ2.createSetCollectionReferenceMethod(), and org.exolab.castor.builder.CollectionInfo.createSetCollectionReferenceMethod().
String [] org.exolab.javasource.JMethod.getParameterClassNames | ( | ) | [protected] |
JParameter [] org.exolab.javasource.JMethod.getParameters | ( | ) |
Returns the set of JParameters for this JMethod.
Note: the array is a copy, the params in the array are the actual references.
References org.exolab.javasource.JMethodSignature.getParameters().
JType org.exolab.javasource.JMethod.getReturnType | ( | ) |
Returns the JType that represents the return type of the method.
References org.exolab.javasource.JMethodSignature.getReturnType().
Referenced by org.exolab.castor.builder.CollectionInfoODMG30.createGetByIndexMethod(), org.exolab.castor.builder.CollectionInfoJ2.createGetByIndexMethod(), org.exolab.castor.builder.CollectionInfo.createGetByIndexMethod(), org.exolab.castor.builder.CollectionInfoODMG30.createGetMethod(), org.exolab.castor.builder.CollectionInfoJ2.createGetMethod(), org.exolab.castor.builder.CollectionInfo.createGetMethod(), org.exolab.castor.builder.CollectionInfoODMG30.createRemoveByIndexMethod(), org.exolab.castor.builder.CollectionInfoJ2.createRemoveByIndexMethod(), org.exolab.castor.builder.CollectionInfo.createRemoveByIndexMethod(), and org.exolab.castor.builder.SourceFactory.createTestableMethods().
JMethodSignature org.exolab.javasource.JMethod.getSignature | ( | ) |
Returns the JMethodSignature for this JMethod.
JSourceCode org.exolab.javasource.JMethod.getSourceCode | ( | ) |
Returns the JSourceCode for the method body.
Referenced by org.exolab.castor.builder.IdentityInfo.createAccessMethods(), org.exolab.castor.builder.FieldInfo.createAccessMethods(), org.exolab.castor.builder.CollectionInfoODMG30.createAddInsertMethod(), org.exolab.castor.builder.CollectionInfoJ2.createAddInsertMethod(), org.exolab.castor.builder.CollectionInfo.createAddInsertMethod(), org.exolab.castor.builder.CollectionInfoODMG30.createAddMethod(), org.exolab.castor.builder.CollectionInfoJ2.createAddMethod(), org.exolab.castor.builder.CollectionInfo.createAddMethod(), org.exolab.castor.builder.CollectionInfoJ2.createClearMethod(), org.exolab.castor.builder.CollectionInfoODMG30.createEnumerateMethod(), org.exolab.castor.builder.CollectionInfoJ2.createEnumerateMethod(), org.exolab.castor.builder.CollectionInfo.createEnumerateMethod(), org.exolab.castor.builder.SourceFactory.createEqualsMethod(), org.exolab.castor.builder.CollectionInfoODMG30.createGetByIndexMethod(), org.exolab.castor.builder.CollectionInfoJ2.createGetByIndexMethod(), org.exolab.castor.builder.CollectionInfo.createGetByIndexMethod(), org.exolab.castor.builder.CollectionInfoJ2.createGetCollectionReferenceMethod(), org.exolab.castor.builder.CollectionInfo.createGetCollectionReferenceMethod(), org.exolab.castor.builder.CollectionInfo.createGetCountMethod(), org.exolab.castor.builder.CollectionInfoODMG30.createGetMethod(), org.exolab.castor.builder.CollectionInfoJ2.createGetMethod(), org.exolab.castor.builder.CollectionInfo.createGetMethod(), org.exolab.castor.builder.CollectionInfoODMG30.createRemoveAllMethod(), org.exolab.castor.builder.CollectionInfoJ2.createRemoveAllMethod(), org.exolab.castor.builder.CollectionInfo.createRemoveAllMethod(), org.exolab.castor.builder.CollectionInfoODMG30.createRemoveByIndexMethod(), org.exolab.castor.builder.CollectionInfoJ2.createRemoveByIndexMethod(), org.exolab.castor.builder.CollectionInfo.createRemoveByIndexMethod(), org.exolab.castor.builder.CollectionInfoJ2.createRemoveByObjectMethod(), org.exolab.castor.builder.CollectionInfo.createRemoveByObjectMethod(), org.exolab.castor.builder.CollectionInfoJ2.createRemoveMethod(), org.exolab.castor.builder.CollectionInfoODMG30.createSetArrayMethod(), org.exolab.castor.builder.CollectionInfoJ2.createSetArrayMethod(), org.exolab.castor.builder.CollectionInfo.createSetArrayMethod(), org.exolab.castor.builder.CollectionInfoODMG30.createSetByIndexMethod(), org.exolab.castor.builder.CollectionInfoJ2.createSetByIndexMethod(), org.exolab.castor.builder.CollectionInfo.createSetByIndexMethod(), org.exolab.castor.builder.CollectionInfoJ2.createSetCollectionMethod(), org.exolab.castor.builder.CollectionInfo.createSetCollectionMethod(), org.exolab.castor.builder.CollectionInfoJ2.createSetCollectionReferenceMethod(), org.exolab.castor.builder.CollectionInfo.createSetCollectionReferenceMethod(), org.exolab.castor.builder.SourceFactory.createTestableMethods(), and org.exolab.castor.builder.CollectionInfo.getReadMethod().
boolean org.exolab.javasource.JMethod.hasAnnotations | ( | ) |
Returns true if annotations have been added to this source element
Implements org.exolab.javasource.JAnnotatedElement.
boolean org.exolab.javasource.JMethod.isAnnotationPresent | ( | JAnnotationType | annotationType | ) |
Returns true if a JAnnotation exists for the given JAnnotationType
annotationType |
Implements org.exolab.javasource.JAnnotatedElement.
void org.exolab.javasource.JMethod.print | ( | JSourceWriter | jsw | ) |
Prints this JMethod to the given JSourceWriter.
jsw | the JSourceWriter to print to. |
References org.exolab.javasource.JMethodSignature.getModifiers(), org.exolab.javasource.JSourceCode.print(), org.exolab.javasource.JMethodSignature.print(), org.exolab.javasource.JDocComment.print(), org.exolab.javasource.JMethod.toString(), org.exolab.javasource.JSourceWriter.write(), and org.exolab.javasource.JSourceWriter.writeln().
Referenced by org.exolab.javasource.JClass.print().
JAnnotation org.exolab.javasource.JMethod.removeAnnotation | ( | JAnnotationType | annotationType | ) | throws IllegalArgumentException |
Removes the JAnnotation from this source element for the given JAnnotationType, throws a IllegalArgumentException if no JAnnotation has been added.
annotation |
Implements org.exolab.javasource.JAnnotatedElement.
void org.exolab.javasource.JMethod.removeDeclaringClass | ( | JClass | jClass | ) | [protected] |
void org.exolab.javasource.JMethod.setComment | ( | String | comment | ) |
Sets the comment describing this member. The comment will be printed when this member is printed with the Class Printer.
comment | the comment for this member |
References org.exolab.javasource.JDocComment.setComment().
Referenced by org.exolab.castor.builder.SourceFactory.createEqualsMethod(), and org.exolab.castor.builder.SourceFactory.createTestableMethods().
void org.exolab.javasource.JMethod.setModifiers | ( | JModifiers | modifiers | ) |
Sets the JModifiers for this JMethod. This JMethod will use only a copy of the JModifiers. Note: The JModifiers will be set in the containing JMethodSignature. If the JMethodSignature is used by other methods, keep in mind that it will be changed.
modifiers | the JModifiers to set. |
References org.exolab.javasource.JMethodSignature.setModifiers().
void org.exolab.javasource.JMethod.setName | ( | String | name | ) |
Sets the name of this JMember.
name | the name of this method |
References org.exolab.javasource.JMethodSignature.setName().
void org.exolab.javasource.JMethod.setSourceCode | ( | String | source | ) |
Sets the given string as the source code (method body) for this JMethod.
source | the String that represents the method body. |
Referenced by org.exolab.javasource.JClass.main().
void org.exolab.javasource.JMethod.setSourceCode | ( | JSourceCode | source | ) |
Sets the given JSourceCode as the source code (method body) for this JMethod.
source | the JSourceCode that represents the method body. |
String org.exolab.javasource.JMethod.toString | ( | ) |
Returns the String representation of this JMethod, which is the method prototype.
References org.exolab.javasource.JMethodSignature.toString().
Referenced by org.exolab.javasource.JMethod.print().