com.sun.codemodel
Class JCodeModel

java.lang.Object
  extended by com.sun.codemodel.JCodeModel

public final class JCodeModel
extends java.lang.Object

Root of the code DOM.


Field Summary
 JPrimitiveType BOOLEAN
           
 JPrimitiveType BYTE
           
 JPrimitiveType CHAR
           
 JPrimitiveType DOUBLE
           
 JPrimitiveType FLOAT
           
 JPrimitiveType INT
           
protected static boolean isCaseSensitiveFileSystem
          If the flag is true, we will consider two classes "Foo" and "foo" as a collision.
 JPrimitiveType LONG
           
 JNullType NULL
          Obtains a reference to the special "null" type.
 JPrimitiveType SHORT
           
 JPrimitiveType VOID
           
 
Constructor Summary
JCodeModel()
           
 
Method Summary
 JDefinedClass _class(java.lang.String fullyqualifiedName)
          Creates a new generated class.
 JDefinedClass _getClass(java.lang.String fullyQualifiedName)
          Gets a reference to the already created generated class.
 JPackage _package(java.lang.String name)
          Add a package to the list of packages to be generated
 void build(CodeWriter out)
          Generates Java source code.
 void build(java.io.File destDir)
          A convenience method for build(destDir,System.out).
 void build(java.io.File destDir, java.io.PrintStream status)
          Generates Java source code.
 JDefinedClass newAnonymousClass(JClass baseType)
          Creates a new anonymous class.
 java.util.Iterator packages()
          Returns an iterator that walks the packages defined using this code writer.
 JClass ref(java.lang.Class clazz)
          Obtains a reference to an existing class from its Class object.
 JClass ref(java.lang.String fullyQualifiedClassName)
          Obtains a reference to an existing class from its fully-qualified class name.
 JPackage rootPackage()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL

public final JNullType NULL
Obtains a reference to the special "null" type.


VOID

public final JPrimitiveType VOID

BOOLEAN

public final JPrimitiveType BOOLEAN

BYTE

public final JPrimitiveType BYTE

SHORT

public final JPrimitiveType SHORT

CHAR

public final JPrimitiveType CHAR

INT

public final JPrimitiveType INT

FLOAT

public final JPrimitiveType FLOAT

LONG

public final JPrimitiveType LONG

DOUBLE

public final JPrimitiveType DOUBLE

isCaseSensitiveFileSystem

protected static final boolean isCaseSensitiveFileSystem
If the flag is true, we will consider two classes "Foo" and "foo" as a collision.

Constructor Detail

JCodeModel

public JCodeModel()
Method Detail

_package

public JPackage _package(java.lang.String name)
Add a package to the list of packages to be generated

Parameters:
name - Name of the package. Use "" to indicate the root package.
Returns:
Newly generated package

rootPackage

public final JPackage rootPackage()

packages

public java.util.Iterator packages()
Returns an iterator that walks the packages defined using this code writer.


_class

public JDefinedClass _class(java.lang.String fullyqualifiedName)
                     throws JClassAlreadyExistsException
Creates a new generated class.

Throws:
JClassAlreadyExistsException - When the specified class/interface was already created.

_getClass

public JDefinedClass _getClass(java.lang.String fullyQualifiedName)
Gets a reference to the already created generated class.

Returns:
null If the class is not yet created.

newAnonymousClass

public JDefinedClass newAnonymousClass(JClass baseType)
Creates a new anonymous class.


build

public void build(java.io.File destDir,
                  java.io.PrintStream status)
           throws java.io.IOException
Generates Java source code. A convenience method that calls build(CodeWriter).

Parameters:
destDir - source files are generated into this directory.
status - if non-null, progress indication will be sent to this stream.
Throws:
java.io.IOException

build

public void build(java.io.File destDir)
           throws java.io.IOException
A convenience method for build(destDir,System.out).

Throws:
java.io.IOException

build

public void build(CodeWriter out)
           throws java.io.IOException
Generates Java source code.

Throws:
java.io.IOException

ref

public JClass ref(java.lang.Class clazz)
Obtains a reference to an existing class from its Class object.


ref

public JClass ref(java.lang.String fullyQualifiedClassName)
           throws java.lang.ClassNotFoundException
Obtains a reference to an existing class from its fully-qualified class name.

Throws:
java.lang.ClassNotFoundException - If the specified class is not available in the current class path.