Index: topia/doc/besoin.rst diff -u topia/doc/besoin.rst:1.1 topia/doc/besoin.rst:1.2 --- topia/doc/besoin.rst:1.1 Mon Aug 2 17:57:19 2004 +++ topia/doc/besoin.rst Fri Sep 24 15:43:31 2004 @@ -2,8 +2,8 @@ ====== :Author: Benjamin Poussin -:Revision: $Revision: 1.1 $ -:Date: $Date: 2004/08/02 17:57:19 $ +:Revision: $Revision: 1.2 $ +:Date: $Date: 2004/09/24 15:43:31 $ .. sectnum:: @@ -200,3 +200,116 @@ Lors de la lecture des fichiers XMI, si une entity externe est lu mais qu'aucune autre entity non extern porte le même nom alors une erreur est levée. + + +Classes d'association +===================== + +Reprendre la génération pour gérer les classes d'association comme dans l'exemple suivant : + + +ex : +:: + A ____________ B + * | * + | + | + C + +doit générer + +:: + import java.util.Collection; + import java.util.Hashtable; + + /** + * + */ + public class A { + protected Hashtable listAB = new Hashtable(); + + /** + * @param ab + */ + public void addAB(AB ab) { + listAB.put(ab.getB(), ab); + } + + public void removeAB(AB ab) { + listAB.remove(ab.getB()); + } + public AB getAB(B b) { + return (AB) listAB.get(b); + } + + public Collection getAB() { + return listAB.values(); + } + + public Collection getB() { + return listAB.keySet(); + } + + } + + public class B { + + protected Hashtable listAB = new Hashtable(); + + /** + * @param ab + */ + public void addAB(AB ab) { + listAB.put(ab.getA(), ab); + } + + public void removeAB(AB ab) { + listAB.remove(ab.getA()); + } + + public AB getAB(A a) { + return (AB) listAB.get(a); + } + + public Collection getAB() { + return listAB.values(); + } + + public Collection getA() { + return listAB.keySet(); + } + } + + public class AB { + protected A a; + protected B b; + + /** + * @param a + * @param b + */ + public AB(A a, B b) { + super(); + this.a = a; + this.b = b; + this.a.addAB(this); + this.b.addAB(this); + } + /** + * @return Returns the a. + */ + public A getA() { + return a; + } + /** + * @return Returns the b. + */ + public B getB() { + return b; + } + + public void remove() { + a.removeAB(this); + b.removeAB(this); + } + }