package jcircus.complementaryenvs; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import jcircus.newutil.ExceptionUtil; //Created by Samuel Lincoln Magalh�es Barrocas, to map a channel name to its dimension in the translation strategy. public class ChanDimEnv { private HashMap _map; public ChanDimEnv() { this._map = new LinkedHashMap(); } public ChanDimEnv (ChanDimEnv cde) { this._map = cde.getMap(); } public void put (String channelName, int dim) { this._map.put(channelName, dim); } public int get (String channelName) { if (channelName == null) { ExceptionUtil.throwException("ChanDimEnv.get (String channelName): name of channel being null... It cannot happen!"); } if (this._map.get(channelName) != null) { return (int) this._map.get(channelName); } else { ExceptionUtil.throwException("I did not find the dimension of channel " + channelName + ". Please investigate why..."); return 0/*-2*/; } } public HashMap getMap () { return this._map; } public void setMap (HashMap map) { this._map = new LinkedHashMap (map); } public void set (String channelName, int dim) { if (this._map.containsKey(channelName)//this.get (channelName) != (new Integer (null)).intValue() ) { this._map.remove(channelName); } this.put(channelName, dim); } public Iterator iteratorKeys() { return this._map.keySet().iterator(); } }