Public Member Functions | Protected Member Functions

org.exolab.javasource.JMethod Class Reference

Inheritance diagram for org.exolab.javasource.JMethod:
org.exolab.javasource.JMember org.exolab.javasource.JAnnotatedElement

List of all members.

Public Member Functions

 JMethod (String name)
 JMethod (JType returnType, String name)
void addException (JClass exp)
void addParameter (JParameter parameter) throws IllegalArgumentException
JDocComment getJDocComment ()
JClass[] getExceptions ()
JModifiers getModifiers ()
String getName ()
JParameter getParameter (int index)
JParameter[] getParameters ()
JType getReturnType ()
JMethodSignature getSignature ()
JSourceCode getSourceCode ()
void setName (String name)
void setComment (String comment)
void setModifiers (JModifiers modifiers)
void setSourceCode (String source)
void setSourceCode (JSourceCode source)
void print (JSourceWriter jsw)
String toString ()
JAnnotation getAnnotation (JAnnotationType annotationType)
JAnnotation[] getAnnotations ()
boolean isAnnotationPresent (JAnnotationType annotationType)
void addAnnotation (JAnnotation annotation) throws IllegalArgumentException
JAnnotation removeAnnotation (JAnnotationType annotationType) throws IllegalArgumentException
boolean hasAnnotations ()

Protected Member Functions

void addDeclaringClass (JClass jClass)
void removeDeclaringClass (JClass jClass)
String[] getParameterClassNames ()

Detailed Description

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.

Author:
Keith Visco
Version:
Revision:
1.4
Date:
2004/12/03 18:47:32

Constructor & Destructor Documentation

org.exolab.javasource.JMethod.JMethod ( String  name  ) 

Creates a new JMethod with the given name and "void" return type.

Parameters:
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.

Parameters:
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().


Member Function Documentation

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.

Parameters:
annotation 

Implements org.exolab.javasource.JAnnotatedElement.

void org.exolab.javasource.JMethod.addDeclaringClass ( JClass  jClass  )  [protected]

Adds the given JClass to the set of classes that contain this method.

Parameters:
jClass the JClass to add as one of the JClasses that contain this method.
void org.exolab.javasource.JMethod.addException ( JClass  exp  ) 
void org.exolab.javasource.JMethod.addParameter ( JParameter  parameter  )  throws IllegalArgumentException
JAnnotation org.exolab.javasource.JMethod.getAnnotation ( JAnnotationType  annotationType  ) 

Retrieves a JAnnotation for the given JAnnotationType, returns null if no annotation has been set.

Parameters:
annotationType 
Returns:
A JAnnotation for the given JAnnotationType

Implements org.exolab.javasource.JAnnotatedElement.

JAnnotation [] org.exolab.javasource.JMethod.getAnnotations (  ) 

Returns a list of JAnnotation's already set on this source element

Returns:
A list of all JAnnotations associated with this source element

Implements org.exolab.javasource.JAnnotatedElement.

JClass [] org.exolab.javasource.JMethod.getExceptions (  ) 

Returns the class in which this JMember has been declared

Returns:
the class in which this JMember has been declared

public JClass getDeclaringClass() { return _declaringClass; } //-- getDeclaringClass Returns the exceptions that this JMember throws.

Returns:
the exceptions that this JMember throws.

References org.exolab.javasource.JMethodSignature.getExceptions().

JModifiers org.exolab.javasource.JMethod.getModifiers (  ) 

Returns the modifiers for this JMember.

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 (  ) 
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.

Returns:
the set of JParameters for this JMethod

References org.exolab.javasource.JMethodSignature.getParameters().

JMethodSignature org.exolab.javasource.JMethod.getSignature (  ) 

Returns the JMethodSignature for this JMethod.

Returns:
the JMethodSignature for this JMethod.
JSourceCode org.exolab.javasource.JMethod.getSourceCode (  ) 

Returns the JSourceCode for the method body.

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

Returns:
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

Parameters:
annotationType 
Returns:
True if a JAnnotation has been added for the given JAnnotationType

Implements org.exolab.javasource.JAnnotatedElement.

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.

Parameters:
annotation 
Returns:
The JAnnotation that was associated with this source element

Implements org.exolab.javasource.JAnnotatedElement.

void org.exolab.javasource.JMethod.removeDeclaringClass ( JClass  jClass  )  [protected]

Removes the given JClass from the set of classes that contain this method.

Parameters:
jClass the JClass to add as one of the JClasses that contain this method.
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.

Parameters:
comment the comment for this member
See also:
getJDocComment

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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Returns:
the String representation of this JMethod, which is simply the method prototype

References org.exolab.javasource.JMethodSignature.toString().

Referenced by org.exolab.javasource.JMethod.print().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties