org.jboss.reflect.plugins
Class ClassInfoImpl

java.lang.Object
  extended by org.jboss.util.JBossObject
      extended by org.jboss.reflect.plugins.AbstractAnnotatedInfo
          extended by org.jboss.reflect.plugins.InheritableAnnotationHolder
              extended by org.jboss.reflect.plugins.ClassInfoImpl
All Implemented Interfaces:
Serializable, Cloneable, AnnotatedInfo, ClassInfo, ModifierInfo, TypeInfo, org.jboss.util.JBossInterface
Direct Known Subclasses:
ArrayInfoImpl, EnumInfoImpl, InterfaceInfoImpl, ReflectClassInfoImpl

public class ClassInfoImpl
extends InheritableAnnotationHolder
implements ClassInfo

Class info TODO JBMICROCONT-118 fix the introspection assumption

Author:
Bill Burke, Adrian Brock
See Also:
Serialized Form

Field Summary
protected  ClassInfoHelper classInfoHelper
          The class info helper
protected  ConstructorInfo[] constructors
          The constructor info
protected  HashMap<String,FieldInfo> fieldMap
          Field map Map
protected  FieldInfo[] fields
          The fields
protected  InterfaceInfo[] genericInterfaces
          The generic interfaces
protected  ClassInfo genericSuperclass
          The generic super class
protected  InterfaceInfo[] interfaces
          The interfaces
protected  MethodInfo[] methods
          The methods
protected  int modifiers
          The class modifiers
protected  String name
          The class name
protected  PackageInfo packageInfo
          The package info
protected  ClassInfo superclass
          The super class
protected  TypeInfoFactory typeInfoFactory
          The type info factory
static ClassInfo UNKNOWN_CLASS
          Marker for generation
static ClassInfo[] UNKNOWN_CLASSES
          Marker for generation
static ConstructorInfo[] UNKNOWN_CONSTRUCTORS
          Marker for generation
static FieldInfo[] UNKNOWN_FIELDS
          Marker for generation
static InterfaceInfo[] UNKNOWN_INTERFACES
          Marker for generation
static MethodInfo[] UNKNOWN_METHODS
          Marker for generation
static TypeInfo UNKNOWN_TYPE
          Marker for generation
static TypeInfo[] UNKNOWN_TYPES
          Marker for generation
 
Fields inherited from class org.jboss.reflect.plugins.InheritableAnnotationHolder
allAnnotations, allAnnotationsArray, annotatedElement, annotationHelper, declaredAnnotations, declaredAnnotationsArray
 
Fields inherited from class org.jboss.util.JBossObject
hashCode, log, toString
 
Fields inherited from interface org.jboss.reflect.spi.ModifierInfo
ABSTRACT, CONSTANT, FINAL, PACKAGE, PACKAGE_ABSTRACT, PACKAGE_CONSTANT, PACKAGE_STATIC, PRIVATE, PRIVATE_CONSTANT, PRIVATE_STATIC, PROTECTED, PROTECTED_ABSTRACT, PROTECTED_CONSTANT, PROTECTED_STATIC, PUBLIC, PUBLIC_ABSTRACT, PUBLIC_CONSTANT, PUBLIC_STATIC, STATIC
 
Constructor Summary
ClassInfoImpl()
          Create a new abstract ClassInfo.
ClassInfoImpl(String name)
          Create a new class info
ClassInfoImpl(String name, int modifiers)
          Create a new abstract ClassInfo.
ClassInfoImpl(String name, int modifiers, InterfaceInfo[] interfaces, ClassInfoImpl superclass)
          Create a new abstract ClassInfo.
 
Method Summary
 Object convertValue(Object value)
          Convert a value
 Object convertValue(Object value, boolean replaceProperties)
          Convert a value
 Object convertValue(Object value, boolean replaceProperties, boolean trim)
          Convert a value
 boolean equals(Object obj)
           
static ConstructorInfo findConstructor(ConstructorInfo[] constructors, TypeInfo[] parameters)
          Find a constructor
static MethodInfo findMethod(MethodInfo[] methods, String name, TypeInfo[] parameters)
          Find a method
 TypeInfo[] getActualTypeArguments()
          Get the actual type parameters
static Class<?> getArrayClass(Class<?> clazz)
          Get an array class
 TypeInfo getArrayType()
          Get an array type
<T> T
getAttachment(Class<T> expectedType)
          Get an attachment from the type, uses the expected type as both the name and to cast the resulting object.
 Object getAttachment(String name)
          Get an attachment from the type
 TypeInfo getComponentType()
          Get the component type if it is a collection or an array
 ConstructorInfo getDeclaredConstructor(TypeInfo[] parameters)
          Get a declared constructor
 ConstructorInfo[] getDeclaredConstructors()
          Get the declared constructors
 FieldInfo getDeclaredField(String name)
          Get the declared field
 FieldInfo[] getDeclaredFields()
          Get the declared fields
 MethodInfo getDeclaredMethod(String name, TypeInfo[] parameters)
          Get the declared method
 MethodInfo[] getDeclaredMethods()
          Get the declared methods
 InterfaceInfo[] getGenericInterfaces()
          Get the generic interfaces
 ClassInfo getGenericSuperclass()
          Get the generic super class
 InterfaceInfo[] getInterfaces()
          Get the interfaces
 TypeInfo getKeyType()
          Get the key type if it is a map
 int getModifiers()
          Get the modifiers
 String getName()
          Get the class name
 TypeInfo getOwnerType()
          Get the owner type
 PackageInfo getPackage()
          Get the package
 ClassInfo getRawType()
          Get the raw type
 String getSimpleName()
          Get the simple name
 ClassInfo getSuperclass()
          Get the super class
protected  InheritableAnnotationHolder getSuperHolder()
          Get the super holder of annoations
 Class<? extends Object> getType()
          Deprecated. 
 TypeInfoFactory getTypeInfoFactory()
          Get the TypeInfoFactory that created this type info
 TypeInfo getValueType()
          Get the value type if it is a map
 int hashCode()
           
 boolean isAnnotation()
          Whether this type is an annotation
 boolean isArray()
          Whether this type is an array
 boolean isAssignableFrom(TypeInfo info)
          Mostly using
 boolean isCollection()
          Whether this type is a collection
 boolean isEnum()
          Whether this type is an enum
 boolean isInstance(Object object)
          Is object instance of this type info.
 boolean isInterface()
          Whether it is an interface
 boolean isMap()
          Whether this type is a map
 boolean isPrimitive()
          Whether this type is a primitive
 boolean isPublic()
          Whether it is public
 boolean isStatic()
          Whether it is static
 boolean isVolatile()
          Whether it is volatile
 Object newArrayInstance(int size)
          Create a new array
 void setAttachment(String name, Object attachment)
          Set an attachment against the type.
 void setClassInfoHelper(ClassInfoHelper classInfoHelper)
           
 void setDeclaredConstructors(ConstructorInfoImpl[] constructors)
          Set the declared constructors
 void setDeclaredFields(FieldInfoImpl[] fields)
          Set the declared fields
 void setDeclaredMethods(MethodInfoImpl[] methods)
          Set the declared methods
 void setGenericInterfaces(InterfaceInfo[] interfaces)
          Set the generic interfaces
 void setGenericSuperclass(ClassInfo superInfo)
          Set the generic super class
 void setInterfaces(InterfaceInfo[] interfaces)
          Set the interfaces
 void setSuperclass(ClassInfoImpl superInfo)
          Set the super class
 void setType(Class<?> type)
          Set the type
 void setTypeInfoFactory(TypeInfoFactory typeInfoFactory)
           
