|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.jac.core.AspectComponent
org.objectweb.jac.core.rtti.RttiAC
This class defines the rtti aspect.
It allows the programmer to add some runtime type informations on the classes of its applications.
ClassItem
,
MethodItem
,
FieldItem
,
CollectionItem
,
Serialized FormField Summary | |
static String |
AUTHORIZED_VALUES
|
static String |
CLONED_FIELDS
|
static String |
CONSTRAINTS
|
static String |
DYNAMIC_FIELD_TYPE
|
static String |
FIELD_TYPE
|
static String |
FORBIDDEN_VALUES
|
static String |
INDEXED_FIELD
|
static String |
IS_INDEX
|
static String |
NULL_ALLOWED
|
static String |
NULL_ALLOWED_PARAMETERS
|
static String |
OPPOSITE_ROLE
|
static String |
PARAMETER_TYPES
|
static String |
PARAMETERS_FIELDS
|
static String |
PRIMARY_KEY
|
static String |
REPOSITORY_COLLECTION
|
static String |
REPOSITORY_NAME
|
Fields inherited from class org.objectweb.jac.core.AspectComponent |
application, blockKeywords, cr, currentConfigMethod, currentImports, firstCall, NOT_SHARED, SHARED, startWeavingCCount, startWeavingCount, startWeavingMethod, startWeavingType, systemListener, wrappers |
Fields inherited from interface org.objectweb.jac.core.BaseProgramListener |
FOUND_OBJECT |
Constructor Summary | |
RttiAC()
|
Method Summary | |
void |
addAccessedFields(MethodItem method,
String[] accessedFields)
Adds some accessed fields to a given method. |
void |
addAdder(CollectionItem collection,
String methodName)
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 methodName)
Adds a removing method for a collection |
void |
addWrittenFields(AbstractMethodItem method,
String[] writtenFields)
Adds some written fields to a given method. |
static Object |
convert(Object value,
Class type)
Tries to convert an object into a given type If type is String, toString() is called on value. |
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. |
Set |
getClassesWithAssociations()
|
String[] |
getDefaultConfigs()
Returns defaults configuration files that must be loaded before the user's configuration |
static MetaItem |
getFieldType(FieldItem field)
Gets the type of a field. |
static MetaItem |
getFieldType(FieldItem field,
Object substance)
Gets the type of a field for a given object. |
static FieldItem |
getIndexFied(CollectionItem collection)
|
void |
ignoreFields(String packageExpr)
|
static boolean |
isCastAllowed(Class src,
Class dest)
|
static boolean |
isCastAllowed(ClassItem src,
ClassItem dest)
|
static boolean |
isCollectionType(Class type)
Tells wether a given type represents a collection |
static boolean |
isIndex(CollectionItem collection)
|
static boolean |
isNullAllowed(FieldItem field)
|
static boolean |
isNullAllowedParameter(AbstractMethodItem method,
int i)
|
void |
newVirtualClass(String className,
ClassItem actualType)
Create a new virtual class. |
void |
setAdder(CollectionItem collection,
String methodName)
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 methodName)
Sets the remover of a collection. |
void |
setSetter(FieldItem field,
String setterName)
Sets the setter of a field |
void |
whenClone(Wrappee cloned,
Wrappee clone)
This method is automatically called when a Jac Object is cloned. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String OPPOSITE_ROLE
public static final String FIELD_TYPE
public static final String DYNAMIC_FIELD_TYPE
public static final String PARAMETER_TYPES
public static final String CLONED_FIELDS
public static final String REPOSITORY_NAME
public static final String REPOSITORY_COLLECTION
public static final String NULL_ALLOWED_PARAMETERS
public static final String NULL_ALLOWED
public static final String IS_INDEX
public static final String INDEXED_FIELD
public static final String AUTHORIZED_VALUES
public static final String FORBIDDEN_VALUES
public static final String CONSTRAINTS
public static final String PARAMETERS_FIELDS
public static final String PRIMARY_KEY
Constructor Detail |
public RttiAC()
Method Detail |
public void addWrittenFields(AbstractMethodItem method, String[] writtenFields)
RttiConf
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).
addWrittenFields
in interface RttiConf
method
- the methodwrittenFields
- some new fields the method writespublic void declareCalculatedField(ClassItem cl, String fieldName, String getterName)
RttiConf
declareCalculatedField
in interface RttiConf
cl
- the class item of te calculated fieldfieldName
- the name of the calculated fieldgetterName
- the name of the getter methodRttiConf.addDependentField(FieldItem,String)
public void setSetter(FieldItem field, String setterName)
RttiConf
setSetter
in interface RttiConf
field
- the fieldsetterName
- name of the setter methodpublic void setGetter(FieldItem field, String getterName)
RttiConf
setGetter
in interface RttiConf
field
- the fieldgetterName
- name of the getter methodpublic void addDependentField(FieldItem field, String dependentField)
RttiConf
addDependentField
in interface RttiConf
field
- the field to refreshdependentField
- the name of the field it depends on. It
must be in the same class as field.RttiConf.declareCalculatedField(ClassItem,String,String)
public void addFieldDependency(FieldItem field, FieldItem dependentField)
RttiConf
addFieldDependency
in interface RttiConf
public void addAdder(CollectionItem collection, String methodName)
RttiConf
addAdder
in interface RttiConf
collection
- the collection's namemethodName
- the name of the adding methodpublic void setAdder(CollectionItem collection, String methodName)
RttiConf
setAdder
in interface RttiConf
collection
- the collectionmethodName
- the name of the adder methodpublic void addRemover(CollectionItem collection, String methodName)
RttiConf
addRemover
in interface RttiConf
collection
- the collectionmethodName
- the name of the removing methodpublic void setRemover(CollectionItem collection, String methodName)
RttiConf
setRemover
in interface RttiConf
collection
- the collectionmethodName
- the name of the remover methodpublic void addAccessedFields(MethodItem method, String[] accessedFields)
RttiConf
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).
addAccessedFields
in interface RttiConf
method
- the methodaccessedFields
- some new fields the method readspublic void setFieldType(FieldItem field, String type)
RttiConf
setFieldType
in interface RttiConf
field
- the fieldtype
- the typeRttiConf.setDynamicFieldType(FieldItem,MethodItem)
public void setDynamicFieldType(FieldItem field, MethodItem method)
RttiConf
setDynamicFieldType
in interface RttiConf
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.RttiConf.setFieldType(FieldItem,String)
public void setComponentType(CollectionItem collection, String type)
RttiConf
setComponentType
in interface RttiConf
collection
- the collectiontype
- the component type of the collectionpublic static MetaItem getFieldType(FieldItem field)
field
- a fieldpublic static MetaItem getFieldType(FieldItem field, Object substance)
field
- a fieldsubstance
- the object holding the fieldpublic void setParametersType(AbstractMethodItem method, String[] types)
RttiConf
setParametersType
in interface RttiConf
method
- the methodtypes
- the types of each parameteropf the methodpublic void newVirtualClass(String className, ClassItem actualType)
RttiConf
newVirtualClass
in interface RttiConf
className
- name of the new classactualType
- the actual primitive type that is extendedpublic void defineRepository(ClassItem type, String repositoryName, CollectionItem repositoryCollection)
RttiConf
defineRepository
in interface RttiConf
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)
RttiConf
setClonedFields
in interface RttiConf
className
- the class namefields
- the names of the fields that are clonedpublic void whenClone(Wrappee cloned, Wrappee clone)
AspectComponent
whenClone
in interface BaseProgramListener
whenClone
in class AspectComponent
public void ignoreFields(String packageExpr)
public void setClass(MemberItem member, String className)
RttiConf
setClass
in interface RttiConf
member
- the member whose type to redefineclassName
- the new class namepublic void setClass(ClassItem cli, String className)
RttiConf
setClass
in interface RttiConf
cli
- the class to redefineclassName
- the new class namepublic void setParametersFields(AbstractMethodItem method, FieldItem[] fields)
RttiConf
Other aspects (such as the GUI aspect) may use this information to provide better default behaviour for the paramters.
setParametersFields
in interface RttiConf
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)
RttiConf
setNullAllowed
in interface RttiConf
field
- the fieldRttiConf.setNullAllowed(FieldItem,boolean)
public void setNullAllowed(FieldItem field, boolean allowed)
RttiConf
setNullAllowed
in interface RttiConf
field
- the fieldallowed
- wether to allow null valuesRttiConf.setNullAllowed(FieldItem)
public static boolean isNullAllowed(FieldItem field)
public void setNullAllowedParameters(AbstractMethodItem method, boolean[] nulls)
RttiConf
setNullAllowedParameters
in interface RttiConf
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 static boolean isNullAllowedParameter(AbstractMethodItem method, int i)
public void setAggregation(FieldItem field, boolean isAggregation)
RttiConf
setAggregation
in interface RttiConf
field
- the relationisAggregation
- wether the relation is an aggregations or not.public void setIndexedField(CollectionItem collection, FieldItem indexedField)
RttiConf
setIndexedField
in interface RttiConf
collection
- the collectionindexedField
- the field which is indexed by the mapRttiConf.setIsIndex(CollectionItem,boolean)
,
CollectionItem.getActualCollection(Object)
,
CollectionItem.getActualCollectionThroughAccessor(Object)
public void setIsIndex(CollectionItem collection, boolean isIndex)
RttiConf
setIsIndex
in interface RttiConf
collection
- the collectionisIndex
- wether the map is an indexRttiConf.setIndexedField(CollectionItem,FieldItem)
,
CollectionItem.getActualCollection(Object)
,
CollectionItem.getActualCollectionThroughAccessor(Object)
public static FieldItem getIndexFied(CollectionItem collection)
public static boolean isIndex(CollectionItem collection)
public String[] getDefaultConfigs()
AspectComponent
getDefaultConfigs
in class AspectComponent
public void definePrimaryKey(CollectionItem collection, String[] fields)
RttiConf
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).
definePrimaryKey
in interface RttiConf
public static boolean isCollectionType(Class type)
public void addAllowedCast(ClassItem src, ClassItem dest)
RttiConf
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.
addAllowedCast
in interface RttiConf
src
- type of the value to be casteddest
- type the value should be casted topublic static boolean isCastAllowed(ClassItem src, ClassItem dest)
public static boolean isCastAllowed(Class src, Class dest)
public Set getClassesWithAssociations()
public void setOppositeRole(FieldItem field, FieldItem oppositeRole)
RttiConf
setOppositeRole
in interface RttiConf
field
- the field whose opposite role to setoppositeRole
- the opposite role of the fieldbRttiConf.declareAssociation(FieldItem,FieldItem)
public void declareAssociation(FieldItem roleA, FieldItem roleB)
RttiConf
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 | `----------' `-------'
declareAssociation
in interface RttiConf
roleA
- the starting role (e.g. Customer.orders)roleB
- the ending role (e.g. Order.customer)public static Object convert(Object value, Class type) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
If type is String, toString() is called on value. If type Integer or Long (or int or long), and the value is numeric type (float,Float,double or Double) an Integer or Long is returned. Otherwise, isCastAllowed() is called, and if it returns true, we try to invoke a constructor take value as a parameter.
value
- the value to converttype
- the type to convert the value into
InstantiationException
IllegalAccessException
InvocationTargetException
NoSuchMethodException
isCastAllowed(Class,Class)
public void addMixinMethod(ClassItem cli, MethodItem method) throws InvalidDelegateException
RttiConf
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.
addMixinMethod
in interface RttiConf
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 |