/[projects]/android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/TimeoutMap.java
ViewVC logotype

Diff of /android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/TimeoutMap.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 428 by torben, Fri Oct 9 08:52:37 2009 UTC revision 966 by torben, Wed Jul 7 12:02:40 2010 UTC
# Line 1  Line 1 
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    
# Line 35  public class TimeoutMap<K,V> implements Line 36  public class TimeoutMap<K,V> implements
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
# Line 66  public class TimeoutMap<K,V> implements Line 64  public class TimeoutMap<K,V> implements
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
# Line 82  public class TimeoutMap<K,V> implements Line 81  public class TimeoutMap<K,V> implements
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
# Line 108  public class TimeoutMap<K,V> implements Line 112  public class TimeoutMap<K,V> implements
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  }  }

Legend:
Removed from v.428  
changed lines
  Added in v.966

  ViewVC Help
Powered by ViewVC 1.1.20