protected  void toString(org.jboss.util.JBossStringBuilder buffer)
           
 
Methods inherited from class org.jboss.reflect.plugins.InheritableAnnotationHolder
getAllAnnotations, getAnnotation, getAnnotations, getDeclaredAnnotations, isAnnotationPresent, setAnnotatedElement, setAnnotationHelper, setupAnnotations
 
Methods inherited from class org.jboss.reflect.plugins.AbstractAnnotatedInfo
getUnderlyingAnnotation, getUnderlyingAnnotations, isAnnotationPresent
 
Methods inherited from class org.jboss.util.JBossObject
cacheGetHashCode, cacheToString, clone, equals, flushJBossObjectCache, getClassShortName, getHashCode, list, notEqual, toShortString, toShortString, toString, toStringImplementation
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.reflect.spi.AnnotatedInfo
getAnnotation, getAnnotations, getUnderlyingAnnotation, getUnderlyingAnnotations, isAnnotationPresent, isAnnotationPresent
 
Methods inherited from interface org.jboss.util.JBossInterface
clone, toShortString, toShortString
 

Field Detail

UNKNOWN_CLASS

public static final ClassInfo UNKNOWN_CLASS
Marker for generation


UNKNOWN_CLASSES

public static final ClassInfo[] UNKNOWN_CLASSES
Marker for generation


UNKNOWN_TYPE

public static final TypeInfo UNKNOWN_TYPE
Marker for generation


UNKNOWN_TYPES

public static final TypeInfo[] UNKNOWN_TYPES
Marker for generation


UNKNOWN_INTERFACES

public static final InterfaceInfo[] UNKNOWN_INTERFACES
Marker for generation


UNKNOWN_CONSTRUCTORS

public static final ConstructorInfo[] UNKNOWN_CONSTRUCTORS
Marker for generation


UNKNOWN_METHODS

public static final MethodInfo[] UNKNOWN_METHODS
Marker for generation


UNKNOWN_FIELDS

public static final FieldInfo[] UNKNOWN_FIELDS
Marker for generation


name

protected String name
The class name


modifiers

protected int modifiers
The class modifiers


interfaces

protected InterfaceInfo[] interfaces
The interfaces


genericInterfaces

protected InterfaceInfo[] genericInterfaces
The generic interfaces


methods

protected MethodInfo[] methods
The methods


fields

protected FieldInfo[] fields
The fields


fieldMap

protected HashMap<String,FieldInfo> fieldMap
Field map Map


superclass

protected ClassInfo superclass
The super class


genericSuperclass

protected ClassInfo genericSuperclass
The generic super class


constructors

protected ConstructorInfo[] constructors
The constructor info


packageInfo

protected PackageInfo packageInfo
The package info


classInfoHelper

protected transient ClassInfoHelper classInfoHelper
The class info helper


typeInfoFactory

protected transient TypeInfoFactory typeInfoFactory
The type info factory

Constructor Detail

ClassInfoImpl

public ClassInfoImpl()
Create a new abstract ClassInfo.


ClassInfoImpl

public ClassInfoImpl(String name)
Create a new class info

Parameters:
name - the class name

ClassInfoImpl

public ClassInfoImpl(String name,
                     int modifiers)
Create a new abstract ClassInfo.

Parameters:
name - the class name
modifiers - the class modifiers

ClassInfoImpl

public ClassInfoImpl(String name,
                     int modifiers,
                     InterfaceInfo[] interfaces,
                     ClassInfoImpl superclass)
Create a new abstract ClassInfo.

Parameters:
name - the class name
modifiers - the class modifiers
interfaces - the interfaces
superclass - the super class
Method Detail

getTypeInfoFactory

public TypeInfoFactory getTypeInfoFactory()
Description copied from interface: TypeInfo
Get the TypeInfoFactory that created this type info

Specified by:
getTypeInfoFactory in interface TypeInfo
Returns:
type info factory

setTypeInfoFactory

public void setTypeInfoFactory(TypeInfoFactory typeInfoFactory)

