|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.jac.core.rtti.MetaItem
org.objectweb.jac.core.rtti.MetaItemDelegate
org.objectweb.jac.core.rtti.ClassItem
This class defines a meta item that corresponds to the
java.lang.reflect.Class
meta element.
Nested Class Summary | |
static class |
ClassItem.AmbiguousMethodNameException
The exception that is thrown when the accessed method has some synonymes (methods with same names but different parameter types). |
Field Summary | |
protected Hashtable |
fields
Stores the fields of the class. |
protected Hashtable |
methods
Stores the methods of the class. |
Fields inherited from class org.objectweb.jac.core.rtti.MetaItemDelegate |
delegate, parent |
Fields inherited from class org.objectweb.jac.core.rtti.MetaItem |
attrACs |
Constructor Summary | |
ClassItem(Class delegate)
Default contructor to create a new class item object. |
Method Summary | |
void |
addChild(ClassItem child)
|
void |
addConstructor(ConstructorItem constructor)
Add a constructor item to this class item. |
void |
addMethod(MethodItem method)
Add a method item to this class item. |
protected void |
buildFieldInfo()
|
Collection |
filterFields(String expression)
|
CollectionItem |
findCollectionFor(Object substance,
Object object)
Finds the collection of this class item that contains the given object. |
AbstractMethodItem |
getAbstractMethod(String name)
Gets an abstract method from its name. |
AbstractMethodItem[] |
getAbstractMethods(String name)
Gets a set of homonym methods (including constructors) from their names. |
Class |
getActualClass()
Gets the class represented by this class item. |
Collection |
getAllAccessors()
Gets all the method items that access the state of the instances for this class item. |
Collection |
getAllAdders()
Gets all the method items that adds an object from a collection of this class item. |
Collection |
getAllFields()
Gets all the fields for this class item |
Collection |
getAllGetters()
Gets all the getter methods of the class. |
Collection |
getAllInstanceMethods()
|
Collection |
getAllMembers()
|
Collection |
getAllMethods()
Gets all the method items for this class item. |
Collection |
getAllModifiers()
Gets all the method items that modify the state of the instances for this class item. |
Collection |
getAllRemovers()
Gets all the method items that removes an object from a collection of this class item. |
Collection |
getAllSetters()
Gets all the method items that modify the state of the instances for this class item. |
Collection |
getAllStaticMethods()
|
Collection |
getAllWriters()
Gets all the method items that modify a field of the instances for this class item. |
Object |
getAttribute(String name)
Get an attribute by searching recursively through all super classes. |
Collection |
getChildren()
|
CollectionItem |
getCollection(String name)
Gets a collection from its name. |
CollectionItem[] |
getCollections()
Gets all the collections for this class item. |
Collection |
getConstraints()
Return all field and collection items whose component type is this class. |
ConstructorItem |
getConstructor(Class[] parameterTypes)
|
ConstructorItem |
getConstructor(Constructor constructor)
Gets the constructor item of this class item that matches the given java.lang.reflect.Constructor . |
ConstructorItem |
getConstructor(String parameterTypes)
Get a constructor with given parameter types |
Collection |
getConstructors()
Gets all the constructors items for this class item. |
FieldItem |
getField(String name)
Gets a field from its name. |
FieldItem |
getFieldNoError(String name)
Gets a field from its name. |
FieldItem[] |
getFields()
Gets all the fields for this class item. |
FieldItem[] |
getFields(String[] names)
Returns a FieldItem array. |
ClassItem[] |
getInterfaceItems()
Returns the interfaces implemented by this class. |
Collection |
getMatchingRelations(String expr)
Gets all the references and collections that match the expression for this class item. |
MemberItem |
getMember(String name)
Returns the member (method or field) of this class with the specified name. |
MemberItem[] |
getMembers(String[] names)
Returns a MemberItem array. |
MethodItem |
getMethod(String name)
Gets a method from its name. |
Collection |
getMethods()
Gets a set of arrays containing all the method items for this class item. |
MethodItem[] |
getMethods(String name)
Gets a set of homonym methods (excluding constructors) from their names. |
MethodItem[] |
getMethods(String[] names)
Returns a MethodItem array. |
Collection |
getMixinMethods()
Gets all the method items for this class item. |
int |
getModifiers()
Get the modifiers (see java.lang.reflect) of the meta item. |
String |
getName()
This method gets the name of the meta item by delegating to the actual java.lang.reflect meta item. |
ClassItem |
getOwnerClassItem()
Gets the class this class is an inner class of. |
FieldItem[] |
getPrimitiveFields()
Gets all the primitive fields for this class item. |
FieldItem[] |
getReferences()
Gets all the references for this class item. |
String |
getShortName()
|
ClassItem |
getSuperclass()
Gets the superclass of this class item. |
Collection |
getTaggedFields(String attribute,
boolean not)
Gets all the current class item's fields that are tagged or not tagged with the given attribute. |
Collection |
getTaggedMembers(String attribute,
boolean not)
|
Collection |
getTaggedMembers(String attribute,
Object value)
Returns the members that are tagged by a given attribute that has a given value. |
Collection |
getTaggedMethods(String attribute,
boolean not)
|
Class |
getType()
Synonym of getActualClass . |
boolean |
hasField(String name)
Tests if a field exist in this class item. |
boolean |
hasMethod(MethodItem method)
|
boolean |
hasMethod(String name)
Tests if a method exist in this class item. |
boolean |
hasMethod(String name,
Class[] paramTypes)
Tells wether the class contains a method. |
Object |
invoke(Object object,
String methodName,
Object[] parameters)
A shortcut to invoke a method (avoid to get the method item). |
boolean |
isAbstract()
|
boolean |
isInner()
Tells wether this class is an inner class of some other class |
boolean |
isSubClassOf(ClassItem cl)
Tells wether the class inherits from a subclass |
boolean |
isSubClassOf(gnu.regexp.RE classNameRE)
Tells wether the class inherits from a subclass whose name matches a regular expression. |
Object |
newInstance()
Creates a new instance of this class item by using the default constructor (the one with no parameters). |
Object |
newInstance(Class[] types,
Object[] values)
Creates a new instance of this class item by using the constructor that matches the given parameter types. |
Object |
newInstance(Object[] parameters)
Create a new instance of the class, using the first constructor suitable for the given parameters. |
List |
parseExpression(String expression)
Parse the expression and computes its type. |
protected void |
setSuperClass(ClassItem superClass)
Set the super class of this class and updates the children of the super class. |
Object |
superGetAttribute(String name)
|
Methods inherited from class org.objectweb.jac.core.rtti.MetaItemDelegate |
getDelegate, getParent, setParent, toString |
Methods inherited from class org.objectweb.jac.core.rtti.MetaItem |
getAttribute, getAttribute, getAttributeAlways, getBoolean, getItemClass, registerAccessController, setAttribute, setItemClass, unsetAttribute, unsetAttributesFor |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected Hashtable fields
protected Hashtable methods
Constructor Detail |
public ClassItem(Class delegate) throws InvalidDelegateException
delegate
- the java.lang.reflect.Class
actual
meta itemMethod Detail |
protected void buildFieldInfo()
public FieldItem getField(String name)
name
- the field name. If name contains a dot, it is
considered an expression field and is automatically created if
it does not exist yet.
FieldItem
instancegetFieldNoError(String)
public FieldItem getFieldNoError(String name)
name
- the field name
FieldItem
instance, or null if no such
field exists in the classgetField(String)
public List parseExpression(String expression)
expression
- the expression (public CollectionItem getCollection(String name)
name
- the collection name
CollectionItem
instancepublic FieldItem[] getFields()
public Collection getAllFields()
public Collection getTaggedFields(String attribute, boolean not)
attribute
- the attributenot
- if true, returns fields not tagged with attribute
public Collection filterFields(String expression)
expression
- something like [!](static|transient|private|public|protected)public Collection getTaggedMethods(String attribute, boolean not)
public Collection getTaggedMembers(String attribute, boolean not)
public Collection getTaggedMembers(String attribute, Object value)
attribute
- the attribute idvalue
- the value of the attribute (must not be null!!)public MemberItem getMember(String name)
name
- the name of the member that you want.
getMembers(String[])
public MemberItem[] getMembers(String[] names)
names
- the names of the members
getMember(String)
public Collection getAllMembers()
public FieldItem[] getFields(String[] names)
names
- the names of the members
getField(String)
public MethodItem[] getMethods(String[] names)
names
- the names of the members
getMethod(String)
public FieldItem[] getPrimitiveFields()
public FieldItem[] getReferences()
public Collection getMatchingRelations(String expr)
public CollectionItem[] getCollections()
public AbstractMethodItem[] getAbstractMethods(String name) throws NoSuchMethodException
name
- the name of the methods
MethodItem
instance
NoSuchMethodException
public AbstractMethodItem getAbstractMethod(String name) throws NoSuchMethodException, ClassItem.AmbiguousMethodNameException
If this method has homonym(s), then an
AmbiguousMethodNameException
is thrown.
An abstract method can be a static, an instance method or a constructor.
name
- the name of the method to search
NoSuchMethodException
ClassItem.AmbiguousMethodNameException
getMethod(String)
,
getAbstractMethods(String)
public boolean hasMethod(String name, Class[] paramTypes)
name
- name of the searched methodparamTypes
- types of the parameters of the searched methodClass.getDeclaredMethod(String,Class[])
public MethodItem[] getMethods(String name) throws NoSuchMethodException
name
- the name of the methods
MethodItem
instance
NoSuchMethodException
public MethodItem getMethod(String name) throws NoSuchMethodException, ClassItem.AmbiguousMethodNameException
If this method has homonym(s), then an
AmbiguousMethodNameException
is thrown.
A method can be a static or instance method but not a constructor.
name
- the name of the method to search
NoSuchMethodException
ClassItem.AmbiguousMethodNameException
getAbstractMethod(String)
,
getMethods(String)
public Collection getMethods()
Each arrays contains the methods of the same name.
public Collection getAllMethods()
public Collection getMixinMethods()
public Collection getAllStaticMethods()
public Collection getAllInstanceMethods()
public Collection getAllModifiers()
public Collection getAllSetters()
public Collection getAllWriters()
public Collection getAllGetters()
MethodItem.isGetter()
public Collection getAllAccessors()
public Collection getAllRemovers()
public Collection getAllAdders()
public Collection getConstructors()
public ConstructorItem getConstructor(Class[] parameterTypes) throws NoSuchMethodException
NoSuchMethodException
public ConstructorItem getConstructor(String parameterTypes)
parameterTypes
- the types of the constructor
parameters. For instance "(java.lang.Object,java.lang.String)".public ConstructorItem getConstructor(Constructor constructor)
java.lang.reflect.Constructor
.
public Object newInstance() throws InstantiationException, IllegalAccessException
InstantiationException
IllegalAccessException
public Object newInstance(Class[] types, Object[] values) throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException
types
- the types of the constructor argumentsvalues
- the arguments values
InstantiationException
IllegalAccessException
NoSuchMethodException
InvocationTargetException
public Object newInstance(Object[] parameters) throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException
parameters
- parameters of the constructor
InstantiationException
IllegalAccessException
NoSuchMethodException
InvocationTargetException
public Class getActualClass()
getType()
public ClassItem[] getInterfaceItems()
protected void setSuperClass(ClassItem superClass)
superClass
- the super classpublic ClassItem getSuperclass()
public Collection getChildren()
public void addChild(ClassItem child)
public boolean isSubClassOf(gnu.regexp.RE classNameRE)
classNameRE
- the regular expressionpublic boolean isSubClassOf(ClassItem cl)
cl
- the regular expressionpublic int getModifiers()
MetaItemDelegate
getModifiers
in class MetaItemDelegate
Modifier
public Class getType()
getActualClass
.
getType
in class MetaItemDelegate
getActualClass()
public void addMethod(MethodItem method)
method
- the new methodpublic void addConstructor(ConstructorItem constructor)
constructor
- the new constructorpublic boolean hasMethod(String name)
public boolean hasMethod(MethodItem method)
public boolean hasField(String name)
public String getName()
MetaItem
java.lang.reflect
meta item.
getName
in class MetaItem
public String getShortName()
public Object invoke(Object object, String methodName, Object[] parameters) throws IllegalAccessException, InvocationTargetException
object
- the object to perform the invocation on (may be
null for a static method)methodName
- the name of the method to invokeparameters
- the parameters passed to the method
IllegalAccessException
InvocationTargetException
MethodItem.invoke(Object,Object[])
public boolean isInner()
public boolean isAbstract()
public ClassItem getOwnerClassItem()
public CollectionItem findCollectionFor(Object substance, Object object)
substance
- the instance of the current class item to seek
inobject
- the object to find
public Object getAttribute(String name)
getAttribute
in class MetaItem
name
- the name of the attribute
public Object superGetAttribute(String name)
public Collection getConstraints()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |