1 |
package dk.thoerup.traininfoservice.banedk; |
package dk.thoerup.traininfoservice.banedk; |
2 |
|
|
3 |
import java.util.concurrent.ConcurrentHashMap; |
import java.util.ArrayList; |
4 |
import java.util.Collection; |
import java.util.Collection; |
5 |
import java.util.Map; |
import java.util.Map; |
6 |
import java.util.Set; |
import java.util.Set; |
7 |
|
import java.util.concurrent.ConcurrentHashMap; |
8 |
|
|
9 |
|
|
|
import com.sun.xml.rpc.processor.schema.UnimplementedFeatureException; |
|
10 |
|
|
11 |
public class TimeoutMap<K,V> implements Map<K,V>{ |
public class TimeoutMap<K,V> implements Map<K,V>{ |
12 |
|
|
36 |
} |
} |
37 |
|
|
38 |
@Override |
@Override |
39 |
public boolean containsKey(Object arg0) { |
public boolean containsKey(Object key) { |
40 |
CacheItem<V> item = cache.get(arg0); |
return cache.containsKey(key); |
|
|
|
|
return (item != null); |
|
41 |
} |
} |
42 |
|
|
43 |
@Override |
@Override |
44 |
public boolean containsValue(Object arg0) { |
public boolean containsValue(Object arg0) { |
45 |
//TODO someday implement this |
//return values().contains(arg0); |
46 |
throw new UnsupportedOperationException(); |
throw new UnsupportedOperationException(); |
|
|
|
47 |
} |
} |
48 |
|
|
49 |
@Override |
@Override |
64 |
|
|
65 |
@Override |
@Override |
66 |
public void putAll(Map<? extends K, ? extends V> arg0) { |
public void putAll(Map<? extends K, ? extends V> arg0) { |
67 |
//TODO someday implement this |
for(K key : arg0.keySet()) { |
68 |
throw new UnsupportedOperationException(); |
this.put(key, arg0.get(key) ); |
69 |
|
} |
70 |
} |
} |
71 |
|
|
72 |
@Override |
@Override |
81 |
|
|
82 |
@Override |
@Override |
83 |
public Collection<V> values() { |
public Collection<V> values() { |
84 |
//TODO someday implement this |
ArrayList<V> values = new ArrayList<V>(); |
85 |
throw new UnsupportedOperationException(); |
for (CacheItem<V> item : cache.values()) { |
86 |
|
values.add( item.value ); |
87 |
|
} |
88 |
|
|
89 |
|
return values; |
90 |
|
|
91 |
} |
} |
92 |
|
|
93 |
@Override |
@Override |
112 |
public V put(K key, V value) { |
public V put(K key, V value) { |
113 |
CacheItem<V> item= new CacheItem<V>(value); |
CacheItem<V> item= new CacheItem<V>(value); |
114 |
|
|
115 |
return cache.put(key, item).value; |
item = cache.put(key, item); |
116 |
|
|
117 |
|
if (item != null) |
118 |
|
return item.value; |
119 |
|
else |
120 |
|
return null; |
121 |
} |
} |
122 |
|
|
123 |
} |
} |