org.jboss.reflect.spi
Interface TypeInfo

All Superinterfaces:
Serializable
All Known Subinterfaces:
AnnotationInfo, ArrayInfo, ClassInfo, EnumInfo, InterfaceInfo
All Known Implementing Classes:
AbstractTypeInfo, AnnotationInfoImpl, ArrayInfoImpl, ClassInfoImpl, DelegateClassInfo, EnumInfoImpl, InterfaceInfoImpl, JavassistAnnotationInfo, JavassistArrayInfoImpl, JavassistEnumInfo, JavassistTypeInfo, NumberInfo, ParameterizedArrayInfo, ParameterizedClassInfo, PrimitiveInfo, ReflectClassInfoImpl

public interface TypeInfo
extends Serializable

A type info

Author:
Bill Burke, Adrian Brock

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
 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
 String getName()
          Get the type name
 String getSimpleName()
          Get the simple name
 Class<?> getType()
          Deprecated. I'm not sure this should be here?
 TypeInfoFactory getTypeInfoFactory()
          Get the TypeInfoFactory that created this type info
 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 isMap()
          Whether this type is a map
 boolean isPrimitive()
          Whether this type is a primitive
 Object newArrayInstance(int size)
          Create a new array
 void setAttachment(String name, Object attachment)
          Set an attachment against the type.
 

Method Detail

getName

String getName()
Get the type name

Returns:
the name

getSimpleName

String getSimpleName()
Get the simple name

Returns:
the simple name

getType

Class<?> getType()
Deprecated. I'm not sure this should be here?

Get the class

Returns:
the class

convertValue

Object convertValue(Object value)
                    throws Throwable
Convert a value

Parameters:
value - the original value
Returns:
the converted value
Throws:
Throwable - for any error

convertValue

Object convertValue(Object value,
                    boolean replaceProperties)
                    throws Throwable
Convert a value

Parameters:
value - the original value
replaceProperties - whether to replace properties
Returns:
the converted value
Throws:
Throwable - for any error

convertValue

Object convertValue(Object value,
                    boolean replaceProperties,
                    boolean trim)
                    throws Throwable
Convert a value

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

boolean isArray()
Whether this type is an array

Returns:
true when an array

isCollection

boolean isCollection()
Whether this type is a collection

Returns:
true when a collection

isMap

boolean isMap()
Whether this type is a map

Returns:
true when a map

isAnnotation

boolean isAnnotation()
Whether this type is an annotation

Returns:
true when an annotation

isEnum

boolean isEnum()
Whether this type is an enum

Returns:
true when an enum

isPrimitive

boolean isPrimitive()
Whether this type is a primitive

Returns:
true when a primtive

getArrayType

TypeInfo getArrayType()
Get an array type

Returns:
the array type

newArrayInstance

Object newArrayInstance(int size)
                        throws Throwable
Create a new array

Parameters:
size - the size
Returns:
the converted value
Throws:
Throwable - for any error

isAssignableFrom

boolean isAssignableFrom(TypeInfo info)
Mostly using

Parameters:
info - type info
Returns:
the boolean value indicating whether objects of the TypeInfo info can be assigned to objects of this TypeInfo
Throws:
NullPointerException - if the specified TypeInfo parameter is null.
See Also:
PrimitiveInfo tests for progression

isInstance

boolean isInstance(Object object)
Is object instance of this type info.

Parameters:
object - the object to check
Returns:
true if object is an instance of this class
See Also:
PrimitiveInfo tests for progression

getTypeInfoFactory

TypeInfoFactory getTypeInfoFactory()
Get the TypeInfoFactory that created this type info

Returns:
type info factory

getAttachment

Object getAttachment(String name)
Get an attachment from the type

Parameters:
name - the name
Returns:
the attachment

getAttachment

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

Type Parameters:
T - the expected type
Parameters:
expectedType - the expected type
Returns:
the attachment
Throws:
ClassCastException - when the object is not of the expected type

setAttachment

void setAttachment(String name,
                   Object attachment)
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.

Parameters:
name - the name
attachment - the attachment, pass null to remove an attachment
Throws:
IllegalArgumentException - for a null name


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