com.sun.codemodel
Class JDefinedClass

java.lang.Object  extended by com.sun.codemodel.JType      extended by com.sun.codemodel.JClass          extended by com.sun.codemodel.JDefinedClass
All Implemented Interfaces:
JAnnotatable, JClassContainer, JDeclaration, JDocCommentable, JGenerable, JGenerifiable, Comparable<JType>

public class JDefinedClass
extends JClass
implements JDeclaration, JClassContainer, JGenerifiable, JAnnotatable, JDocCommentable

A generated Java class/interface/enum/....

This class models a declaration, and since a declaration can be always used as a reference, it inherits JClass.

Where to go from here?

You'd want to generate fields and methods on a class. See method(int, JType, String) and field(int, JType, String).


Field Summary
 Objectmetadata
          Client-app spcific metadata associated with this user-created class.
 
Fields inherited from class com.sun.codemodel.JClass
EMPTY_ARRAY
 
Method Summary
 JDefinedClass_annotationTypeDeclaration(String name)
          Add an annotationType Declaration to this package
 JDefinedClass_class(int mods, String name)
          Add a new nested class to this class.
 JDefinedClass_class(int mods, String name, boolean isInterface)
          Deprecated.  
 JDefinedClass_class(int mods, String name, ClassType classTypeVal)
          Creates a new class/enum/interface/annotation.
 JDefinedClass_class(String name)
          Add a new public nested class to this class.
 JDefinedClass_enum(int mods, String name)
          Add a public enum to this package
 JDefinedClass_enum(String name)
          Add a public enum to this package
 JClass_extends()
          Returns the class extended by this class.
 JDefinedClass_extends(Class<?> superClass)
           
 JDefinedClass_extends(JClass superClass)
          This class extends the specifed class.
 Iterator<JClass>_implements()
          Returns an iterator that walks the nested classes defined in this class.
 JDefinedClass_implements(Class<?> iface)
           
 JDefinedClass_implements(JClass iface)
          This class implements the specifed interface.
 JDefinedClass_interface(int mods, String name)
          Add an interface to this package.
 JDefinedClass_interface(String name)
          Adds a public interface to this package.
 JPackage_package()
          Gets the package to which this class belongs.
 JAnnotationUseannotate(Class<? extends Annotation> clazz)
          Adding ability to annotate a class
 JAnnotationUseannotate(JClass clazz)
          Adding ability to annotate a class
<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()
          JAnnotatable.annotations()
 StringbinaryName()
          Gets the binary name of the type.
 Iterator<JDefinedClass>classes()
          Returns an iterator that walks the nested classes defined in this class.
 JMethodconstructor(int mods)
          Adds a constructor to this class.
 Iterator<JMethod>constructors()
          Returns an iterator that walks the constructors defined in this class.
 voiddeclare(JFormatter f)
           
protected  voiddeclareBody(JFormatter f)
          prints the body of a class.
 voiddirect(String string)
          Places the given string directly inside the generated class.
 JEnumConstantenumConstant(String name)
          If the named enum already exists, the reference to it is returned.
 JFieldVarfield(int mods, Class<?> type, String name)
           
 JFieldVarfield(int mods, Class<?> type, String name, JExpression init)
           
 JFieldVarfield(int mods, JType type, String name)
          Adds a field to the list of field members of this JDefinedClass.
 JFieldVarfield(int mods, JType type, String name, JExpression init)
          Adds a field to the list of field members of this JDefinedClass.
 Map<String,JFieldVar>fields()
          Returns all the fields declred in this class.
 StringfullName()
          Gets the fully qualified name of this class.
 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.
 ClassTypegetClassType()
           
 JMethodgetConstructor(JType[] argTypes)
          Looks for a method that has the specified method signature and return it.
 JMethodgetMethod(String name, JType[] argTypes)
          Looks for a method that has the specified method signature and return it.
 JPackagegetPackage()
          Gets the nearest package parent.
 voidhide()
          Mark this file as hidden, so that this file won't be generated.
 JBlockinit()
          Creates, if necessary, and returns the static initializer for this class.
 booleanisAbstract()
          Checks if this class is an abstract class.
 booleanisAnnotationTypeDeclaration()
          This method indicates if the interface is an annotationTypeDeclaration
 booleanisAnonymous()
          Returns true if this is an anonymous class.
 booleanisClass()
          Returns true if the container is a class.
 booleanisHidden()
           
 booleanisInterface()
          Checks if this object represents an interface.
 booleanisPackage()
          Returns true if the container is a package.
 JDocCommentjavadoc()
          Creates, if necessary, and returns the class javadoc for this JDefinedClass
 JClass[]listClasses()
          Returns all the nested classes defined in this class.
 JMethodmethod(int mods, Class<?> type, String name)
           
 JMethodmethod(int mods, JType type, String name)
          Add a method to the list of method members of this JDefinedClass instance.
 Collection<JMethod>methods()
          Returns the set of methods defined in this class.
 JModsmods()
           
 Stringname()
          JClass name accessor.
 JClassouter()
          Returns the class in which this class is nested, or null if this is a top-level class.
 JClassContainerparentContainer()
          Parent JClassContainer.
 voidremoveField(JFieldVar field)
          Removes a JFieldVar from this class.
protected  JClasssubstituteParams(JTypeVar[] variables, List<JClass> bindings)
          Substitutes the type variables with their actual arguments.
 JTypeVar[]typeParams()
          Iterates all the type parameters of this class/interface.
 
Methods inherited from class com.sun.codemodel.JClass
array, boxify, dotclass, erasure, generate, getBaseClass, getBaseClass, getPrimitiveType, getTypeParameters, isAssignableFrom, isParameterized, narrow, narrow, narrow, narrow, narrow, narrow, owner, staticInvoke, staticInvoke, staticRef, staticRef, toString, unboxify, wildcard
 
Methods inherited from class com.sun.codemodel.JType
compareTo, elementType, isArray, isPrimitive, isReference, parse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.sun.codemodel.JClassContainer
owner
 

Field Detail

metadata

public Object metadata
Client-app spcific metadata associated with this user-created class.

Method Detail

isAnonymous

public final boolean isAnonymous()
Returns true if this is an anonymous class.


_extends

public JDefinedClass _extends(JClass superClass)
This class extends the specifed class.

Parameters:
superClass - Superclass for this class
Returns:
This class

_extends

public JDefinedClass _extends(Class<?> superClass)

_extends

public JClass _extends()
Returns the class extended by this class.

Specified by:
_extends in class JClass
Returns:
Returns the JClass representing the superclass of the entity (class or interface) represented by this JClass. Even if no super class is given explicitly or this JClass is not a class, this method still returns JClass for Object. If this JClass represents Object, return null.

_implements

public JDefinedClass _implements(JClass iface)
This class implements the specifed interface.

Parameters:
iface - Interface that this class implements
Returns:
This class

_implements

public JDefinedClass _implements(Class<?> iface)

_implements

public Iterator<JClass> _implements()
Returns an iterator that walks the nested classes defined in this class.

Specified by:
_implements in class JClass
Returns:
A non-null valid iterator that iterates all JClass objects that represents those interfaces implemented by this object.

name

public String name()
JClass name accessor.

For example, for java.util.List, this method returns "List""

Specified by:
name in class JClass
Returns:
Name of this class

enumConstant

public JEnumConstant enumConstant(String name)
If the named enum already exists, the reference to it is returned. Otherwise this method generates a new enum reference with the given name and returns it.

Parameters:
name - The name of the constant.
Returns:
The generated type-safe enum constant.

fullName

public String fullName()
Gets the fully qualified name of this class.

Specified by:
fullName in class JType
Returns:
Strings like "int", "java.lang.String", "java.io.File[]". Never null.

binaryName

public String binaryName()
Description copied from class: JType
Gets the binary name of the type. See http://java.sun.com/docs/books/jls/third_edition/html/binaryComp.html#44909

Overrides:
binaryName in class JType
Returns:
Name like "Foo$Bar", "int", "java.lang.String", "java.io.File[]". Never null.

isInterface

public boolean isInterface()
Description copied from class: JClass
Checks if this object represents an interface.

