1 20 package org.enhydra.barracuda.contrib.dbroggisch.display; 21 22 23 import java.util.*; 24 import javax.servlet.*; 25 import javax.servlet.http.*; 26 27 import org.enhydra.barracuda.core.comp.*; 28 import org.enhydra.barracuda.core.forms.*; 29 import org.enhydra.barracuda.core.comp.model.*; 30 31 public class HashMapModel extends AbstractTemplateModel implements LightweightTemplateModel { 32 33 protected Map values; 34 protected String modelName; 35 36 public String getName() 37 { 38 return modelName; 39 } 40 41 public Object getItem(TemplateDirective td) { 43 return getItem(td.getKeyName()); 44 } 45 46 47 public Object getItem(String key) { 48 if(values != null && values.containsKey(key)) { 49 return values.get(key); 50 } 51 return super.getItem(key); 52 } 53 54 public void setName(String name) 55 { 56 modelName = name; 57 } 58 59 public HashMapModel() { 60 this(null, null); 61 } 62 63 public HashMapModel(String name, Map mp) { 64 modelName = name; 65 if(mp != null) { 66 values = mp; 67 } else { 68 values = new HashMap(); 69 } 70 } 71 72 public HashMapModel(String name) { 73 this(name, null); 74 } 75 76 77 public HashMapModel(Map mp) { 78 this(null, mp); 79 } 80 81 82 83 public void setItem(String key, Object value) { 84 values.put(key, value); 85 } 86 87 88 public Map getItems() { 89 return values; 90 } 91 92 public void setItems(Map v) { 93 values = v; 94 } 95 96 public void clear() { 97 values.clear(); 98 } 99 100 public Set keySet() { 101 return values.keySet(); 102 } 103 } 104 | Popular Tags |