1 20 package org.apache.slide.projector.store; 21 22 import java.io.IOException ; 23 24 import org.apache.slide.projector.Context; 25 import org.apache.slide.projector.Store; 26 import org.apache.slide.projector.value.MapValue; 27 28 public class FormStore extends AbstractStore { 29 private Context context; 30 private Store store; 31 32 public FormStore(Context context, Store store) { 33 this.context = context; 34 this.store = store; 35 } 36 37 public void put(String key, Object value) throws IOException { 38 MapValue domain = getDomain(); 39 domain.getMap().put(key, value); 40 } 41 42 public Object get(String key) throws IOException { 43 return getDomain().getMap().get(key); 44 } 45 46 public void dispose(String key) throws IOException { 47 getDomain().getMap().remove(key); 48 } 49 50 public void clear() throws IOException { 51 String domain = context.getProcess().toString(); 52 store.dispose(domain); 53 } 54 55 public MapValue getDomain() throws IOException { 56 String domain = context.getProcess().toString(); 57 MapValue mapResource = (MapValue)store.get(domain); 58 if ( mapResource == null ) { 59 mapResource = new MapValue(); 60 store.put(domain, mapResource); 61 return mapResource; 62 } else { 63 return mapResource; 64 } 65 } 66 } | Popular Tags |