Specified by:
isInterface in class JClass

isAbstract

public boolean isAbstract()
Description copied from class: JClass
Checks if this class is an abstract class.

Specified by:
isAbstract in class JClass

field

public JFieldVar field(int mods,                       JType type,                       String name)
Adds a field to the list of field members of this JDefinedClass.

Parameters:
mods - Modifiers for this field
type - JType of this field
name - Name of this field
Returns:
Newly generated field

field

public JFieldVar field(int mods,                       Class<?> type,                       String name)

field

public JFieldVar field(int mods,                       JType type,                       String name,                       JExpression init)
Adds a field to the list of field members of this JDefinedClass.

Parameters:
mods - Modifiers for this field.
type - JType of this field.
name - Name of this field.
init - Initial value of this field.
Returns:
Newly generated field

isAnnotationTypeDeclaration

public boolean isAnnotationTypeDeclaration()
This method indicates if the interface is an annotationTypeDeclaration


_annotationTypeDeclaration

public JDefinedClass _annotationTypeDeclaration(String name)                                         throws JClassAlreadyExistsException
Add an annotationType Declaration to this package

Specified by:
_annotationTypeDeclaration in interface JClassContainer
Parameters:
name - Name of the annotation Type declaration to be added to this package
Returns:
newly created Annotation Type Declaration
Throws:
JClassAlreadyExistsException - When the specified class/interface was already created.

_enum

public JDefinedClass _enum(String name)                    throws JClassAlreadyExistsException
Add a public enum to this package

Specified by:
_enum in interface JClassContainer
Parameters:
name - Name of the enum to be added to this package
Returns:
newly created Enum
Throws:
JClassAlreadyExistsException - When the specified class/interface was already created.

_enum

public JDefinedClass _enum(int mods,                           String name)                    throws JClassAlreadyExistsException
Add a public enum to this package

Parameters:
name - Name of the enum to be added to this package
mods - Modifiers for this enum declaration
Returns:
newly created Enum
Throws:
JClassAlreadyExistsException - When the specified class/interface was already created.

getClassType

public ClassType getClassType()

field

public JFieldVar field(int mods,                       Class<?> type,                       String name,                       JExpression init)

fields

public Map<String,JFieldVar> fields()
Returns all the fields declred in this class. The returned Map is a read-only live view.

Returns:
always non-null.

removeField

public void removeField(JFieldVar field)
Removes a JFieldVar from this class.

Throws:
IllegalArgumentException - if the given field is not a field on this class.

init

public JBlock init()
Creates, if necessary, and returns the static initializer for this class.

Returns:
JBlock containing initialization statements for this class

constructor

public JMethod constructor(int mods)
Adds a constructor to this class.

Parameters:
mods - Modifiers for this constructor

constructors

public Iterator<JMethod> constructors()
Returns an iterator that walks the constructors defined in this class.


getConstructor

public JMethod getConstructor(JType[] argTypes)
Looks for a method that has the specified method signature and return it.

Returns:
null if not found.

method

public JMethod method(int mods,                      JType type,                      String name)
Add a method to the list of method members of this JDefinedClass instance.

Parameters:
mods - Modifiers for this method
type - Return type for this method
name - Name of the method
Returns:
Newly generated JMethod

method

public JMethod method(int mods,                      Class<?> type,                      String name)

methods

public Collection<JMethod> methods()
Returns the set of methods defined in this class.


getMethod

public JMethod getMethod(String name,                         JType[] argTypes)
Looks for a method that has the specified method signature and return it.

Returns:
null if not found.

isClass

public boolean isClass()
Description copied from interface: JClassContainer
Returns true if the container is a class.

Specified by:
isClass in interface JClassContainer

isPackage

public boolean isPackage()
Description copied from interface: JClassContainer
Returns true if the container is a package.

Specified by:
isPackage in interface JClassContainer

getPackage

public JPackage getPackage()
Description copied from interface: JClassContainer
Gets the nearest package parent.

If this.isPackage(), then return this.

Specified by:
getPackage in interface JClassContainer

_class

