JAC project
AOPSYS
CEDRIC & LIP6 labs

org.objectweb.jac.core.rtti
Interface RttiConf

All Known Implementing Classes:
RttiAC

public interface RttiConf

This class defines the rtti aspect.

It allows the programmer to add some runtime type information on the classes of its applications.

Some configuration methods are useless since the type information is retrieved through bytecode analysis. They are kept in the interface in case of.

Author:
Renaud Pawlak, Laurent Martelli
See Also:
ClassItem, MethodItem, FieldItem, CollectionItem

Method Summary
 void addAccessedFields(MethodItem method, String[] accessedFields)
          Adds some accessed fields to a given method.
 void addAdder(CollectionItem collection, String method)
          Adds an adding method for a collection
 void addDependentField(FieldItem field, String dependentField)
          Declares a field dependency.
 void addRemover(CollectionItem collection, String method)
          Adds a removing method for a collection
 void addRoot(String name)
          This configuration method defines root objects.
 void addWrittenFields(AbstractMethodItem method, String[] writtenFields)
          Adds some written fields to a given method.
 void declareCalculatedField(ClassItem cl, String fieldName, String getterName)
          Declare a calculated field, which is a field with only a getter and no actual field.
 void definePrimaryKey(CollectionItem collection, String[] fields)
          Defines primary keys for a collection.
 void defineRepository(ClassItem type, String repositoryName, CollectionItem repositoryCollection)
          Declare a repository to which all instances of type will be automatically added.
 void introduce(ClassItem target, ClassItem roleType, String memberType, String memberName)
          Introduces a new member (field or method) into a given class.
 void newVirtualClass(String className, ClassItem actualType)
          Create a new virtual class.
 void setAdder(CollectionItem collection, String method)
          Sets the adder of a collection.
 void setClass(ClassItem cli, String className)
          Sets a user defined class on a class.
 void setClass(MemberItem member, String className)
          Sets a user defined class on a class' member.
 void setClonedFields(String className, String[] fields)
          This configuration method tells that the fields (references or collections) must be cloned when the class is cloned.
 void setComponentType(CollectionItem collection, String type)
          Sets the component type of a collection, i.e.
 void setFieldType(FieldItem field, String type)
          Declare a field to be of a given type
 void setIndexedField(CollectionItem collection, FieldItem indexedField)
          Tells that a Map implementing a collection indexes a field of the contained objects.
 void setIsIndex(CollectionItem collection, boolean isIndex)
          Specify wether a Map implementing a collection is a mere index for the collection (this is not the default).
 void setNullAllowed(FieldItem cli)
          This configuration method tells that the field can be set to null (forbidden by default)
 void setNullAllowed(FieldItem field, boolean allowed)
          This configuration method tells wether the field can be set to null or not.
 void setNullAllowedParameters(AbstractMethodItem method, boolean[] nulls)
          Tells if JAC object-typed (references) arguments of a method can take null value while the method's invocation or if they should be choosen in existing instances list.
 void setParametersFields(AbstractMethodItem method, FieldItem[] fields)
          Specifies that the parameters of a method will be assigned to a given field.
 void setParametersType(AbstractMethodItem method, String[] types)
          Declare a method's parameters to be of a given type
 void setRemover(CollectionItem collection, String method)
          Sets the remover of a collection.
 

Method Detail

introduce

public void introduce(ClassItem target,
                      ClassItem roleType,
                      String memberType,
                      String memberName)
Introduces a new member (field or method) into a given class. Does not work yet.

The target class does not declare the member but is wrapped by a wrapper that contains a member that should be considered as a base-object member.

Once introduced, the member will behave like a regular member if accessed or setted through the RTTI.

Parameters:
target - the target class where to add the memeber
roleType - the type of the role wrapper that actually contains the member

addWrittenFields

public void addWrittenFields(AbstractMethodItem method,
                             String[] writtenFields)
Adds some written fields to a given method.

This configuration method must be used when a method changes some field values and does not follow the naming conventions (it is not a setter or an adder for instance).

Parameters:
method - the method
writtenFields - some new fields the method writes

addAccessedFields

public void addAccessedFields(MethodItem method,
                              String[] accessedFields)
Adds some accessed fields to a given method.

This configuration method must be used when a method reads some field values and does not follow the naming conventions (it is not a getter for instance).

Parameters:
method - the method

declareCalculatedField

public void declareCalculatedField(ClassItem cl,
                                   String fieldName,
                                   String getterName)
Declare a calculated field, which is a field with only a getter and no actual field.

Parameters:
cl - the class item of te calculated field
fieldName - the name of the calculated field
getterName - the name of the getter method
See Also:
addDependentField(FieldItem,String)

addDependentField

public void addDependentField(FieldItem field,
                              String dependentField)
Declares a field dependency. It will cause the field to be refreshed when the dependent field's value changes.

Parameters:
field - the field to refresh
dependentField - the name of the field it depends on. It must be in the same class ass field.
See Also:
declareCalculatedField(ClassItem,String,String)

