org.objectweb.jac.core.rtti
Class AbstractMethodItem

java.lang.Object
  extended byorg.objectweb.jac.core.rtti.MetaItem
      extended byorg.objectweb.jac.core.rtti.MetaItemDelegate
          extended byorg.objectweb.jac.core.rtti.MemberItem
              extended byorg.objectweb.jac.core.rtti.AbstractMethodItem
Direct Known Subclasses:
ConstructorItem, MethodItem

public abstract class AbstractMethodItem
extends MemberItem

This class defines a meta item that corresponds to the java.lang.reflect.Method and to the java.lang.reflect.Constructor meta elements.

It appears that methods and contructors can be seen as semantically similar (a constructor is nothing else that a special static method that returns an object that is of the owner class type). Thus, we decide to wrap those two meta item into a unique one (on contrary to the Java choice)

Author:
Laurent Martelli, Renaud Pawlak

Field Summary
 
Fields inherited from class org.objectweb.jac.core.rtti.MemberItem
role, roleClassType, roleName, roleType
 
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
AbstractMethodItem(Object delegate, ClassItem parent)
          Default contructor to create a new abstract method item.
 
Method Summary
 void addAccessedField(FieldItem accessedField)
          Adds a new accessed field for this method.
 void addModifiedCollection(CollectionItem modifiedCollection)
          Adds a new modified collection for this method.
 void addWrittenField(FieldItem writtenField)
          Adds a new written field for this method.
 CollectionItem[] getAccessedCollections()
           
 FieldItem[] getAccessedFields()
          Gets the value of the fields that are written by this method.
 FieldItem[] getAccessedReferences()
          Gets the value of the fields that are written by this method.
 CollectionItem getAddedCollection()
          Get the value of the collection that is added by this method (the method is the unique adder of the collection).
abstract  CollectionItem[] getAddedCollections()
           
 Object getAttribute(String name)
          If the field does not have a value for the request attribute, tries on the superclass.
 String getCompactFullName()
          Return the full method name, ie with short parameter types.
 AbstractMethodItem getConcreteMethod()
          Returns the method item who really holds the byte code.
 String getFullName()
          Return the full method name, ie with parameter types.
static String getFullName(String name, Class[] pts)
           
 String getLongName()
          Returns the name prfixed with the owning class name.
 CollectionItem[] getModifiedCollections()
          Gets the value of the collections that are modified by this method.
 ClassItem getOwningClass()
          Returns the owning class of this method.
 Object getParameter(Object[] params, int i)
           
 int getParameterCount()
          Gets the number of parameters
 ClassItem getParameterTypeItem(int n)
          Get the ClassItem of the type of a parameter of the method.
abstract  Class[] getParameterTypes()
          Gets the parameter types of this abstract method item.
 String getRealFullName()
          Return the full method name, ie with parameter types.
abstract  CollectionItem[] getRemovedCollections()
           
abstract  FieldItem getSetField()
           
 FieldItem[] getWrittenFields()
          Gets the value of the fields that are written by this method.
 boolean hasModifiedCollections()
          Returns true if the method has at least one modified collection
 boolean hasWrittenFields()
           
 Object invoke(Object object, Object[] parameters)
           
abstract  boolean isAccessor()
           
abstract  boolean isAdder()
           
abstract  boolean isCollectionAccessor()
           
abstract  boolean isCollectionGetter()
           
abstract  boolean isCollectionSetter()
           
abstract  boolean isFieldGetter()
           
abstract  boolean isFieldSetter()
           
abstract  boolean isGetter()
           
 boolean isModifier()
          Tells wether the method modifies the state of the object
abstract  boolean isReferenceAccessor()
           
abstract  boolean isReferenceGetter()
           
abstract  boolean isReferenceSetter()
           
abstract  boolean isRemover()
           
abstract  boolean isSetter()
           
 boolean isStatic()
           
abstract  boolean isWriter()
           
 void removeAccessedField(FieldItem field)
          Removes an accessed field for this method.
 void removeWrittenField(FieldItem field)
          Removes a new written field for this method.
 void setAccessedFields(FieldItem[] accessedFields)
          Sets the value of the fields that are read by this method.
 void setParameter(Object[] params, int i, Object value)
           
 void setWrittenFields(FieldItem[] writtenFields)
          Sets the value of the fields that are written by this method.
 String toString()
          Overloads the default method to call the delegate one.
 
Methods inherited from class org.objectweb.jac.core.rtti.MemberItem
addDependentMethod, equals, getClassItem, getDependentMethods, getMemberFromFullName, getModifiers, getType, getTypeItem, isRole, setRole
 
Methods inherited from class org.objectweb.jac.core.rtti.MetaItemDelegate
getDelegate, getParent, setParent
 
Methods inherited from class org.objectweb.jac.core.rtti.MetaItem
getAttribute, getAttribute, getAttributeAlways, getBoolean, getItemClass, getName, registerAccessController, setAttribute, setItemClass, unsetAttribute, unsetAttributesFor
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractMethodItem

public AbstractMethodItem(Object delegate,
                          ClassItem parent)
                   throws InvalidDelegateException
Default contructor to create a new abstract method item.

Parameters:
delegate - the java.lang.reflect actual meta item
Method Detail

getAttribute

public final Object getAttribute(String name)
If the field does not have a value for the request attribute, tries on the superclass.

Overrides:
getAttribute in class MetaItem
Parameters:
name - the name of the attribute
Returns:
the value of the attribute

