Hi,
I am migrating some code from 1.4.2 to 1.5.0 but I am stopped by hashtable issue:
public class MyClass {
private static Hashtable ht = null;
private int id;
private String sID;
public MyClass() {
ht = new Hashtable();
id = 0;
}
public String subscribe(int i, MyObject event) throws Exception {
try {
id++;
Integer type = new Integer(event);
Hashtable group = (Hashtable)ht.get(type);
if (group == null) {
group = new Hashtable();
ht.put(type, group); // 1)
}
sID = type.toString() + new Integer(id).toString();
group.put(sID, event); // 2)
return sID;
}
catch (Exception exc) {
throw new NestedException(exc, "ERROR: bla bla bla bla");
}
}
public boolean unSubscribe(String sID) throws Exception {
try {
Enumeration g = ht.elements();
while (g.hasMoreElements()) {
Hashtable group = (Hashtable)g.nextElement();
if (group.remove(sID) != null)
return true;
}
return false;
}
catch (Exception exc) {
throw new NestedException(exc, "ERROR: bla bla bla bla");
}
}
1) Type safety: The method put(Object, Object) belongs to the raw type Hashtable. References to generic type Hashtable<K,V> should be parameterized
2) Type safety: The method put(Object, Object) belongs to the raw type Hashtable. References to generic type Hashtable<K,V> should be parameterized
Could you help me with this?
I am really being under pressure with this.
Thanks