Top Description Constructors Methods
com.sun.codemodel

public abstract Class JType

extends Object
implements JGenerable, Comparable<JType>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable, com.sun.codemodel.JGenerable
Known Direct Subclasses
com.sun.codemodel.JClass, com.sun.codemodel.JPrimitiveType

A representation of a type in codeModel. A type is always either primitive (JPrimitiveType) or a reference type (JClass).

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public abstract JClass

Returns:

A JClass representing the array type whose element type is this type
array
()

Create an array type of this type.

public String

Returns:

Name like "Foo$Bar", "int", "java.lang.String", "java.io.File[]". Never null.
binaryName
()

Gets the binary name of the type.

public abstract JClass
boxify()

If this class is a primitive type, return the boxed class.

public int
compareTo(JType o)

Implements java.lang.Comparable.compareTo.

Compare two JTypes by FQCN, giving sorting precedence to types that belong to packages java and javax over all others.

public JType
elementType()

If this is an array, returns the component type of the array.

public JType
erasure()

Returns the erasure of this type.

public abstract String

Returns:

Strings like "int", "java.lang.String", "java.io.File[]". Never null.
fullName
()

Gets the full name of the type.

public boolean
isArray()

Tell whether or not this is an array type.

public boolean
isPrimitive()

Tell whether or not this is a built-in primitive type, such as int or void.

public final boolean
isReference()

Returns true if this is a referenced type.

public abstract String

Returns:

Names like "int", "void", "BigInteger".
name
()

Gets the name of this type.

public abstract JCodeModel
owner()

Gets the owner code model object.

public static JPrimitiveType
parse(JCodeModel codeModel, String typeName)

Obtains a reference to the primitive type object from a type name.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public abstract JType
unboxify()

If this class is a wrapper type for a primitive, return the primitive type.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Constructor Detail

JTypeback to summary
protected JType()

Method Detail

arrayback to summary
public abstract JClass array()

Create an array type of this type. This method is undefined for primitive void type, which doesn't have any corresponding array representation.

Returns:JClass

A JClass representing the array type whose element type is this type

binaryNameback to summary
public String binaryName()

Gets the binary name of the type. See http://java.sun.com/docs/books/jls/third_edition/html/binaryComp.html#44909

Returns:String

Name like "Foo$Bar", "int", "java.lang.String", "java.io.File[]". Never null.

boxifyback to summary
public abstract JClass boxify()

If this class is a primitive type, return the boxed class. Otherwise return this.

For example, for "int", this method returns "java.lang.Integer".

compareToback to summary
public int compareTo(JType o)

Implements java.lang.Comparable.compareTo.

Compare two JTypes by FQCN, giving sorting precedence to types that belong to packages java and javax over all others. This method is used to sort generated import statments in a conventional way for readability.

Annotations
@Override
elementTypeback to summary
public JType elementType()

If this is an array, returns the component type of the array. (T of T[])

erasureback to summary
public JType erasure()

Returns the erasure of this type.

fullNameback to summary
public abstract String fullName()

Gets the full name of the type. See http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html#25430 for the details.

Returns:String

Strings like "int", "java.lang.String", "java.io.File[]". Never null.

isArrayback to summary
public boolean isArray()

Tell whether or not this is an array type.

isPrimitiveback to summary
public boolean isPrimitive()

Tell whether or not this is a built-in primitive type, such as int or void.

isReferenceback to summary
public final boolean isReference()

Returns true if this is a referenced type.

nameback to summary
public abstract String name()

Gets the name of this type.

Returns:String

Names like "int", "void", "BigInteger".

ownerback to summary
public abstract JCodeModel owner()

Gets the owner code model object.

parseback to summary
public static JPrimitiveType parse(JCodeModel codeModel, String typeName)

Obtains a reference to the primitive type object from a type name.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
unboxifyback to summary
public abstract JType unboxify()

If this class is a wrapper type for a primitive, return the primitive type. Otherwise return this.

For example, for "java.lang.Integer", this method returns "int".