Index: topia/src/java/org/codelutin/topia/AbstractTopiaElement.java diff -u topia/src/java/org/codelutin/topia/AbstractTopiaElement.java:1.1 topia/src/java/org/codelutin/topia/AbstractTopiaElement.java:1.2 --- topia/src/java/org/codelutin/topia/AbstractTopiaElement.java:1.1 Thu Jul 15 13:19:30 2004 +++ topia/src/java/org/codelutin/topia/AbstractTopiaElement.java Fri Jun 10 17:16:38 2005 @@ -23,17 +23,17 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * - * Mise a jour: $Date: 2004/07/15 13:19:30 $ - * par : $Author: bpoussin $ + * Mise a jour: $Date: 2005/06/10 17:16:38 $ + * par : $Author: thimel $ */ package org.codelutin.topia; public abstract class AbstractTopiaElement implements TopiaElement { // AbstractTopiaElement - protected TopiaContext topiaContext; + transient protected TopiaContext topiaContext; public void setContext(TopiaContext topiaContext) throws TopiaException { this.topiaContext = topiaContext; Index: topia/src/java/org/codelutin/topia/TopiaAssociationsManager.java diff -u /dev/null topia/src/java/org/codelutin/topia/TopiaAssociationsManager.java:1.1 --- /dev/null Fri Jun 10 17:16:43 2005 +++ topia/src/java/org/codelutin/topia/TopiaAssociationsManager.java Fri Jun 10 17:16:38 2005 @@ -0,0 +1,90 @@ +/* *##% +* Copyright (C) 2002, 2003, 2004, 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. +*##%*/ + +/* * +* TopiaAssociationsManager.java +* +* Created: 9 juin 2005 +* +* @author Arnaud Thimel +* @version $Revision: 1.1 $ +*/ + + +package org.codelutin.topia; + +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; + +import org.codelutin.util.HashMapMultiKey; + + +public class TopiaAssociationsManager { + + Hashtable associations; + + public TopiaAssociationsManager() { + associations = new Hashtable(); + } + + public void createAssociation(String associationName) { + if (associations.get(associationName) == null) + associations.put( associationName, new HashMapMultiKey()); + } + + public HashMapMultiKey getAssociation(String associationName) { + return (HashMapMultiKey)associations.get(associationName); + } + + public List getKeys(String associationName, Object partOfKey) { + HashMapMultiKey assocMap = (HashMapMultiKey)associations.get(associationName); + if (assocMap == null) + return null; + return assocMap.getKeys(partOfKey); + } + + public Object getAssociationClass(String associationName, HashMapMultiKey.Key key) { + HashMapMultiKey assocMap = (HashMapMultiKey)associations.get(associationName); + if (assocMap == null) + return null; + return assocMap.get(key); + } + + public List getKeysForPosition(String associationName, Object partOfKey, int pos) { + List keys = getKeys(associationName, partOfKey); + for (Iterator it = keys.iterator(); it.hasNext(); ) { + HashMapMultiKey.Key key = (HashMapMultiKey.Key)it.next(); + if ((pos >= key.size()) || (!key.get(pos).equals(partOfKey))) + keys.remove(key); + } + return keys; + } + + public int numberInPosition(String associationName, Object partOfKey, int pos) { + int number = 0; + for (Iterator it = getKeys(associationName, partOfKey).iterator(); it.hasNext(); ) { + HashMapMultiKey.Key key = (HashMapMultiKey.Key)it.next(); + if ((pos < key.size()) || (key.get(pos).equals(partOfKey))) + number++; + } + return number; + } +}