5 public class DatabaseCache {
6 private final ArrayList _cache;
8 private final int _max;
10 public DatabaseCache(int i_max){
13 _cache = new ArrayList(_max);
16 public DatabaseCache(){
19 _cache = new ArrayList(_max);
22 public synchronized void put(String key, Object value){
27 System.out.println("put: remove " + _counter);
29 _cache.add(new Entry(key,value));
31 System.out.println("put: put " + _counter);
34 public synchronized void clear(){
38 public int containsKey(String key){
39 for(int i = 0; i<_cache.size(); i++){
40 if( _cache.get(i)!=null && ((Entry)_cache.get(i)).getKey().equals(key) )
46 public int containsValue(Object o){
47 for(int i = 0; i<_cache.size(); i++){
48 if( _cache.get(i)!=null && ((Entry)_cache.get(i)).getValue().equals(o) )
54 public Object get(String key){
55 for(int i = 0; i<_cache.size(); i++){
56 if( _cache.get(i) != null &&
57 ((Entry)_cache.get(i)).getKey(key) != null &&
58 ((Entry)_cache.get(i)).getKey(key).equals(key) ) {
59 System.out.println("test2: "+((Entry)_cache.get(i)).getKey(key));
60 return ((Entry)_cache.get(i)).getValue();
66 public synchronized boolean remove(String key){
67 int i = containsKey(key);
83 private Object _value;
85 public Entry(String i_key, Object i_value){
90 public void put(String i_key, Object i_value){
95 public Object getValue(String i_key){
96 if(i_key.equals(_key)){
103 public Object getValue(){
107 public String getKey(Object i_o){
108 if(i_o.equals(_value)){
115 public String getKey(){