Top Description Fields Constructors Methods
com.sun.codemodel

public final Class JPrimitiveType

extends JType
Class Inheritance

Java built-in primitive types. Instances of this class can be obtained as constants of JCodeModel, such as JCodeModel#BOOLEAN.

Field Summary

Modifier and TypeField and Description
private JClass
private final JCodeModel
private final String
private final JClass
wrapperClass

Corresponding wrapper class.

Constructor Summary

AccessConstructor and Description
pack-priv
JPrimitiveType(JCodeModel owner, String typeName, Class<?> wrapper)

Method Summary

Modifier and TypeMethod and Description
public JClass
array()

Implements abstract com.sun.codemodel.JType.array.

Create an array type of this type.

public JClass
boxify()

Implements abstract com.sun.codemodel.JType.boxify.

Obtains the wrapper class for this primitive type.

public String
fullName()

Implements abstract com.sun.codemodel.JType.fullName.

Gets the full name of the type.

public void
public JClass
getWrapperClass()
Deprecated Use boxify().

public boolean
isPrimitive()

Overrides com.sun.codemodel.JType.isPrimitive.

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

public String
name()

Implements abstract com.sun.codemodel.JType.name.

Gets the name of this type.

public JCodeModel
owner()

Implements abstract com.sun.codemodel.JType.owner.

Gets the owner code model object.

public JType
unboxify()

Implements abstract com.sun.codemodel.JType.unboxify.

Deprecated

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

public JExpression
unwrap(JExpression exp)

Do the opposite of the wrap method.

public JExpression
wrap(JExpression exp)

Wraps an expression of this type to the corresponding wrapper class.

Inherited from com.sun.codemodel.JType:
binaryNamecompareToelementTypeerasureisArrayisReferenceparsetoString

Field Detail

arrayClassback to summary
private JClass arrayClass
ownerback to summary
private final JCodeModel owner
typeNameback to summary
private final String typeName
wrapperClassback to summary
private final JClass wrapperClass

Corresponding wrapper class. For example, this would be "java.lang.Short" for short.

Constructor Detail

JPrimitiveTypeback to summary
pack-priv JPrimitiveType(JCodeModel owner, String typeName, Class<?> wrapper)

Method Detail

arrayback to summary
public JClass array()

Implements abstract com.sun.codemodel.JType.array.

Doc from com.sun.codemodel.JType.array.

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

Annotations
@Override
boxifyback to summary
public JClass boxify()

Implements abstract com.sun.codemodel.JType.boxify.

Obtains the wrapper class for this primitive type. For example, this method returns a reference to java.lang.Integer if this object represents int.

Annotations
@Override
fullNameback to summary
public String fullName()

Implements abstract com.sun.codemodel.JType.fullName.

Doc from com.sun.codemodel.JType.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.

Annotations
@Override
generateback to summary
public void generate(JFormatter f)

Implements com.sun.codemodel.JGenerable.generate.

Annotations
@Override
getWrapperClassback to summary
public JClass getWrapperClass()

Deprecated

Use boxify().

Annotations
@Deprecated
isPrimitiveback to summary
public boolean isPrimitive()

Overrides com.sun.codemodel.JType.isPrimitive.

Doc from com.sun.codemodel.JType.isPrimitive.

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

Annotations
@Override
nameback to summary
public String name()

Implements abstract com.sun.codemodel.JType.name.

Doc from com.sun.codemodel.JType.name.

Gets the name of this type.

Annotations
@Override
ownerback to summary
public JCodeModel owner()

Implements abstract com.sun.codemodel.JType.owner.

Doc from com.sun.codemodel.JType.owner.

Gets the owner code model object.

Annotations
@Override
unboxifyback to summary
public JType unboxify()

Implements abstract com.sun.codemodel.JType.unboxify.

Doc from com.sun.codemodel.JType.unboxify.

Deprecated

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

Annotations
@Deprecated
@Override
unwrapback to summary
public JExpression unwrap(JExpression exp)

Do the opposite of the wrap method.

Revisit

it's not clear how this method works for VOID.

wrapback to summary
public JExpression wrap(JExpression exp)

Wraps an expression of this type to the corresponding wrapper class. For example, if this class represents "float", this method will return the expression new Float(x) for the paramter x.

Revisit

it's not clear how this method works for VOID.