--- android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/TimeoutMap.java 2009/10/09 08:52:37 428 +++ android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/TimeoutMap.java 2010/07/07 12:02:40 966 @@ -1,11 +1,12 @@ package dk.thoerup.traininfoservice.banedk; -import java.util.concurrent.ConcurrentHashMap; +import java.util.ArrayList; import java.util.Collection; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + -import com.sun.xml.rpc.processor.schema.UnimplementedFeatureException; public class TimeoutMap implements Map{ @@ -35,17 +36,14 @@ } @Override - public boolean containsKey(Object arg0) { - CacheItem item = cache.get(arg0); - - return (item != null); + public boolean containsKey(Object key) { + return cache.containsKey(key); } @Override public boolean containsValue(Object arg0) { - //TODO someday implement this + //return values().contains(arg0); throw new UnsupportedOperationException(); - } @Override @@ -66,8 +64,9 @@ @Override public void putAll(Map arg0) { - //TODO someday implement this - throw new UnsupportedOperationException(); + for(K key : arg0.keySet()) { + this.put(key, arg0.get(key) ); + } } @Override @@ -82,8 +81,13 @@ @Override public Collection values() { - //TODO someday implement this - throw new UnsupportedOperationException(); + ArrayList values = new ArrayList(); + for (CacheItem item : cache.values()) { + values.add( item.value ); + } + + return values; + } @Override @@ -108,7 +112,12 @@ public V put(K key, V value) { CacheItem item= new CacheItem(value); - return cache.put(key, item).value; + item = cache.put(key, item); + + if (item != null) + return item.value; + else + return null; } }