|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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.
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 |
addAllowedCast(ClassItem src,
ClassItem dest)
Specify that a type can be safely casted into another type. |
void |
addDependentField(FieldItem field,
String dependentField)
Declares a field dependency. |
void |
addFieldDependency(FieldItem field,
FieldItem dependentField)
Tells that when field changes, dependentField changes too. |
void |
addMixinMethod(ClassItem cli,
MethodItem method)
Adds a mixin method to a class. |
void |
addRemover(CollectionItem collection,
String method)
Adds a removing method for a collection |
void |
addWrittenFields(AbstractMethodItem method,
String[] writtenFields)
Adds some written fields to a given method. |
void |
declareAssociation(FieldItem roleA,
FieldItem roleB)
Declares an association made of two roles. |
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 get instances of a class from, instead of fetching all instances of the class, when ObjectRepository.getObjects(ClassItem) is called. |
void |
newVirtualClass(String className,
ClassItem actualType)
Create a new virtual class. |
void |
setAdder(CollectionItem collection,
String method)
Sets the adder of a collection. |
void |
setAggregation(FieldItem field,
boolean isAggregation)
Tells wether a relation is an aggregation or not. |
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. the type of objects it contains. |
void |
setDynamicFieldType(FieldItem field,
MethodItem method)
Use a method to dynamically determine the type of a field |
void |
setFieldType(FieldItem field,
String type)
Declares a field to be of a given type |
void |
setGetter(FieldItem field,
String getterName)
Sets the getter of a field |
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 field)
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 |
setOppositeRole(FieldItem field,
FieldItem oppositeRole)
Sets the opposite role of a reference or collection field |
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. |
void |
setSetter(FieldItem field,
String setterName)
Sets the setter of a field |
Method Detail |
public void addWrittenFields(AbstractMethodItem method, String[] writtenFields)
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).
method
- the methodwrittenFields
- some new fields the method writespublic void addAccessedFields(MethodItem method, String[] accessedFields)
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).
method
- the methodaccessedFields
- some new fields the method readspublic void declareCalculatedField(ClassItem cl, String fieldName, String getterName)
cl
- the class item of te calculated fieldfieldName
- the name of the calculated fieldgetterName
- the name of the getter methodaddDependentField(FieldItem,String)
public void setSetter(FieldItem field, String setterName)
field
- the fieldsetterName
- name of the setter methodpublic void setGetter(FieldItem field, String getterName)
field
- the fieldgetterName
- name of the getter methodpublic void addDependentField(FieldItem field, String dependentField)
field
- the field to refreshdependentField
- the name of the field it depends on. It
must be in the same class as field.declareCalculatedField(ClassItem,String,String)
public void addFieldDependency(FieldItem field, FieldItem dependentField)
public void addAdder(CollectionItem collection, String method)
collection
- the collection's namemethod
- the name of the adding methodpublic void setAdder(CollectionItem collection, String method)
collection
- the collectionmethod
- the name of the adder methodpublic void addRemover(CollectionItem collection, String method)
collection
- the collectionmethod
- the name of the removing methodpublic void setRemover(CollectionItem collection, String method)
collection
- the collectionmethod
- the name of the remover methodpublic void setFieldType(FieldItem field, String type)
field
- the fieldtype
- the typesetDynamicFieldType(FieldItem,MethodItem)
public void setDynamicFieldType(FieldItem field, MethodItem method)
field
- the fieldmethod
- a static method taking as arguments a FieldItem
and an Object (holder of the field), and return a ClassItem or
a VirtualClassItem or a String.setFieldType(FieldItem,String)
public void setComponentType(CollectionItem collection, String type)
collection
- the collectiontype
- the component type of the collectionpublic void setParametersType(AbstractMethodItem method, String[] types)
method
- the methodtypes
- the types of each parameteropf the methodpublic void newVirtualClass(String className, ClassItem actualType)
className
- name of the new classactualType
- the actual primitive type that is extendedpublic void defineRepository(ClassItem type, String repositoryName, CollectionItem repositoryCollection)
type
- the type of objects to add in the repositoryrepositoryName
- the name of the object holding the repositoryrepositoryCollection
- the collection to get the objects
from. Any expression field can be used.ObjectRepository.getObjects(ClassItem)
public void setClonedFields(String className, String[] fields)
className
- the class namefields
- the names of the fields that are clonedpublic void setClass(ClassItem cli, String className)
cli
- the class to redefineclassName
- the new class namepublic void setClass(MemberItem member, String className)
member
- the member whose type to redefineclassName
- the new class namepublic void setParametersFields(AbstractMethodItem method, FieldItem[] fields)
Other aspects (such as the GUI aspect) may use this information to provide better default behaviour for the paramters.
method
- the of the methodfields
- 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.public void setNullAllowed(FieldItem field)
field
- the fieldsetNullAllowed(FieldItem,boolean)
public void setNullAllowed(FieldItem field, boolean allowed)
field
- the fieldallowed
- wether to allow null valuessetNullAllowed(FieldItem)
public void setNullAllowedParameters(AbstractMethodItem method, boolean[] nulls)
method
- the methodnulls
- 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)public void setIsIndex(CollectionItem collection, boolean isIndex)
collection
- the collectionisIndex
- wether the map is an indexsetIndexedField(CollectionItem,FieldItem)
,
CollectionItem.getActualCollection(Object)
,
CollectionItem.getActualCollectionThroughAccessor(Object)
public void setIndexedField(CollectionItem collection, FieldItem indexedField)
collection
- the collectionindexedField
- the field which is indexed by the mapsetIsIndex(CollectionItem,boolean)
,
CollectionItem.getActualCollection(Object)
,
CollectionItem.getActualCollectionThroughAccessor(Object)
public void definePrimaryKey(CollectionItem collection, String[] fields)
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).
public void setAggregation(FieldItem field, boolean isAggregation)
field
- the relationisAggregation
- wether the relation is an aggregations or not.public void addAllowedCast(ClassItem src, ClassItem dest)
Specify that a type can be safely casted into another type.
It can be useful it you changed the type of a field to a subclass of the original type that only adds new methods, and a persistence aspect complains that it cannot load this field anymore. dest should have constructor which takes a value of type src as the only argument.
src
- type of the value to be casteddest
- type the value should be casted topublic void setOppositeRole(FieldItem field, FieldItem oppositeRole)
field
- the field whose opposite role to setoppositeRole
- the opposite role of the fieldbdeclareAssociation(FieldItem,FieldItem)
public void declareAssociation(FieldItem roleA, FieldItem roleB)
When declared, the relations that constitutes the
association's roles are tagged in the RTTI by the
RttiAC.OPPOSITE_RELATION
attribute (then they can
be interpreted by other aspects such as Integrity, GUI or
Persistence).
For instance, if you have a Customer class and an Order class:
,----------. 1 n ,-------. | Customer |--------| Order | `----------' `-------'
roleA
- the starting role (e.g. Customer.orders)roleB
- the ending role (e.g. Order.customer)public void addMixinMethod(ClassItem cli, MethodItem method) throws InvalidDelegateException
A mixin method of class is a method which is not defined in the code of that class, but which will be made available on that class's ClassItem.
cli
- a classmethod
- a static method whose 1st argument must be cli.
InvalidDelegateException
MixinMethodItem.invoke(Object,Object[])
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |