com.sun.codemodel
Class JClass

java.lang.Object  extended by com.sun.codemodel.JType      extended by com.sun.codemodel.JClass
All Implemented Interfaces:
JGenerable, Comparable<JType>
Direct Known Subclasses:
JDefinedClass, JNullType, JTypeVar

public abstract class JClass
extends JType

Represents a Java reference type, such as a class, an interface, an enum, an array type, a parameterized type.

To be exact, this object represents an "use" of a reference type, not necessarily a declaration of it, which is modeled as JDefinedClass.


Field Summary
protected static JTypeVar[]EMPTY_ARRAY
          Sometimes useful reusable empty array.
 
Constructor Summary
protected JClass(JCodeModel _owner)
           
 
Method Summary
abstract  JClass_extends()
          Gets the super class of this class.
abstract  Iterator<JClass>_implements()
          Iterates all super interfaces directly implemented by this class/interface.
abstract  JPackage_package()
          Gets the package to which this class belongs.
 JClassarray()
          Create an array type of this type.
 JClassboxify()
          Deprecated. calling this method from JClass would be meaningless, since it's always guaranteed to return this.
 JExpressiondotclass()
           
 JClasserasure()
          Returns the erasure of this type.
 voidgenerate(JFormatter f)
           
 JClassgetBaseClass(Class<?> baseType)
           
 JClassgetBaseClass(JClass baseType)
          Gets the parameterization of the given base type.
 JPrimitiveTypegetPrimitiveType()
          If this class represents one of the wrapper classes defined in the java.lang package, return the corresponding primitive type.
 List<JClass>getTypeParameters()
          If this class is parameterized, return the type parameter of the given index.
abstract  booleanisAbstract()
          Checks if this class is an abstract class.
 booleanisAssignableFrom(JClass derived)
          Checks the relationship between two classes.
abstract  booleanisInterface()
          Checks if this object represents an interface.
 booleanisParameterized()
          Returns true if this class is a parameterized class.
abstract  Stringname()
          Gets the name of this class.
 JClassnarrow(Class<?>... clazz)
           
 JClassnarrow(Class<?> clazz)
          "Narrows" a generic class to a concrete class by specifying a type argument.
 JClassnarrow(JClass... clazz)
           
 JClassnarrow(JClass clazz)
          "Narrows" a generic class to a concrete class by specifying a type argument.
 JClassnarrow(JType type)
           
 JClassnarrow(List<? extends JClass> clazz)
           
 JClassouter()
          Returns the class in which this class is nested, or null if this is a top-level class.
 JCodeModelowner()
          Gets the JCodeModel object to which this object belongs.
 JInvocationstaticInvoke(JMethod method)
          Generates a static method invocation.
 JInvocationstaticInvoke(String method)
          Generates a static method invocation.
 JFieldRefstaticRef(JVar field)
          Static field reference.
 JFieldRefstaticRef(String field)
          Static field reference.
protected abstract  JClasssubstituteParams(JTypeVar[] variables, List<JClass> bindings)
          Substitutes the type variables with their actual arguments.
 StringtoString()
           
 JTypeVar[]typeParams()
          Iterates all the type parameters of this class/interface.
 JTypeunboxify()
          If this class is a wrapper type for a primitive, return the primitive type.
 JClasswildcard()
          Create "? extends T" from T.
 
Methods inherited from class com.sun.codemodel.JType
binaryName, compareTo, elementType, fullName, isArray, isPrimitive, isReference, parse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_ARRAY

protected static final JTypeVar[] EMPTY_ARRAY
Sometimes useful reusable empty array.

Constructor Detail

JClass

protected JClass(JCodeModel _owner)
Method Detail

name

public abstract String name()
Gets the name of this class.

Specified by:
name in class JType
Returns:
name of this class, without any qualification. For example, this method returns "String" for java.lang.String.

_package

public abstract JPackage _package()
Gets the package to which this class belongs. TODO: shall we move move this down?


outer

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


owner

