1 32 33 package it.businesslogic.ireport; 34 35 import java.util.HashMap ; 36 import java.util.Iterator ; 37 38 42 public class IReportHashMapBean implements Cloneable { 43 44 private HashMap beanProperties = new HashMap (); 45 46 47 public IReportHashMapBean() { 48 } 49 50 public HashMap getBeanProperties() { 51 return beanProperties; 52 } 53 54 public void setBeanProperties(HashMap beanProperties) { 55 this.beanProperties = beanProperties; 56 } 57 58 59 public Object clone() 60 { 61 IReportHashMapBean newBean = new IReportHashMapBean(); 62 return clone(newBean); 63 } 64 65 66 public Object clone(IReportHashMapBean newBean) 67 { 68 Iterator i_keys = getBeanProperties().keySet().iterator(); 69 70 while (i_keys.hasNext()) 71 { 72 Object key = i_keys.next(); 73 newBean.getBeanProperties().put(key,getBeanProperties().get(key)); 74 } 75 76 return newBean; 77 } 78 79 83 public boolean getBooleanValue(String property, boolean defaultValue) 84 { 85 Object prop = getBeanProperties().get(property); 86 if (prop == null) return defaultValue; 87 return Boolean.valueOf( prop.toString() ).booleanValue(); 88 } 89 90 94 public String getStringValue(String property, String defaultValue) 95 { 96 Object prop = getBeanProperties().get(property); 97 if (prop == null) return defaultValue; 98 return prop.toString(); 99 } 100 101 105 public java.awt.Color getColorValue(String property, java.awt.Color defaultValue) 106 { 107 Object prop = getBeanProperties().get(property); 108 if (prop == null || !(prop instanceof java.awt.Color )) return defaultValue; 109 return (java.awt.Color )prop; 110 } 111 112 118 public int getIntValue(String property, int defaultValue) 119 { 120 Object prop = getBeanProperties().get(property); 121 if (prop == null) return defaultValue; 122 try { 123 return Integer.valueOf( prop.toString() ).intValue(); 124 } catch (Exception ex) 125 { 126 getBeanProperties().remove(property); 127 return defaultValue; 128 } 129 } 130 131 136 public void setPropertyValue(String property, Object value) 137 { 138 if (property == null) return; 139 getBeanProperties().put(property,value); 140 } 141 142 147 public Object getPropertyValue(String property) 148 { 149 if (property == null) return null; 150 return getBeanProperties().get(property); 151 } 152 153 159 public int getDoubleValue(String property, int defaultValue) 160 { 161 Object prop = getBeanProperties().get(property); 162 if (prop == null) return defaultValue; 163 return Integer.valueOf( prop.toString() ).intValue(); 164 } 165 166 } 167 | Popular Tags |