00001 package plp.orientadaObjetos1.memoria.colecao; 00002 00003 import java.util.Enumeration; 00004 import java.util.Hashtable; 00005 00006 import plp.orientadaObjetos1.expressao.leftExpression.Id; 00007 import plp.orientadaObjetos1.expressao.valor.Valor; 00008 00013 public class HashIdValor { 00014 00018 private Hashtable tabela; 00019 00023 public HashIdValor() { 00024 this.tabela = new Hashtable(); 00025 } 00026 00035 public Valor put(Id id, Valor valor) { 00036 Object result = tabela.put(id, valor); 00037 if (result == null) { 00038 return null; 00039 } else { 00040 return (Valor) result; 00041 } 00042 } 00043 00052 public Valor change(Id id, Valor valor) { 00053 tabela.remove(id); 00054 Object result = tabela.put(id, valor); 00055 if (result == null) { 00056 return null; 00057 } else { 00058 return (Valor) result; 00059 } 00060 } 00061 00068 public Valor get(Id id) { 00069 Object result = tabela.get(id); 00070 if (result == null) { 00071 return null; 00072 } else { 00073 return (Valor) result; 00074 } 00075 } 00076 00082 public Enumeration keys() { 00083 return tabela.keys(); 00084 } 00085 }