com.sun.codemodel
Class JMethod

java.lang.Object
  extended by com.sun.codemodel.JMethod
All Implemented Interfaces:
JDeclaration

public class JMethod
extends java.lang.Object
implements JDeclaration

Java method


Method Summary
 JMethod _throws(java.lang.Class exception)
           
 JMethod _throws(JClass exception)
          Add an exception to the list of exceptions that this method may throw.
 JBlock body()
          Get the block that makes up body of this method
 void declare(JFormatter f)
           
 JMods getMods()
           
 boolean hasSignature(JType[] argTypes)
          Returns true if the method has the specified signature.
 JDocComment javadoc()
          Creates, if necessary, and returns the class javadoc for this JDefinedClass
 JVar[] listParams()
          Returns all the parameters in an array.
 JType[] listParamTypes()
          Returns all the parameter types in an array.
 java.lang.String name()
           
 JVar param(java.lang.Class type, java.lang.String name)
           
 JVar param(int mods, java.lang.Class type, java.lang.String name)
           
 JVar param(int mods, JType type, java.lang.String name)
          Add the specified variable to the list of parameters for this method signature.
 JVar param(JType type, java.lang.String name)
           
 JType type()
          Returns the return type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

_throws

public JMethod _throws(JClass exception)
Add an exception to the list of exceptions that this method may throw.

Parameters:
exception - Name of an exception that this method may throw

_throws

public JMethod _throws(java.lang.Class exception)

param

public JVar param(int mods,
                  JType type,
                  java.lang.String name)
Add the specified variable to the list of parameters for this method signature.

Parameters:
type - JType of the parameter being added
name - Name of the parameter being added
Returns:
New parameter variable

param

public JVar param(JType type,
                  java.lang.String name)

param

public JVar param(int mods,
                  java.lang.Class type,
                  java.lang.String name)

param

public JVar param(java.lang.Class type,
                  java.lang.String name)

name

public java.lang.String name()

type

public JType type()
Returns the return type.

Returns:

listParamTypes

public JType[] listParamTypes()
Returns all the parameter types in an array.

Returns:
If there's no parameter, an empty array will be returned.

listParams

public JVar[] listParams()
Returns all the parameters in an array.

Returns:
If there's no parameter, an empty array will be returned.

hasSignature

public boolean hasSignature(JType[] argTypes)
Returns true if the method has the specified signature.


body

public JBlock body()
Get the block that makes up body of this method

Returns:
Body of method

javadoc

public JDocComment javadoc()
Creates, if necessary, and returns the class javadoc for this JDefinedClass

Returns:
JDocComment containing javadocs for this class

declare

public void declare(JFormatter f)
Specified by:
declare in interface JDeclaration

getMods

public JMods getMods()
Returns:
the current modifiers of this method. Always return non-null valid object.