public final JCodeModel owner()
Gets the JCodeModel object to which this object belongs.

Specified by:
owner in class JType

_extends

public abstract JClass _extends()
Gets the super class of this class.

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 abstract Iterator<JClass> _implements()
Iterates all super interfaces directly implemented by this class/interface.

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

typeParams

public JTypeVar[] typeParams()
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'.


isInterface

public abstract boolean isInterface()
Checks if this object represents an interface.


isAbstract

public abstract boolean isAbstract()
Checks if this class is an abstract class.


getPrimitiveType

public JPrimitiveType getPrimitiveType()
If this class represents one of the wrapper classes defined in the java.lang package, return the corresponding primitive type. Otherwise null.


boxify

public JClass boxify()
Deprecated. calling this method from JClass would be meaningless, since it's always guaranteed to return this.

Description copied from class: JType
If this class is a primitive type, return the boxed class. Otherwise return this.

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

Specified by:
boxify in class JType

unboxify

public JType unboxify()
Description copied from class: JType
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".

Specified by:
unboxify in class JType

erasure

public JClass erasure()
Description copied from class: JType
Returns the erasure of this type.

Overrides:
erasure in class JType

isAssignableFrom

public final boolean isAssignableFrom(JClass derived)
Checks the relationship between two classes.

This method works in the same way as Class.isAssignableFrom(Class) works. For example, baseClass.isAssignableFrom(derivedClass)==true.


getBaseClass

public final JClass getBaseClass(JClass baseType)
Gets the parameterization of the given base type.

For example, given the following

 interface Foo&lt;T&gt; extends List&lt;List&lt;T&gt;&gt; {} interface Bar extends Foo&lt;String&gt; {} 
This method works like this:
 getBaseClass( Bar, List ) = List&lt;List&lt;String&gt; getBaseClass( Bar, Foo  ) = Foo&lt;String&gt; getBaseClass( Foo&lt;? extends Number&gt;, Collection ) = Collection&lt;List&lt;? extends Number&gt;&gt; getBaseClass( ArrayList&lt;? extends BigInteger&gt;, List ) = List&lt;? extends BigInteger&gt; 

Parameters:
baseType - The class whose parameterization we are interested in.
Returns:
The use of baseType in this type. or null if the type is not assignable to the base type.

getBaseClass

public final JClass getBaseClass(Class<?> baseType)

array

public JClass array()
Description copied from class: JType
Create an array type of this type. This method is undefined for primitive void type, which doesn't have any corresponding array representation.

Specified by:
array in class JType
Returns:
A JClass representing the array type whose element type is this type

narrow

public JClass narrow(Class<?> clazz)
"Narrows" a generic class to a concrete class by specifying a type argument.

.narrow(X) builds Set<X> from Set.


narrow

public JClass narrow(Class<?>... clazz)

narrow

public JClass narrow(JClass clazz)
"Narrows" a generic class to a concrete class by specifying a type argument.

.narrow(X) builds Set<X> from Set.


narrow

public JClass narrow(JType type)

narrow

public JClass narrow(JClass... clazz)

narrow

public JClass narrow(List<? extends JClass> clazz)

getTypeParameters

public List<JClass> getTypeParameters()
If this class is parameterized, return the type parameter of the given index.


isParameterized

public final boolean isParameterized()
Returns true if this class is a parameterized class.


wildcard

public final JClass wildcard()
Create "? extends T" from T.

Returns:
never null

substituteParams

protected abstract JClass substituteParams(JTypeVar[] variables,                                           List<JClass> bindings)
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.


toString

public String toString()
Overrides:
toString in class JType

dotclass

public final JExpression dotclass()

staticInvoke

public final JInvocation staticInvoke(JMethod method)
Generates a static method invocation.


staticInvoke

public final JInvocation staticInvoke(String method)
Generates a static method invocation.


staticRef

public final JFieldRef staticRef(String field)
Static field reference.


staticRef

public final JFieldRef staticRef(JVar field)
Static field reference.


generate

public void generate(JFormatter f)


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