com.sun.codemodel
Class JPackage

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

public final class JPackage
extends Object
implements JDeclaration, JGenerable, JClassContainer, JAnnotatable, Comparable<JPackage>, JDocCommentable

A Java package.


Method Summary
 JDefinedClass_annotationTypeDeclaration(String name)
          Add an annotationType Declaration to this package
 JDefinedClass_class(int mods, String name)
          Add a class to this package.
 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)
          Adds a public class to this package.
 JDefinedClass_enum(String name)
          Add a public enum to this package
 JDefinedClass_getClass(String name)
          Gets a reference to the already created JDefinedClass.
 JDefinedClass_interface(int mods, String name)
          Add an interface to this package.
 JDefinedClass_interface(String name)
          Adds a public interface to this package.
 JResourceFileaddResourceFile(JResourceFile rsrc)
          Adds a new resource file to this package.
 JAnnotationUseannotate(Class<? extends Annotation> clazz)
          Adds an annotation to this program element.
 JAnnotationUseannotate(JClass clazz)
          Adds an annotation to this program element.
<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
 Iterator<JDefinedClass>classes()
          Returns an iterator that walks the top-level classes defined in this package.
 intcompareTo(JPackage that)
          Order is based on the lexicological order of the package name.
 voiddeclare(JFormatter f)
           
 voidgenerate(JFormatter f)
           
 JPackagegetPackage()
          Gets the nearest package parent.
 booleanhasResourceFile(String name)
          Checks if a resource of the given name exists.
 booleanisClass()
          Returns true if the container is a class.
 booleanisDefined(String classLocalName)
          Checks if a given name is already defined as a class/interface
 booleanisPackage()
          Returns true if the container is a package.
 booleanisUnnamed()
          Checks if this package is the root, unnamed package.
 JDocCommentjavadoc()
          Creates, if necessary, and returns the package javadoc for this JDefinedClass.
 Stringname()
          Get the name of this package
 JCodeModelowner()
          Return the code model root object being used to create this package.
 JPackageparent()
          Gets the parent package, or null if this class is the root package.
 JClassContainerparentContainer()
          Parent JClassContainer.
 Iterator<JResourceFile>propertyFiles()
          Iterates all resource files in this package.
 JClassref(String name)
          Reference a class within this package.
 voidremove(JClass c)
          Removes a class from this package.
 JPackagesubPackage(String pkg)
          Gets a reference to a sub package of this package.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parentContainer

public 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

parent

public JPackage parent()
Gets the parent package, or null if this class is the root package.


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 class to this package.

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
Adds a public class to this package.

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

_getClass

public JDefinedClass _getClass(String name)
Gets a reference to the already created JDefinedClass.

Returns:
null If the class is not yet created.

compareTo

public int compareTo(JPackage that)
Order is based on the lexicological order of the package name.

Specified by:
compareTo in interface Comparable<JPackage>

_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.

_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.

addResourceFile

public JResourceFile addResourceFile(JResourceFile rsrc)
Adds a new resource file to this package.


hasResourceFile

public boolean hasResourceFile(String name)
Checks if a resource of the given name exists.


propertyFiles

public Iterator<JResourceFile> propertyFiles()
Iterates all resource files in this package.


javadoc

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

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

remove

public void remove(JClass c)
Removes a class from this package.


ref

public JClass ref(String name)           throws ClassNotFoundException
Reference a class within this package.

Throws:
ClassNotFoundException

subPackage

public JPackage subPackage(String pkg)
Gets a reference to a sub package of this package.


classes

public Iterator<JDefinedClass> classes()
Returns an iterator that walks the top-level classes defined in this package.

Specified by:
classes in interface JClassContainer

isDefined

public boolean isDefined(String classLocalName)
Checks if a given name is already defined as a class/interface


isUnnamed

public final boolean isUnnamed()
Checks if this package is the root, unnamed package.


name

public String name()
Get the name of this package

Returns:
The name of this package, or the empty string if this is the null package. For example, this method returns strings like "java.lang"

owner

public final JCodeModel owner()
Return the code model root object being used to create this package.

Specified by:
owner in interface JClassContainer

annotate

public JAnnotationUse annotate(JClass clazz)
Description copied from interface: JAnnotatable
Adds an annotation to this program element.

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

annotate

public JAnnotationUse annotate(Class<? extends Annotation> clazz)
Description copied from interface: JAnnotatable
Adds an annotation to this program element.

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

declare

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

generate

public void generate(JFormatter f)
Specified by:
generate in interface JGenerable


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