getParameterTypes

public abstract Class[] getParameterTypes()
Gets the parameter types of this abstract method item.

Returns:
the actual method parameter types

setParameter

public void setParameter(Object[] params,
                         int i,
                         Object value)

getParameter

public Object getParameter(Object[] params,
                           int i)

getParameterTypeItem

public ClassItem getParameterTypeItem(int n)
Get the ClassItem of the type of a parameter of the method.

Parameters:
n - the number of the parameter
Returns:
the ClassItem of the type of the parameter

getParameterCount

public int getParameterCount()
Gets the number of parameters

Returns:
the number of parameters.

isStatic

public final boolean isStatic()

getFullName

public String getFullName()
Return the full method name, ie with parameter types.

Returns:
The full method name. For instance myMethod(java.lang.String,int)
See Also:
getCompactFullName()

getRealFullName

public String getRealFullName()
Return the full method name, ie with parameter types.

Returns:
The full method name. For instance myMethod(java.lang.String,int)
See Also:
getCompactFullName()

getFullName

public static String getFullName(String name,
                                 Class[] pts)

getCompactFullName

public String getCompactFullName()
Return the full method name, ie with short parameter types.

Returns:
The full method name. For instance "myMethod(String,int)"
See Also:
getFullName()

getLongName

public String getLongName()
Description copied from class: MemberItem
Returns the name prfixed with the owning class name.

Overrides:
getLongName in class MemberItem

invoke

public Object invoke(Object object,
                     Object[] parameters)

getConcreteMethod

public AbstractMethodItem getConcreteMethod()
Returns the method item who really holds the byte code.


getOwningClass

public ClassItem getOwningClass()
Returns the owning class of this method.


isAdder

public abstract boolean isAdder()

getAddedCollections

public abstract CollectionItem[] getAddedCollections()

getAddedCollection

public final CollectionItem getAddedCollection()
Get the value of the collection that is added by this method (the method is the unique adder of the collection).

Returns:
value of addedCollection.

isRemover

public abstract boolean isRemover()

getRemovedCollections

public abstract CollectionItem[] getRemovedCollections()

isAccessor

public abstract boolean isAccessor()

isWriter

public abstract boolean isWriter()

isGetter

public abstract boolean isGetter()

isSetter

public abstract boolean isSetter()

isCollectionGetter

public abstract boolean isCollectionGetter()

isCollectionAccessor

public abstract boolean isCollectionAccessor()

isCollectionSetter

public abstract boolean isCollectionSetter()

isFieldGetter

public abstract boolean isFieldGetter()

isFieldSetter

public abstract boolean isFieldSetter()

isReferenceGetter

public abstract boolean isReferenceGetter()

isReferenceSetter

public abstract boolean isReferenceSetter()

isReferenceAccessor

public abstract boolean isReferenceAccessor()

getSetField

public abstract FieldItem getSetField()

getWrittenFields

public final FieldItem[] getWrittenFields()
Gets the value of the fields that are written by this method.

Returns:
value of writtenFields.

hasWrittenFields

public final boolean hasWrittenFields()

setWrittenFields

public final void setWrittenFields(FieldItem[] writtenFields)
Sets the value of the fields that are written by this method.

Parameters:
writtenFields - value to assign to writtenFields
See Also:
addWrittenField(FieldItem)

addWrittenField

public final void addWrittenField(FieldItem writtenField)
Adds a new written field for this method.

Parameters:
writtenField - the field to add
See Also:
setWrittenFields(FieldItem[]), removeWrittenField(FieldItem)

removeWrittenField

public final void removeWrittenField(FieldItem field)
Removes a new written field for this method.

Parameters:
field - the field to remove
See Also:
addWrittenField(FieldItem)

getModifiedCollections

public final CollectionItem[] getModifiedCollections()
Gets the value of the collections that are modified by this method.

Returns:
value of removedCollections.

hasModifiedCollections

public final boolean hasModifiedCollections()
Returns true if the method has at least one modified collection


addModifiedCollection

public final void addModifiedCollection(CollectionItem modifiedCollection)
Adds a new modified collection for this method.

Parameters:
modifiedCollection - the collection to add

getAccessedFields

public final FieldItem[] getAccessedFields()
Gets the value of the fields that are written by this method.

Returns:
value of accessedFields.

setAccessedFields

public void setAccessedFields(FieldItem[] accessedFields)
Sets the value of the fields that are read by this method.

Parameters:
accessedFields - value to assign to accessedFields
See Also:
addAccessedField(FieldItem)

addAccessedField

public void addAccessedField(FieldItem accessedField)
Adds a new accessed field for this method.

Parameters:
accessedField - the field to add
See Also:
setAccessedFields(FieldItem[]), removeAccessedField(FieldItem)

removeAccessedField

public void removeAccessedField(FieldItem field)
Removes an accessed field for this method.

Parameters:
field - the field to remove
See Also:
addAccessedField(FieldItem)

getAccessedReferences

public final FieldItem[] getAccessedReferences()
Gets the value of the fields that are written by this method.

Returns:
value of accessedFields.

getAccessedCollections

public final CollectionItem[] getAccessedCollections()

isModifier

public final boolean isModifier()
Tells wether the method modifies the state of the object


toString

public String toString()
Description copied from class: MetaItemDelegate
Overloads the default method to call the delegate one.

Overrides:
toString in class MemberItem