import java.util.*; /** * Keeps current Objects * * @date May 11, 1998 ( Updated May 11, 1998 ) * @author H. Timucin Ozdemir * */ public class EntityManager { Hashtable objIDToCountry = new Hashtable(); public EntityManager() {} /** */ public void add( int objID, Country newCandidate ) { Country cnt = (Country) objIDToCountry.get( new Integer(objID) ); if( cnt == null ) objIDToCountry.put( new Integer(objID), newCandidate ) ; }// end of add() /** */ public void remove( int objID ) { Country cnt = (Country) objIDToCountry.get( new Integer(objID) ); if( cnt != null ) objIDToCountry.remove( new Integer(objID) ); }// end of remove() /** */ public Enumeration getAllEntities() { return objIDToCountry.elements(); }// end of getAllEntities() /** */ public Country getEntity( int objID ) { return (Country) objIDToCountry.get( new Integer(objID) ); }// end of getEntity() /** * Returns all simulated objects by this client. */ public Enumeration getSimulatedObjects() { Vector retV = new Vector(); Enumeration e = objIDToCountry.elements(); Country c; for(;e.hasMoreElements();) { c = (Country) e.nextElement(); if( c != null && c instanceof SimCountry ) retV.addElement(c); }// end of for e = null; if( retV.size() > 0 ) e = retV.elements(); return e; }// end of getSimulatedObjects() }// end of EntityManager