org.jboss.reflect.plugins.javassist
Class JavassistTypeInfo

java.lang.Object
  extended by org.jboss.util.JBossObject
      extended by org.jboss.reflect.plugins.AbstractAnnotatedInfo
          extended by org.jboss.reflect.plugins.javassist.JavassistAnnotatedInfo
              extended by org.jboss.reflect.plugins.javassist.JavassistInheritableAnnotationHolder
                  extended by org.jboss.reflect.plugins.javassist.JavassistTypeInfo
All Implemented Interfaces:
Serializable, Cloneable, AnnotatedInfo, ClassInfo, InterfaceInfo, ModifierInfo, TypeInfo, org.jboss.util.JBossInterface
Direct Known Subclasses:
JavassistAnnotationInfo, JavassistArrayInfoImpl, JavassistEnumInfo

public class JavassistTypeInfo
extends JavassistInheritableAnnotationHolder
implements ClassInfo, InterfaceInfo

JavassistTypeInfo.

Version:
$Revision: 81547 $
Author:
Adrian Brock
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jboss.reflect.plugins.javassist.JavassistInheritableAnnotationHolder
allAnnotations, allAnnotationsArray, ctClass
 
Fields inherited from class org.jboss.reflect.plugins.javassist.JavassistAnnotatedInfo
annotationHelper, annotationMap, annotationsArray
 
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
 
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)
           
protected  ConstructorInfo generateConstructorInfo(javassist.CtConstructor constructor)
          Generate constructor info
protected  ConstructorInfo generateConstructorInfo(org.jboss.reflect.plugins.javassist.SignatureKey key)
          Generate constructor info
protected  FieldInfo generateFieldInfo(javassist.CtField field)
          Generate field info
protected  MethodInfo generateMethodInfo(javassist.CtMethod method)
          Generate method info
protected  MethodInfo generateMethodInfo(org.jboss.reflect.plugins.javassist.SignatureKey key)
          Generate method info
protected  MethodInfo generateMethodInfo(org.jboss.reflect.plugins.javassist.SignatureKey key, javassist.CtMethod method)
          Generate method info
 TypeInfo[] getActualTypeArguments()
          Get the actual type parameters
protected  Object getAnnotatedTarget()
           
 AnnotationValue[] getAnnotations()
          Get the annotations
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
protected  JavassistTypeInfoFactoryImpl getFactory()
          Get the factory
 InterfaceInfo[] getGenericInterfaces()
          Get the generic interfaces
 ClassInfo getGenericSuperclass()
          Get the generic super class
protected  int getHashCode()
           
 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
protected  javassist.CtClass[] getParameterTypes(org.jboss.reflect.plugins.javassist.SignatureKey key)
          Get the parameter types
 ClassInfo getRawType()
          Get the raw type
 String getSimpleName()
          Get the simple name
 ClassInfo getSuperclass()
          Get the super class
 JavassistInheritableAnnotationHolder getSuperHolder()
           
 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
 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 toShortString(org.jboss.util.JBossStringBuilder buffer)
           
protected  void toString(org.jboss.util.JBossStringBuilder buffer)
           
 
Methods inherited from class org.jboss.reflect.plugins.javassist.JavassistInheritableAnnotationHolder
getAllAnnotations, getAnnotation, getAnnotations, isAnnotationPresent, 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, hashCode, list, notEqual, 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, getUnderlyingAnnotation, getUnderlyingAnnotations, isAnnotationPresent, isAnnotationPresent
 
Methods inherited from interface org.jboss.util.JBossInterface
clone, toShortString
 

Method Detail

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

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

getSimpleName

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

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

getModifiers

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

Specified by:
getModifiers in interface ModifierInfo
Returns:
the modifiers

isPublic

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

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

isStatic

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

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

isVolatile

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

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

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

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

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

getDeclaredConstructors

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

Specified by:
getDeclaredConstructors in interface ClassInfo
Returns:
the constructors

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

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

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

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

getArrayClass

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

Parameters:
clazz - the class
Returns:
the array class

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

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

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

getHashCode

protected int getHashCode()
Overrides:
getHashCode in class org.jboss.util.JBossObject

equals

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

toShortString

public void toShortString(org.jboss.util.JBossStringBuilder buffer)
Specified by:
toShortString in interface org.jboss.util.JBossInterface
Overrides:
toShortString in class org.jboss.util.JBossObject

toString

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

getFactory

protected JavassistTypeInfoFactoryImpl getFactory()
Get the factory

Returns:
the factory

generateConstructorInfo

protected ConstructorInfo generateConstructorInfo(javassist.CtConstructor constructor)
Generate constructor info

Parameters:
constructor - the constructor
Returns:
the constructor info

generateConstructorInfo

protected ConstructorInfo generateConstructorInfo(org.jboss.reflect.plugins.javassist.SignatureKey key)
Generate constructor info

Parameters:
key - the key
Returns:
the constructor info

generateFieldInfo

protected FieldInfo generateFieldInfo(javassist.CtField field)
Generate field info

Parameters:
field - the field
Returns:
the field info

generateMethodInfo

protected MethodInfo generateMethodInfo(org.jboss.reflect.plugins.javassist.SignatureKey key)
Generate method info

Parameters:
key - the key
Returns:
the method info

generateMethodInfo

protected MethodInfo generateMethodInfo(javassist.CtMethod method)
Generate method info

Parameters:
method - the method
Returns:
the method info

generateMethodInfo

protected MethodInfo generateMethodInfo(org.jboss.reflect.plugins.javassist.SignatureKey key,
                                        javassist.CtMethod method)
Generate method info

Parameters:
key - the key
method - the method
Returns:
the method info

getParameterTypes

protected javassist.CtClass[] getParameterTypes(org.jboss.reflect.plugins.javassist.SignatureKey key)
Get the parameter types

Parameters:
key - the key
Returns:
the parameter types

getAnnotatedTarget

protected Object getAnnotatedTarget()

getAnnotations

public AnnotationValue[] getAnnotations()
Description copied from interface: AnnotatedInfo
Get the annotations

Specified by:
getAnnotations in interface AnnotatedInfo
Overrides:
getAnnotations in class JavassistInheritableAnnotationHolder
Returns:
the annotations

getSuperHolder

public JavassistInheritableAnnotationHolder getSuperHolder()
Specified by:
getSuperHolder in class JavassistInheritableAnnotationHolder

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


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