public JDefinedClass _class(int mods,                            String name)                     throws JClassAlreadyExistsException
Add a new nested class to this class.

Specified by:
_class in interface JClassContainer
Parameters:
mods - Modifiers for this class declaration
name - Name of class to be added to this package
Returns:
Newly generated class
Throws:
JClassAlreadyExistsException - When the specified class/interface was already created.

_class

public JDefinedClass _class(int mods,                            String name,                            boolean isInterface)                     throws JClassAlreadyExistsException
Deprecated. 

Create a new class or a new interface.

Specified by:
_class in interface JClassContainer
Throws:
JClassAlreadyExistsException

_class

public JDefinedClass _class(int mods,                            String name,                            ClassType classTypeVal)                     throws JClassAlreadyExistsException
Description copied from interface: JClassContainer
Creates a new class/enum/interface/annotation.

Specified by:
_class in interface JClassContainer
Throws:
JClassAlreadyExistsException

_class

public JDefinedClass _class(String name)                     throws JClassAlreadyExistsException
Add a new public nested class to this class.

Specified by:
_class in interface JClassContainer
Throws:
JClassAlreadyExistsException - When the specified class/interface was already created.

_interface

public JDefinedClass _interface(int mods,                                String name)                         throws JClassAlreadyExistsException
Add an interface to this package.

Specified by:
_interface in interface JClassContainer
Parameters:
mods - Modifiers for this interface declaration
name - Name of interface to be added to this package
Returns:
Newly generated interface
Throws:
JClassAlreadyExistsException - When the specified class/interface was already created.

_interface

public JDefinedClass _interface(String name)                         throws JClassAlreadyExistsException
Adds a public interface to this package.

Specified by:
_interface in interface JClassContainer
Throws:
JClassAlreadyExistsException - When the specified class/interface was already created.

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

hide

public void hide()
Mark this file as hidden, so that this file won't be generated.

This feature could be used to generate code that refers to class X, without actually generating X.java.


isHidden

public boolean isHidden()

classes

public final Iterator<JDefinedClass> classes()
Returns an iterator that walks the nested classes defined in this class.

Specified by:
classes in interface JClassContainer

listClasses

public final JClass[] listClasses()
Returns all the nested classes defined in this class.


outer

public JClass outer()
Description copied from class: JClass
Returns the class in which this class is nested, or null if this is a top-level class.

Overrides:
outer in class JClass

declare

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

declareBody

protected void declareBody(JFormatter f)
prints the body of a class.


direct

public void direct(String string)
Places the given string directly inside the generated class. This method can be used to add methods/fields that are not generated by CodeModel. This method should be used only as the last resort.


_package

public final JPackage _package()
Description copied from class: JClass
Gets the package to which this class belongs. TODO: shall we move move this down?

Specified by:
_package in class JClass

parentContainer

public final JClassContainer parentContainer()
Description copied from interface: JClassContainer
Parent JClassContainer. If this is a package, this method returns a parent package, or null if this package is the root package. If this is an outer-most class, this method returns a package to which it belongs. If this is an inner class, this method returns the outer class.

Specified by:
parentContainer in interface JClassContainer

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 class: JClass
Iterates all the type parameters of this class/interface.

For example, if this JClass represents Set<T>, this method returns an array that contains single JTypeVar for 'T'.

Specified by:
typeParams in interface JGenerifiable
Overrides:
typeParams in class JClass

substituteParams

protected JClass substituteParams(JTypeVar[] variables,                                  List<JClass> bindings)
Description copied from class: JClass
Substitutes the type variables with their actual arguments.

For example, when this class is Map<String,Map<V>>, (where V then doing substituteParams( V, Integer ) returns a JClass for Map<String,Map<Integer>>.

This method needs to work recursively.

Specified by:
substituteParams in class JClass

annotate

public JAnnotationUse annotate(Class<? extends Annotation> clazz)
Adding ability to annotate a class

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

annotate

public JAnnotationUse annotate(JClass clazz)
Adding ability to annotate a class

Specified by:
annotate in interface JAnnotatable
Parameters:
clazz - The annotation class to annotate the class 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()
JAnnotatable.annotations()

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

mods

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


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