setClassInfoHelper

public void setClassInfoHelper(ClassInfoHelper classInfoHelper)

findMethod

public static MethodInfo findMethod(MethodInfo[] methods,
                                    String name,
                                    TypeInfo[] parameters)
Find a method

Parameters:
methods - the methods
name - the name
parameters - the parameters
Returns:
the method info

findConstructor

public static ConstructorInfo findConstructor(ConstructorInfo[] constructors,
                                              TypeInfo[] parameters)
Find a constructor

Parameters:
constructors - the constructors
parameters - the parameters
Returns:
the constructor info

getArrayClass

public static Class<?> getArrayClass(Class<?> clazz)
Get an array class

Parameters:
clazz - the class
Returns:
the array class

setType

public void setType(Class<?> type)
Set the type

Parameters:
type - the class

setInterfaces

public void setInterfaces(InterfaceInfo[] interfaces)
Set the interfaces

Parameters:
interfaces - the interfaces

setGenericInterfaces

public void setGenericInterfaces(InterfaceInfo[] interfaces)
Set the generic interfaces

Parameters:
interfaces - the interfaces

setDeclaredMethods

public void setDeclaredMethods(MethodInfoImpl[] methods)
Set the declared methods

Parameters:
methods - the methods

setDeclaredFields

public void setDeclaredFields(FieldInfoImpl[] fields)
Set the declared fields

Parameters:
fields - the fields

setDeclaredConstructors

public void setDeclaredConstructors(ConstructorInfoImpl[] constructors)
Set the declared constructors

Parameters:
constructors - the constructors

setSuperclass

public void setSuperclass(ClassInfoImpl superInfo)
Set the super class

Parameters:
superInfo - the super class

setGenericSuperclass

public void setGenericSuperclass(ClassInfo superInfo)
Set the generic super class

Parameters:
superInfo - the super class

isInterface

public boolean isInterface()
Description copied from interface: ClassInfo
Whether it is an interface

Specified by:
isInterface in interface ClassInfo
Returns:
true when an interface

getInterfaces

public InterfaceInfo[] getInterfaces()
Description copied from interface: ClassInfo
Get the interfaces

Specified by:
getInterfaces in interface ClassInfo
Returns:
the interfaces

getGenericInterfaces

public InterfaceInfo[] getGenericInterfaces()
Description copied from interface: ClassInfo
Get the generic interfaces

Specified by:
getGenericInterfaces in interface ClassInfo
Returns:
the generic interfaces

getDeclaredMethod

public MethodInfo getDeclaredMethod(String name,
                                    TypeInfo[] parameters)
Description copied from interface: ClassInfo
Get the declared method

Specified by:
getDeclaredMethod in interface ClassInfo
Parameters:
name - the method name
parameters - the parameters
Returns:
the method info

getDeclaredMethods

public MethodInfo[] getDeclaredMethods()
Description copied from interface: ClassInfo
Get the declared methods

Specified by:
getDeclaredMethods in interface ClassInfo
Returns:
the methods

getDeclaredField

public FieldInfo getDeclaredField(String name)
Description copied from interface: ClassInfo
Get the declared field

Specified by:
getDeclaredField in interface ClassInfo
Parameters:
name - the field name
Returns:
the field

getDeclaredFields

public FieldInfo[] getDeclaredFields()
Description copied from interface: ClassInfo
Get the declared fields

Specified by:
getDeclaredFields in interface ClassInfo
Returns:
the fields

getDeclaredConstructor

public ConstructorInfo getDeclaredConstructor(TypeInfo[] parameters)
Description copied from interface: ClassInfo
Get a declared constructor

Specified by:
getDeclaredConstructor in interface ClassInfo
Parameters:
parameters - the parameters
Returns:
the constructor

getDeclaredConstructors

public ConstructorInfo[] getDeclaredConstructors()
Description copied from interface: ClassInfo
Get the declared constructors

Specified by:
getDeclaredConstructors in interface ClassInfo
Returns:
the constructors

getSuperclass

public ClassInfo getSuperclass()
Description copied from interface: ClassInfo
Get the super class

Specified by:
getSuperclass in interface ClassInfo
Returns:
the super class

getGenericSuperclass

public ClassInfo getGenericSuperclass()
Description copied from interface: ClassInfo
Get the generic super class

Specified by:
getGenericSuperclass in interface ClassInfo
Returns:
the super class

getModifiers

public int getModifiers()
Description copied from interface: ModifierInfo
Get the modifiers

Specified by:
getModifiers in interface ModifierInfo
Returns:
the modifiers

isStatic

public boolean isStatic()
Description copied from interface: ModifierInfo
Whether it is static

Specified by:
isStatic in interface ModifierInfo
Returns:
true when static

isPublic

public boolean isPublic()
Description copied from interface: ModifierInfo
Whether it is public

Specified by:
isPublic in interface ModifierInfo
Returns:
true when public

isVolatile

public boolean isVolatile()
Description copied from interface: ModifierInfo
Whether it is volatile

Specified by:
isVolatile in interface ModifierInfo
Returns:
true if volatile

getName

public String getName()
Description copied from interface: ClassInfo
Get the class name

Specified by:
getName in interface ClassInfo
Specified by:
getName in interface TypeInfo
Returns:
the name

getSimpleName

public String getSimpleName()
Description copied from interface: TypeInfo
Get the simple name

Specified by:
getSimpleName in interface TypeInfo
Returns:
the simple name

getType

@Deprecated
public Class<? extends Object> getType()
Deprecated. 

Description copied from interface: TypeInfo
Get the class

Specified by:
getType in interface TypeInfo
Returns:
the class

convertValue

public Object convertValue(Object value)
                    throws Throwable
Description copied from interface: TypeInfo
Convert a value

Specified by:
convertValue in interface TypeInfo
Parameters:
value - the original value
Returns:
the converted value
Throws:
Throwable - for any error

convertValue

public Object convertValue(Object value,
                           boolean replaceProperties)
                    throws Throwable
Description copied from interface: TypeInfo
Convert a value

Specified by:
convertValue in interface TypeInfo
Parameters:
value - the original value
replaceProperties - whether to replace properties
Returns:
the converted value
Throws:
Throwable - for any error

convertValue

public Object convertValue(Object value,
                           boolean replaceProperties,
                           boolean trim)
                    throws Throwable
Description copied from interface: TypeInfo
Convert a value

Specified by:
convertValue in interface TypeInfo
Parameters:
value - the original value
replaceProperties - whether to replace properties
trim - do we trim before conversion
Returns:
the converted value
Throws:
Throwable - for any error

isArray

public boolean isArray()
Description copied from interface: TypeInfo
Whether this type is an array

Specified by:
isArray in interface TypeInfo
Returns:
true when an array

isCollection

public boolean isCollection()
Description copied from interface: TypeInfo
Whether this type is a collection

Specified by:
isCollection in interface TypeInfo
Returns:
true when a collection

isMap

public boolean isMap()
Description copied from interface: TypeInfo
Whether this type is a map

Specified by:
isMap in interface TypeInfo
Returns:
true when a map

isAnnotation

public boolean isAnnotation()
Description copied from interface: TypeInfo
Whether this type is an annotation

Specified by:
isAnnotation in interface TypeInfo
Returns:
true when an annotation

isEnum

public boolean isEnum()
Description copied from interface: TypeInfo
Whether this type is an enum

Specified by:
isEnum in interface TypeInfo
Returns:
true when an enum

isPrimitive

public boolean isPrimitive()
Description copied from interface: TypeInfo
Whether this type is a primitive

Specified by:
isPrimitive in interface TypeInfo
Returns:
true when a primtive

getArrayType

