com.sun.codemodel
Class JMethod

java.lang.Object  extended by com.sun.codemodel.JMethod
All Implemented Interfaces:
JAnnotatable, JDeclaration, JDocCommentable, JGenerifiable

public class JMethod
extends Object
implements JDeclaration, JAnnotatable, JDocCommentable

Java method.


Method Summary
 JMethod_throws(Class<? extends Throwable> exception)
           
 JMethod_throws(JClass exception)
          Add an exception to the list of exceptions that this method may throw.
 JAnnotationUseannotate(Class<? extends Annotation> clazz)
          Adds an annotation to this variable.
 JAnnotationUseannotate(JClass clazz)
          Adds an annotation to this variable.
<W extends JAnnotationWriter>
W
annotate2(Class<W> clazz)
          Adds an annotation to this program element and returns a type-safe writer to fill in the values of such annotations.
 Collection<JAnnotationUse>annotations()
          Read-only live view of all annotations on this JAnnotatable
 JBlockbody()
          Get the block that makes up body of this method
 voiddeclare(JFormatter f)
           
 voiddeclareDefaultValue(JExpression value)
          Specify the default value for this annotation member
 JTypeVargenerify(String name)
          Adds a new type variable to this declaration.
 JTypeVargenerify(String name, Class<?> bound)
          Adds a new type variable to this declaration with a bound.
 JTypeVargenerify(String name, JClass bound)
          Adds a new type variable to this declaration with a bound.
 JModsgetMods()
          Deprecated. use mods()
 booleanhasSignature(JType[] argTypes)
          Returns true if the method has the specified signature.
 booleanhasVarArgs()
          Check if there are any varargs declared for this method signature.
 JDocCommentjavadoc()
          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.
 JVarlistVarParam()
          Returns the variable parameter
 JTypelistVarParamType()
          Returns the varags parameter type.
 JModsmods()
           
 Stringname()
           
 voidname(String n)
          Changes the name of the method.
protected  JCodeModelowner()
           
 JVarparam(Class<?> type, String name)
           
 JVarparam(int mods, Class<?> type, String name)
           
 JVarparam(int mods, JType type, String name)
          Add the specified variable to the list of parameters for this method signature.
 JVarparam(JType type, String name)
           
 List<JVar>params()
          Returns the list of variable of this method.
 JTypetype()
          Returns the return type.
 voidtype(JType t)
          Overrides the return type.
 JTypeVar[]typeParams()
          Iterates all the type parameters of this class/interface.
 JVarvarParam(Class<?> type, String name)
           
 JVarvarParam(JType type, String name)
          Add the specified variable argument to the list of parameters for this method signature.
 
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(Class<? extends Throwable> exception)

params

public List<JVar> params()
Returns the list of variable of this method.

Returns:
List of parameters of this method. This list is not modifiable.

param

public JVar param(int mods,                  JType type,                  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,                  String name)

param

public JVar param(int mods,                  Class<?> type,                  String name)

param

public JVar param(Class<?> type,                  String name)

varParam

public JVar varParam(Class<?> type,                     String name)
See Also:
varParam(JType, String)

varParam

public JVar varParam(JType type,                     String name)
Add the specified variable argument to the list of parameters for this method signature.

Parameters:
type - Type of the parameter being added.
name - Name of the parameter being added
Returns:
the variable parameter
Throws:
IllegalStateException - If this method is called twice. varargs in J2SE 1.5 can appear only once in the method signature.

annotate

public JAnnotationUse annotate(JClass clazz)
Adds an annotation to this variable.

Specified by:
annotate in interface JAnnotatable
Parameters:
clazz - The annotation class to annotate the field with

annotate

public JAnnotationUse annotate(Class<? extends Annotation> clazz)
Adds an annotation to this variable.

Specified by:
annotate in interface JAnnotatable
Parameters:
clazz - The annotation class to annotate the field with

annotate2

public <W extends JAnnotationWriter> W annotate2(Class<W> clazz)
Description copied from interface: JAnnotatable
Adds an annotation to this program element and returns a type-safe writer to fill in the values of such annotations.

Specified by:
annotate2 in interface JAnnotatable

annotations

public Collection<JAnnotationUse> annotations()
Description copied from interface: JAnnotatable
Read-only live view of all annotations on this JAnnotatable

Specified by:
annotations in interface JAnnotatable
Returns:
Can be empty but never null.

hasVarArgs

public boolean hasVarArgs()
Check if there are any varargs declared for this method signature.


name

public String name()

name

public void name(String n)
Changes the name of the method.


type

public JType type()
Returns the return type.


type

public void type(JType t)
Overrides the return type.


listParamTypes

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

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

listVarParamType

public JType listVarParamType()
Returns the varags parameter type.

Returns:
If there's no vararg parameter type, null 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.

listVarParam

public JVar listVarParam()
Returns the variable parameter

Returns:
If there's no parameter, null 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

declareDefaultValue

public void declareDefaultValue(JExpression value)
Specify the default value for this annotation member

Parameters:
value - Default value for the annotation member

javadoc

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

Specified by:
javadoc in interface JDocCommentable
Returns:
JDocComment containing javadocs for this class

declare

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

mods

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

getMods

public JMods getMods()
Deprecated. use mods()


owner

protected JCodeModel owner()

generify

public JTypeVar generify(String name)
Description copied from interface: JGenerifiable
Adds a new type variable to this declaration.

Specified by:
generify in interface JGenerifiable

generify

public JTypeVar generify(String name,                         Class<?> bound)
Description copied from interface: JGenerifiable
Adds a new type variable to this declaration with a bound.

Specified by:
generify in interface JGenerifiable

generify

public JTypeVar generify(String name,                         JClass bound)
Description copied from interface: JGenerifiable
Adds a new type variable to this declaration with a bound.

Specified by:
generify in interface JGenerifiable

typeParams

public JTypeVar[] typeParams()
Description copied from interface: JGenerifiable
Iterates all the type parameters of this class/interface.

Specified by:
typeParams in interface JGenerifiable


Copyright © 2005-2011
Oracle. All Rights Reserved.


NOTHING
NOTHING
Add the Maven Dependecy to your project: maven dependecy for com.amazonaws : aws-java-sdk : 1.3.14