Index: topia/src/java/org/codelutin/topia/annotation/ClassInfo.java diff -u topia/src/java/org/codelutin/topia/annotation/ClassInfo.java:1.3 topia/src/java/org/codelutin/topia/annotation/ClassInfo.java:1.4 --- topia/src/java/org/codelutin/topia/annotation/ClassInfo.java:1.3 Tue Jul 19 16:28:51 2005 +++ topia/src/java/org/codelutin/topia/annotation/ClassInfo.java Wed Jul 20 12:49:52 2005 @@ -23,10 +23,10 @@ * Created: 19 juillet 2005 12:18:58 CEST * * @author Benjamin POUSSIN - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * - * Last update: $Date: 2005/07/19 16:28:51 $ - * by : $Author: thimel $ + * Last update: $Date: 2005/07/20 12:49:52 $ + * by : $Author: bpoussin $ */ package org.codelutin.topia.annotation; @@ -42,28 +42,28 @@ /** le type de classe */ ClassType type() default ClassType.ENTITY; /** indique que la classe est une classe d'association */ - boolean associationClass() default false; + boolean isAssociationClass() default false; /** indique que la classe est une classe qui n'apparaissait pas dans le diagramme initial, mais qui a ete genere pour les besoins du framework */ boolean generatedClass() default false; - + /** indique le numéro de version de schema de la classe */ long schemaVersion(); /** liste des champs de la classe, les associations A et B ne font pas parti des champs*/ - String [] fields(); + String [] fields() default {}; /** liste les types de champs de la classe */ - Class [] fieldTypes(); + Class [] fieldTypes() default {}; /** Les valeurs par defaut des champs de la classe */ - String [] fieldValues(); + String [] fieldValues() default {}; /** Si associationClass est vrai indique la partie A de l'association */ Class associationA() default Void.class; /** Le nom du champs supportant l'association pour la classe A */ String associationAField() default ""; - /** indique la cardinalité de l'association, -1 indique *, 0 indique une - non navigabilité */ - int associationACardinality() default 0; + /** indique la cardinalité de l'association, {0,-1} indique *, + {0,0} indique une non navigabilité */ + int [] associationACardinality() default {0,0}; /** indique si le type d'association pour la partie A */ boolean associationAIsComposition() default false; @@ -71,9 +71,9 @@ Class associationB() default Void.class; /** Le nom du champs supportant l'association pour la classe B */ String associationBField() default ""; - /** indique la cardinalité de l'association, -1 indique *, 0 indique une - non navigabilité */ - int associationBCardinality() default 0; + /** indique la cardinalité de l'association, {0,-1} indique *, + {0,0} indique une non navigabilité */ + int [] associationBCardinality() default {0,0}; /** indique si le type d'association pour la partie B */ boolean associationBIsComposition() default false; Index: topia/src/java/org/codelutin/topia/annotation/MethodInfo.java diff -u topia/src/java/org/codelutin/topia/annotation/MethodInfo.java:1.3 topia/src/java/org/codelutin/topia/annotation/MethodInfo.java:1.4 --- topia/src/java/org/codelutin/topia/annotation/MethodInfo.java:1.3 Tue Jul 19 16:28:51 2005 +++ topia/src/java/org/codelutin/topia/annotation/MethodInfo.java Wed Jul 20 12:49:52 2005 @@ -23,10 +23,10 @@ * Created: 19 juillet 2005 12:36:01 CEST * * @author Benjamin POUSSIN - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * - * Last update: $Date: 2005/07/19 16:28:51 $ - * by : $Author: thimel $ + * Last update: $Date: 2005/07/20 12:49:52 $ + * by : $Author: bpoussin $ */ package org.codelutin.topia.annotation; @@ -44,7 +44,7 @@ /** si type vaut FIELD_ACCESSOR alors indique si la methode est une methode de modification de la valeur du champs sur lequel travail la méthode */ boolean isFieldModifier() default false; - /** si type vaut FIELD_ACCESSOR alors indique le type du champs sur lequel + /** si type vaut FIELD_ACCESSOR alors indique le champs sur lequel travail la méthode */ String field() default ""; /** si type vaut FIELD_ACCESSOR alors indique le type du champs sur lequel Index: topia/src/java/org/codelutin/topia/annotation/ClassInfoHelper.java diff -u /dev/null topia/src/java/org/codelutin/topia/annotation/ClassInfoHelper.java:1.1 --- /dev/null Wed Jul 20 12:49:57 2005 +++ topia/src/java/org/codelutin/topia/annotation/ClassInfoHelper.java Wed Jul 20 12:49:52 2005 @@ -0,0 +1,147 @@ +/* *##% + * Copyright (C) 2005 + * Code Lutin, Cédric Pineau, Benjamin Poussin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * ClassInfoHelper.java + * + * Created: 20 juillet 2005 12:35:42 CEST + * + * @author Benjamin POUSSIN + * @version $Revision: 1.1 $ + * + * Last update: $Date: 2005/07/20 12:49:52 $ + * by : $Author: bpoussin $ + */ + +package org.codelutin.topia.annotation; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** +* Methode util pour recuperer les MetaInformations des classes +*/ +@ClassInfo +public class ClassInfoHelper { // ClassInfoHelper + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private Logger log = Logger.getLogger("org.codelutin.topia.annotation.ClassInfoHelper"); + + /** + * Retourne l'info de la classe demande, on un info avec les valeurs + * par defaut si la classe passé en argument n'a pas d'info + */ + protected static ClassInfo getInfo(Class clazz){ + ClassInfo info = (ClassInfo)clazz.getAnnotation(ClassInfo.class); + if(info == null){ + info = ClassInfoHelper.class.getAnnotation(ClassInfo.class); + } + return info; + } + + /** le type de classe */ + public static ClassType type(Class clazz){ + ClassInfo info = getInfo(clazz); + return info.type(); + } + + /** indique que la classe est une classe d'association */ + public static boolean isAssociationClass(Class clazz){ + ClassInfo info = getInfo(clazz); + return info.isAssociationClass(); + } + + /** indique que la classe est une classe qui n'apparaissait pas dans le + diagramme initial, mais qui a ete genere pour les besoins du framework */ + public static boolean isGeneratedClass(Class clazz){ + ClassInfo info = getInfo(clazz); + return info.isGeneratedClass(); + } + + /** liste des champs de la classe, les associations A et B ne font pas + parti des champs*/ + public static String [] fields(Class clazz){ + ClassInfo info = getInfo(clazz); + return info.fields(); + } + + /** liste les types de champs de la classe */ + public static Class [] fieldTypes(Class clazz){ + ClassInfo info = getInfo(clazz); + return info.fieldTypes(); + } + + /** Les valeurs par defaut des champs de la classe */ + public static String [] fieldValues(Class clazz){ + ClassInfo info = getInfo(clazz); + return info.fieldValues(); + } + + /** Si associationClass est vrai indique la partie A de l'association */ + public static Class associationA(Class clazz){ + ClassInfo info = getInfo(clazz); + return info.associationA(); + } + + /** Le nom du champs supportant l'association pour la classe A */ + public static String associationAField(Class clazz){ + ClassInfo info = getInfo(clazz); + return info.associationAField(); + } + + /** indique la cardinalité de l'association, {0,-1} indique *, + {0,0} indique une non navigabilité */ + public static int [] associationACardinality(Class clazz){ + ClassInfo info = getInfo(clazz); + return info.associationACardinality(); + } + + /** indique si le type d'association pour la partie A */ + public static boolean associationAIsComposition(Class clazz){ + ClassInfo info = getInfo(clazz); + return info.associationAIsComposition(); + } + + /** Si associationClass est vrai indique la partie B de l'association */ + public static Class associationB(Class clazz){ + ClassInfo info = getInfo(clazz); + return info.associationB(); + } + + /** Le nom du champs supportant l'association pour la classe B */ + public static String associationBField(Class clazz){ + ClassInfo info = getInfo(clazz); + return info.associationBField(); + } + + /** indique la cardinalité de l'association, {0,-1} indique *, + {0,0} indique une non navigabilité */ + public static int [] associationBCardinality(Class clazz){ + ClassInfo info = getInfo(clazz); + return info.associationBCardinality(); + } + + /** indique si le type d'association pour la partie B */ + public static boolean associationBIsComposition(Class clazz){ + ClassInfo info = getInfo(clazz); + return info.associationBIsComposition(); + } + +} // ClassInfoHelper + Index: topia/src/java/org/codelutin/topia/annotation/MethodInfoHelper.java diff -u /dev/null topia/src/java/org/codelutin/topia/annotation/MethodInfoHelper.java:1.1 --- /dev/null Wed Jul 20 12:49:57 2005 +++ topia/src/java/org/codelutin/topia/annotation/MethodInfoHelper.java Wed Jul 20 12:49:52 2005 @@ -0,0 +1,95 @@ +/* *##% + * Copyright (C) 2005 + * Code Lutin, Cédric Pineau, Benjamin Poussin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * MethodInfoHelper.java + * + * Created: 20 juillet 2005 13:01:19 CEST + * + * @author Benjamin POUSSIN + * @version $Revision: 1.1 $ + * + * Last update: $Date: 2005/07/20 12:49:52 $ + * by : $Author: bpoussin $ + */ + +package org.codelutin.topia.annotation; + +import java.lang.reflect.Method; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class MethodInfoHelper { // MethodInfoHelper + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private Logger log = Logger.getLogger("org.codelutin.topia.annotation.MethodInfoHelper"); + + @MethodInfo + protected static MethodInfo getInfo(Method method){ + MethodInfo info = method.getAnnotation(MethodInfo.class); + if(info == null){ + try{ + method = MethodInfoHelper.class.getMethod("getInfo", Method.class); + }catch(NoSuchMethodException eee){ + // normalement ne doit pas survenir, car on est dans cette methode + throw new RuntimeException("Erreur inatendu, on recherchait la methode dans lequel on est"); + } + info = method.getAnnotation(MethodInfo.class); + } + return info; + } + + /** le type de methode */ + public static MethodType type(Method method){ + return getInfo(method).type(); + } + + /** SI type vaut FIELD_ACCESSOR alors indique si la methode est une methode + de modification de la valeur du champs sur lequel travail la méthode */ + public static boolean isFieldModifier(Method method){ + return getInfo(method).isFieldModifier(); + } + + /** si type vaut FIELD_ACCESSOR alors indique le champs sur lequel + travail la méthode */ + public static String field(Method method){ + return getInfo(method).field(); + } + + /** si type vaut FIELD_ACCESSOR alors indique le type du champs sur lequel + travail la méthode */ + public static Class fieldType(Method method){ + return getInfo(method).fieldType(); + } + + /** si type vaut FIELD_ACCESSOR alors indique la valeur par defaut du + champs sur lequel travail la méthode */ + public static String fieldValue(Method method){ + return getInfo(method).fieldValue(); + } + + /** si type vaut FIELD_ACCESSOR et que le fieldType est une relation, + indique la clase responsable de la conservation de l'information de la + relation */ + public static Class associationClass(Method method){ + return getInfo(method).associationClass(); + } + +} // MethodInfoHelper +