public TypeInfo getArrayType()
Description copied from interface: TypeInfo
Get an array type

Specified by:
getArrayType in interface TypeInfo
Returns:
the array type

newArrayInstance

public Object newArrayInstance(int size)
                        throws Throwable
Description copied from interface: TypeInfo
Create a new array

Specified by:
newArrayInstance in interface TypeInfo
Parameters:
size - the size
Returns:
the converted value
Throws:
Throwable - for any error

isAssignableFrom

public boolean isAssignableFrom(TypeInfo info)
Description copied from interface: TypeInfo
Mostly using

Specified by:
isAssignableFrom in interface TypeInfo
Parameters:
info - type info
Returns:
the boolean value indicating whether objects of the TypeInfo info can be assigned to objects of this TypeInfo
See Also:
PrimitiveInfo tests for progression

isInstance

public boolean isInstance(Object object)
Description copied from interface: TypeInfo
Is object instance of this type info.

Specified by:
isInstance in interface TypeInfo
Parameters:
object - the object to check
Returns:
true if object is an instance of this class
See Also:
PrimitiveInfo tests for progression

getActualTypeArguments

public TypeInfo[] getActualTypeArguments()
Description copied from interface: ClassInfo
Get the actual type parameters

Specified by:
getActualTypeArguments in interface ClassInfo
Returns:
the type parameters

getOwnerType

public TypeInfo getOwnerType()
Description copied from interface: ClassInfo
Get the owner type

Specified by:
getOwnerType in interface ClassInfo
Returns:
the owner type

getRawType

public ClassInfo getRawType()
Description copied from interface: ClassInfo
Get the raw type

Specified by:
getRawType in interface ClassInfo
Returns:
the raw type

getComponentType

public TypeInfo getComponentType()
Description copied from interface: ClassInfo
Get the component type if it is a collection or an array

Specified by:
getComponentType in interface ClassInfo
Returns:
the component type

getKeyType

public TypeInfo getKeyType()
Description copied from interface: ClassInfo
Get the key type if it is a map

Specified by:
getKeyType in interface ClassInfo
Returns:
the key type

getValueType

public TypeInfo getValueType()
Description copied from interface: ClassInfo
Get the value type if it is a map

Specified by:
getValueType in interface ClassInfo
Returns:
the value type

getPackage

public PackageInfo getPackage()
Description copied from interface: ClassInfo
Get the package

Specified by:
getPackage in interface ClassInfo
Returns:
the package

setAttachment

public void setAttachment(String name,
                          Object attachment)
Description copied from interface: TypeInfo
Set an attachment against the type. This is useful for caching information against a type.

If you add a future object, subsequent gets will wait for the result

WARNING: Be careful about what you put in here. Don't create references across classloaders, if you are not sure add a WeakReference to the information.

Specified by:
setAttachment in interface TypeInfo
Parameters:
name - the name
attachment - the attachment, pass null to remove an attachment

getAttachment

public <T> T getAttachment(Class<T> expectedType)
Description copied from interface: TypeInfo
Get an attachment from the type, uses the expected type as both the name and to cast the resulting object.

Specified by:
getAttachment in interface TypeInfo
Type Parameters:
T - the expected type
Parameters:
expectedType - the expected type
Returns:
the attachment

getAttachment

public Object getAttachment(String name)
Description copied from interface: TypeInfo
Get an attachment from the type

Specified by:
getAttachment in interface TypeInfo
Parameters:
name - the name
Returns:
the attachment

getSuperHolder

protected InheritableAnnotationHolder getSuperHolder()
Description copied from class: InheritableAnnotationHolder
Get the super holder of annoations

Specified by:
getSuperHolder in class InheritableAnnotationHolder
Returns:
the super holder

toString

protected void toString(org.jboss.util.JBossStringBuilder buffer)
Overrides:
toString in class org.jboss.util.JBossObject

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class org.jboss.util.JBossObject


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.