addAdder

public void addAdder(CollectionItem collection,
                     String method)
Adds an adding method for a collection

Parameters:
collection - the collection's name
method - the name of the adding method

setAdder

public void setAdder(CollectionItem collection,
                     String method)
Sets the adder of a collection.

Parameters:
collection - the collection
method - the name of the adder method

addRemover

public void addRemover(CollectionItem collection,
                       String method)
Adds a removing method for a collection

Parameters:
collection - the collection
method - the name of the removing method

setRemover

public void setRemover(CollectionItem collection,
                       String method)
Sets the remover of a collection.

Parameters:
collection - the collection's name
method - the name of the remover method

setFieldType

public void setFieldType(FieldItem field,
                         String type)
Declare a field to be of a given type

Parameters:
type - the type

setComponentType

public void setComponentType(CollectionItem collection,
                             String type)
Sets the component type of a collection, i.e. the type of objects it contains.

Parameters:
collection - the collection
type - the component type of the collection

setParametersType

public void setParametersType(AbstractMethodItem method,
                              String[] types)
Declare a method's parameters to be of a given type

Parameters:
method - the method

newVirtualClass

public void newVirtualClass(String className,
                            ClassItem actualType)
Create a new virtual class. Virtual classes allow you extend and refine the types used by the application, so that aspects can behave differently.

Parameters:
className - name of the new class
actualType - the actual primitive type that is extended

defineRepository

public void defineRepository(ClassItem type,
                             String repositoryName,
                             CollectionItem repositoryCollection)
Declare a repository to which all instances of type will be automatically added.

Parameters:
type - the type of objects to add in the repository
repositoryName - the name of the object holding the repository
repositoryCollection - the collection to add the objects to

addRoot

public void addRoot(String name)
This configuration method defines root objects.

Root objects are never garbaged since they are considered as an entry point to retrieve the application objects that are related to them.

Parameters:
name - the name of the root object

setClonedFields

public void setClonedFields(String className,
                            String[] fields)
This configuration method tells that the fields (references or collections) must be cloned when the class is cloned.

Parameters:
className - the class name
fields - the names of the fields that are cloned

setClass

public void setClass(ClassItem cli,
                     String className)
Sets a user defined class on a class. This can be used by aspects user-defined configuration.

Parameters:
cli - the class to redefine
className - the new class name

setClass

public void setClass(MemberItem member,
                     String className)
Sets a user defined class on a class' member. This can be used by aspects user-defined configuration.

Parameters:
member - the member whose type to redefine
className - the new class name

setParametersFields

public void setParametersFields(AbstractMethodItem method,
                                FieldItem[] fields)
Specifies that the parameters of a method will be assigned to a given field.

Other aspects (such as the GUI aspect) may use this information to provide better default behaviour for the paramters.

Parameters:
method - the of the method
fields - an array of field items, one per parameter of the method. Elements of this array may be null if some parameters are not assigned to any field.

setNullAllowed

public void setNullAllowed(FieldItem cli)
This configuration method tells that the field can be set to null (forbidden by default)

See Also:
#setNullAllowed(ClassItem,String,boolean)

setNullAllowed

public void setNullAllowed(FieldItem field,
                           boolean allowed)
This configuration method tells wether the field can be set to null or not. (forbidden by default)

Parameters:
field - the field
allowed - wether to allow null values
See Also:
#setNullAllowed(ClassItem,String)

setNullAllowedParameters

public void setNullAllowedParameters(AbstractMethodItem method,
                                     boolean[] nulls)
Tells if JAC object-typed (references) arguments of a method can take null value while the method's invocation or if they should be choosen in existing instances list.

Parameters:
method - the method
nulls - a flags array that tells for each parameter whether it can be null (true) or not (false). It has no effect if the parameter is not a JAC object (a reference)

setIsIndex

public void setIsIndex(CollectionItem collection,
                       boolean isIndex)
Specify wether a Map implementing a collection is a mere index for the collection (this is not the default). In this case, CollectionItem.getActualCollection() returns the values contained in the hashtable, otherwise the (key,values) entries are returned.

Parameters:
isIndex - wether the map is an index
See Also:
setIndexedField(CollectionItem,FieldItem), CollectionItem.getActualCollection(Object), CollectionItem.getActualCollectionThroughAccessor(Object)

setIndexedField

public void setIndexedField(CollectionItem collection,
                            FieldItem indexedField)
Tells that a Map implementing a collection indexes a field of the contained objects.

See Also:
setIsIndex(CollectionItem,boolean), CollectionItem.getActualCollection(Object), CollectionItem.getActualCollectionThroughAccessor(Object)

definePrimaryKey

public void definePrimaryKey(CollectionItem collection,
                             String[] fields)
Defines primary keys for a collection.

It is used to check for double entries in the collection by checking the precised fields (it is the same as primary keys in a database).


Contact JAC development team:
Renaud Pawlak
Lionel Seinturier
Laurent Martelli