ChanDimEnv.java 1.57 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
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 <String, Integer> _map;
public ChanDimEnv() {
this._map = new LinkedHashMap<String, Integer>();
}
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 <String, Integer> getMap () {
return this._map;
}
public void setMap (HashMap <String, Integer> map) {
this._map = new LinkedHashMap <String, Integer> (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<String> iteratorKeys() {
return this._map.keySet().iterator();
}

}