1 16 package org.apache.cocoon.portal.util; 17 18 import java.util.HashMap ; 19 import java.util.Iterator ; 20 import java.util.Map ; 21 22 import org.apache.cocoon.portal.coplet.CopletBaseData; 23 import org.exolab.castor.mapping.MapItem; 24 25 32 public class ConfigurationFieldHandler extends AbstractFieldHandler { 33 34 public Object getValue(Object object) { 35 HashMap map = new HashMap (); 36 Iterator iterator = 37 ((CopletBaseData) object).getCopletConfig().entrySet().iterator(); 38 Map.Entry entry; 39 Object key; 40 while (iterator.hasNext()) { 41 entry = (Map.Entry ) iterator.next(); 42 key = entry.getKey(); 43 map.put(key, new MapItem(key, entry.getValue())); 44 } 45 return map; 46 } 47 48 public Object newInstance(Object parent) { 49 return new MapItem(); 50 } 51 52 public void resetValue(Object object) { 53 ((CopletBaseData) object).getCopletConfig().clear(); 54 } 55 56 public void setValue(Object object, Object value) { 57 MapItem item = (MapItem) value; 58 ((CopletBaseData) object).setCopletConfig( 59 (String ) item.getKey(), 60 item.getValue()); 61 } 62 } 63 | Popular Tags |