public class JavassistTypeInfo extends JavassistInheritableAnnotationHolder implements MutableClassInfo, InterfaceInfo
Modifier and Type | Class and Description |
---|---|
static class |
JavassistTypeInfo.MarshalledClassInfo |
Modifier and Type | Field and Description |
---|---|
protected static RuntimePermission |
GET_CLASSLOADER_PERMISSION
The get classloader permission
|
allAnnotations, allAnnotationsArray, ctClass, initialized
annotationHelper, annotationMap, annotationsArray
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
Modifier and Type | Method and Description |
---|---|
void |
addConstructor(MutableConstructorInfo mci)
Add a constructor
|
void |
addField(MutableFieldInfo mfi)
Add a field
|
void |
addMethod(MutableMethodInfo mmi)
Add a method
|
protected void |
clearConstructorCache() |
protected void |
clearFieldCache() |
protected void |
clearMethodCache() |
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
|
MutableConstructorInfo |
createMutableConstructor(Body body)
Compiles the code included in the Body parameter and returns a MutableConstructorInfo
representation of it.
|
MutableConstructorInfo |
createMutableConstructor(int modifiers,
Body body,
ClassInfo[] parameters,
ClassInfo[] exceptions)
Creates a constructor with the parameters given.
|
MutableConstructorInfo |
createMutableConstructor(int modifiers,
Body body,
String[] parameters,
String[] exceptions)
Creates a constructor with the parameters given.
|
MutableConstructorInfo |
createMutableConstructor(int modifiers,
ClassInfo[] parameters,
ClassInfo[] exceptions)
Creates an empty constructor with the parameters given.
|
MutableConstructorInfo |
createMutableConstructor(int modifiers,
String[] parameters,
String[] exceptions)
Creates an empty constructor with parameters given.
|
MutableFieldInfo |
createMutableField(int modifiers,
ClassInfo type,
String fieldName)
Creates a field connected to this class with the parameters given.
|
MutableFieldInfo |
createMutableField(int modifiers,
String type,
String fieldName)
Creates a field connected to this class with the parameters given.
|
MutableMethodInfo |
createMutableMethod(Body body)
Compiles the code included in Body and returns a MutableMethodInfo representation of it.
|
MutableMethodInfo |
createMutableMethod(int modifiers,
ClassInfo returnType,
String methodName,
Body body,
ClassInfo[] parameters,
ClassInfo[] exceptions)
Compiles a method with the signature and body given by the parameters.
|
MutableMethodInfo |
createMutableMethod(int modifiers,
ClassInfo returnType,
String methodName,
ClassInfo[] parameters,
ClassInfo[] exceptions)
Compiles an empty method with the signature given by the parameters.
|
MutableMethodInfo |
createMutableMethod(int modifiers,
String returnType,
String methodName,
Body body,
String[] parameters,
String[] exceptions)
Compiles a method with the signature and body given by the parameters.
|
MutableMethodInfo |
createMutableMethod(int modifiers,
String returnType,
String methodName,
String[] parameters,
String[] exceptions)
Compiles an empty method with the signature given by the parameters.
|
boolean |
equals(Object obj) |
protected MutableConstructorInfo |
generateConstructorInfo(javassist.CtConstructor constructor)
Generate constructor info
|
protected MutableConstructorInfo |
generateConstructorInfo(SignatureKey key)
Generate constructor info
|
protected MutableFieldInfo |
generateFieldInfo(javassist.CtField field)
Generate field info
|
protected MutableMethodInfo |
generateMethodInfo(javassist.CtMethod method)
Generate method info
|
protected MutableMethodInfo |
generateMethodInfo(SignatureKey key)
Generate method info
|
protected MutableMethodInfo |
generateMethodInfo(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 attachmentName)
Get an attachment from the type
|
ClassLoader |
getClassLoader()
Get the classloader for this class info.
|
ClassLoader |
getClassLoaderInternal() |
javassist.bytecode.SignatureAttribute.ClassSignature |
getClassSignature() |
TypeInfo |
getComponentType()
Get the component type if it is a collection or an array
|
MutableConstructorInfo |
getDeclaredConstructor()
Gets the default constructor (parameterless)
|
MutableConstructorInfo |
getDeclaredConstructor(String... parameters)
Get a declared constructor
Note: the parameters will be loaded with the classloader defined in
TypeInfoFactory.
|
MutableConstructorInfo |
getDeclaredConstructor(TypeInfo... parameters)
Get a declared constructor
|
MutableConstructorInfo[] |
getDeclaredConstructors()
Get the declared constructors
|
MutableFieldInfo |
getDeclaredField(String fieldName)
Get the declared field
|
MutableFieldInfo[] |
getDeclaredFields()
Get the declared fields
|
MutableMethodInfo |
getDeclaredMethod(String methodName)
Get the declared method without parameters.
|
MutableMethodInfo |
getDeclaredMethod(String methodName,
String... parameters)
Get the declared method
Note: the parameters will be loaded with the classloader defined in
TypeInfoFactory.
|
MutableMethodInfo |
getDeclaredMethod(String methodName,
TypeInfo... parameters)
Get the declared method
|
MutableMethodInfo[] |
getDeclaredMethods()
Get the declared methods
|
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(SignatureKey key)
Get the parameter types
|
ClassInfo |
getRawType()
Get the raw type
|
String |
getSimpleName()
Get the simple name
|
ClassInfo |
getSuperclass()
Get the super class
|
ClassInfo |
getSuperHolder() |
Class<? extends Object> |
getType()
Deprecated.
|
TypeInfoFactory |
getTypeInfoFactory()
Get the TypeInfoFactory that created this type info
|
String |
getTypeVariable()
Gets the type variable if we are a parameterized type which is part of a
parameterized type and there is a type variable for this type.
|
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() |
boolean |
isStatic()
Whether it is static
|
boolean |
isVolatile()
Whether it is volatile
|
Object |
newArrayInstance(int size)
Create a new array
|
void |
removeConstructor(MutableConstructorInfo mci)
Remove the specified constructor from this class
|
void |
removeField(MutableFieldInfo mfi)
Remove a field
|
void |
removeMethod(MutableMethodInfo mmi)
Remove the specified method from this class
|
void |
setAttachment(String name,
Object attachment)
Set an attachment against the type.
|
byte[] |
toByteCode()
Converts the class to a Class file.
|
void |
toShortString(org.jboss.util.JBossStringBuilder buffer) |
protected void |
toString(org.jboss.util.JBossStringBuilder buffer) |
protected Object |
writeReplace() |
getAllAnnotations, getAnnotation, getAnnotations, isAnnotationPresent, setupAnnotations
getUnderlyingAnnotation, getUnderlyingAnnotations, isAnnotationPresent
cacheGetHashCode, cacheToString, clone, equals, flushJBossObjectCache, getClassShortName, hashCode, list, notEqual, toShortString, toString, toStringImplementation
finalize, getClass, notify, notifyAll, wait, wait, wait
getAnnotation, getUnderlyingAnnotation, getUnderlyingAnnotations, isAnnotationPresent, isAnnotationPresent
protected static final RuntimePermission GET_CLASSLOADER_PERMISSION
public boolean isInterface()
ClassInfo
isInterface
in interface ClassInfo
public String getSimpleName()
TypeInfo
getSimpleName
in interface TypeInfo
public int getModifiers()
ModifierInfo
getModifiers
in interface ModifierInfo
public boolean isPublic()
isPublic
in interface ModifierInfo
public boolean isStatic()
ModifierInfo
isStatic
in interface ModifierInfo
public boolean isVolatile()
ModifierInfo
isVolatile
in interface ModifierInfo
@Deprecated public Class<? extends Object> getType()
TypeInfo
public ClassLoader getClassLoader()
TypeInfo
getClassLoader
in interface TypeInfo
public ClassLoader getClassLoaderInternal()
public ClassInfo getSuperclass()
ClassInfo
getSuperclass
in interface ClassInfo
public ClassInfo getGenericSuperclass()
ClassInfo
getGenericSuperclass
in interface ClassInfo
public InterfaceInfo[] getInterfaces()
ClassInfo
getInterfaces
in interface ClassInfo
public InterfaceInfo[] getGenericInterfaces()
ClassInfo
getGenericInterfaces
in interface ClassInfo
public MutableConstructorInfo[] getDeclaredConstructors()
MutableClassInfo
getDeclaredConstructors
in interface ClassInfo
getDeclaredConstructors
in interface MutableClassInfo
public MutableConstructorInfo getDeclaredConstructor()
MutableClassInfo
getDeclaredConstructor
in interface MutableClassInfo
public MutableConstructorInfo getDeclaredConstructor(TypeInfo... parameters)
MutableClassInfo
getDeclaredConstructor
in interface ClassInfo
getDeclaredConstructor
in interface MutableClassInfo
parameters
- the parameterspublic MutableConstructorInfo getDeclaredConstructor(String... parameters) throws ClassNotFoundException
MutableClassInfo
getDeclaredConstructor
in interface MutableClassInfo
parameters
- the parametersClassNotFoundException
public MutableFieldInfo getDeclaredField(String fieldName)
MutableClassInfo
getDeclaredField
in interface ClassInfo
getDeclaredField
in interface MutableClassInfo
fieldName
- the field namepublic MutableFieldInfo[] getDeclaredFields()
MutableClassInfo
getDeclaredFields
in interface ClassInfo
getDeclaredFields
in interface MutableClassInfo
public MutableMethodInfo getDeclaredMethod(String methodName)
MutableClassInfo
getDeclaredMethod
in interface MutableClassInfo
methodName
- the method namepublic MutableMethodInfo getDeclaredMethod(String methodName, TypeInfo... parameters)
MutableClassInfo
getDeclaredMethod
in interface ClassInfo
getDeclaredMethod
in interface MutableClassInfo
methodName
- the method nameparameters
- the parameterspublic MutableMethodInfo getDeclaredMethod(String methodName, String... parameters) throws ClassNotFoundException
MutableClassInfo
getDeclaredMethod
in interface MutableClassInfo
methodName
- the method nameparameters
- the parametersClassNotFoundException
public MutableMethodInfo[] getDeclaredMethods()
MutableClassInfo
getDeclaredMethods
in interface ClassInfo
getDeclaredMethods
in interface MutableClassInfo
public boolean isArray()
TypeInfo
public boolean isCollection()
TypeInfo
isCollection
in interface TypeInfo
public boolean isMap()
TypeInfo
public boolean isAnnotation()
TypeInfo
isAnnotation
in interface TypeInfo
public boolean isEnum()
TypeInfo
public boolean isPrimitive()
TypeInfo
isPrimitive
in interface TypeInfo
public static Class<?> getArrayClass(Class<?> clazz)
clazz
- the classpublic TypeInfo getArrayType()
TypeInfo
getArrayType
in interface TypeInfo
public Object newArrayInstance(int size) throws Throwable
TypeInfo
newArrayInstance
in interface TypeInfo
size
- the sizeThrowable
- for any errorpublic boolean isAssignableFrom(TypeInfo info)
TypeInfo
isAssignableFrom
in interface TypeInfo
info
- type infoPrimitiveInfo tests for progression
public boolean isInstance(Object object)
TypeInfo
isInstance
in interface TypeInfo
object
- the object to checkobject
is an instance of this classPrimitiveInfo tests for progression
public TypeInfoFactory getTypeInfoFactory()
TypeInfo
getTypeInfoFactory
in interface TypeInfo
public Object convertValue(Object value) throws Throwable
TypeInfo
convertValue
in interface TypeInfo
value
- the original valueThrowable
- for any errorpublic Object convertValue(Object value, boolean replaceProperties) throws Throwable
TypeInfo
convertValue
in interface TypeInfo
value
- the original valuereplaceProperties
- whether to replace propertiesThrowable
- for any errorpublic Object convertValue(Object value, boolean replaceProperties, boolean trim) throws Throwable
TypeInfo
convertValue
in interface TypeInfo
value
- the original valuereplaceProperties
- whether to replace propertiestrim
- do we trim before conversionThrowable
- for any errorprotected int getHashCode()
getHashCode
in class org.jboss.util.JBossObject
public void toShortString(org.jboss.util.JBossStringBuilder buffer)
toShortString
in interface org.jboss.util.JBossInterface
toShortString
in class org.jboss.util.JBossObject
protected void toString(org.jboss.util.JBossStringBuilder buffer)
toString
in class org.jboss.util.JBossObject
public JavassistTypeInfoFactoryImpl getFactory()
protected MutableConstructorInfo generateConstructorInfo(javassist.CtConstructor constructor)
constructor
- the constructorprotected MutableConstructorInfo generateConstructorInfo(SignatureKey key)
key
- the keyprotected MutableFieldInfo generateFieldInfo(javassist.CtField field)
field
- the fieldprotected MutableMethodInfo generateMethodInfo(SignatureKey key)
key
- the keyprotected MutableMethodInfo generateMethodInfo(javassist.CtMethod method)
method
- the methodprotected MutableMethodInfo generateMethodInfo(SignatureKey key, javassist.CtMethod method)
key
- the keymethod
- the methodprotected javassist.CtClass[] getParameterTypes(SignatureKey key)
key
- the keyprotected Object getAnnotatedTarget()
public AnnotationValue[] getAnnotations()
AnnotatedInfo
getAnnotations
in interface AnnotatedInfo
getAnnotations
in class JavassistInheritableAnnotationHolder
public ClassInfo getSuperHolder()
getSuperHolder
in class JavassistInheritableAnnotationHolder
public TypeInfo[] getActualTypeArguments()
ClassInfo
getActualTypeArguments
in interface ClassInfo
public TypeInfo getOwnerType()
ClassInfo
getOwnerType
in interface ClassInfo
public ClassInfo getRawType()
ClassInfo
getRawType
in interface ClassInfo
public TypeInfo getComponentType()
ClassInfo
getComponentType
in interface ClassInfo
public TypeInfo getKeyType()
ClassInfo
getKeyType
in interface ClassInfo
public TypeInfo getValueType()
ClassInfo
getValueType
in interface ClassInfo
public PackageInfo getPackage()
ClassInfo
getPackage
in interface ClassInfo
public void setAttachment(String name, Object attachment)
TypeInfo
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.
setAttachment
in interface TypeInfo
name
- the nameattachment
- the attachment, pass null to remove an attachmentpublic <T> T getAttachment(Class<T> expectedType)
TypeInfo
getAttachment
in interface TypeInfo
T
- the expected typeexpectedType
- the expected typepublic Object getAttachment(String attachmentName)
TypeInfo
getAttachment
in interface TypeInfo
attachmentName
- the nameprotected void clearMethodCache()
protected void clearConstructorCache()
protected void clearFieldCache()
public void addConstructor(MutableConstructorInfo mci)
MutableClassInfo
addConstructor
in interface MutableClassInfo
public void addField(MutableFieldInfo mfi)
MutableClassInfo
addField
in interface MutableClassInfo
public void addMethod(MutableMethodInfo mmi)
MutableClassInfo
addMethod
in interface MutableClassInfo
public MutableConstructorInfo createMutableConstructor(Body body)
MutableClassInfo
createMutableConstructor
in interface MutableClassInfo
body
- contains the code of the constructor to be createdpublic MutableConstructorInfo createMutableConstructor(int modifiers, String[] parameters, String[] exceptions)
MutableClassInfo
createMutableConstructor
in interface MutableClassInfo
modifiers
- the modifiers of the constructor to be createdparameters
- the parameters of the constructor to be createdexceptions
- the exceptions that the constructor to be created declares to throwpublic MutableConstructorInfo createMutableConstructor(int modifiers, ClassInfo[] parameters, ClassInfo[] exceptions)
MutableClassInfo
createMutableConstructor
in interface MutableClassInfo
modifiers
- the modifiers of the constructor to be createdparameters
- the parameters of the constructor to be createdexceptions
- the exceptions that the constructor to be created declares to throwpublic MutableConstructorInfo createMutableConstructor(int modifiers, Body body, String[] parameters, String[] exceptions)
MutableClassInfo
{}
.createMutableConstructor
in interface MutableClassInfo
modifiers
- the modifiers of the constructor to be createdbody
- the body of the constructor to be createdparameters
- the parameters of the constructor to be createdexceptions
- the exceptions that the constructor to be created declares to throwpublic MutableConstructorInfo createMutableConstructor(int modifiers, Body body, ClassInfo[] parameters, ClassInfo[] exceptions)
MutableClassInfo
{}
.createMutableConstructor
in interface MutableClassInfo
modifiers
- the modifiers of the constructor to be createdbody
- the body of the constructor to be createdparameters
- the parameters of the constructor to be createdexceptions
- the exceptions that the constructor to be created declares to throwpublic MutableFieldInfo createMutableField(int modifiers, String type, String fieldName)
MutableClassInfo
createMutableField
in interface MutableClassInfo
modifiers
- the modifiers of the field to be createdtype
- the type of the field to be createdfieldName
- the name of the field to be createdpublic MutableFieldInfo createMutableField(int modifiers, ClassInfo type, String fieldName)
MutableClassInfo
createMutableField
in interface MutableClassInfo
modifiers
- the modifiers of the field to be createdtype
- the type of the field to be createdfieldName
- the name of the field to be createdpublic MutableMethodInfo createMutableMethod(Body body)
MutableClassInfo
createMutableMethod
in interface MutableClassInfo
body
- contains the entire declaration of the method, including its signaturepublic MutableMethodInfo createMutableMethod(int modifiers, String returnType, String methodName, String[] parameters, String[] exceptions)
MutableClassInfo
createMutableMethod
in interface MutableClassInfo
modifiers
- the modifiers of the method to be createdreturnType
- the return type of the method to be createdmethodName
- the name of the method to be createdparameters
- the parameters of the method to be createdexceptions
- the exceptions that the method to be created declares to throwpublic MutableMethodInfo createMutableMethod(int modifiers, ClassInfo returnType, String methodName, ClassInfo[] parameters, ClassInfo[] exceptions)
MutableClassInfo
createMutableMethod
in interface MutableClassInfo
modifiers
- the modifiers of the method to be createdreturnType
- the return type of the method to be createdmethodName
- the name of the method to be createdparameters
- the parameters of the method to be createdexceptions
- the exceptions that the method to be created declares to throwpublic MutableMethodInfo createMutableMethod(int modifiers, String returnType, String methodName, Body body, String[] parameters, String[] exceptions)
MutableClassInfo
{}
.createMutableMethod
in interface MutableClassInfo
modifiers
- the modifiers of the method to be createdreturnType
- the return type of the method to be createdmethodName
- the name of the method to be createdbody
- the body of the method to be createdparameters
- the parameters of the method to be createdexceptions
- the exceptions that the method to be created declares to throwpublic MutableMethodInfo createMutableMethod(int modifiers, ClassInfo returnType, String methodName, Body body, ClassInfo[] parameters, ClassInfo[] exceptions)
MutableClassInfo
{}
.createMutableMethod
in interface MutableClassInfo
modifiers
- the modifiers of the method to be createdreturnType
- the return type of the method to be createdmethodName
- the name of the method to be createdbody
- the body of the method to be createdparameters
- the parameters of the method to be createdexceptions
- the exceptions that the method to be created declares to throwpublic void removeConstructor(MutableConstructorInfo mci)
MutableClassInfo
removeConstructor
in interface MutableClassInfo
public void removeField(MutableFieldInfo mfi)
MutableClassInfo
removeField
in interface MutableClassInfo
public void removeMethod(MutableMethodInfo mmi)
MutableClassInfo
removeMethod
in interface MutableClassInfo
public byte[] toByteCode()
MutableClassInfo
toByteCode
in interface MutableClassInfo
protected Object writeReplace()
public String getTypeVariable()
ClassInfo
getTypeVariable
in interface ClassInfo
public javassist.bytecode.SignatureAttribute.ClassSignature getClassSignature()
Copyright © 2013 JBoss, a division of Red Hat, Inc.. All Rights Reserved.