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.aspect.Aspectalizable; 23 import org.exolab.castor.mapping.MapItem; 24 25 32 public class AspectDataFieldHandler extends AbstractFieldHandler { 33 34 public Object getValue(Object object) { 35 HashMap map = new HashMap (); 36 Iterator iterator; 37 38 Map data = ((Aspectalizable) object).getPersistentAspectData(); 39 if (data == null) 40 return map; 41 42 iterator = data.entrySet().iterator(); 43 Map.Entry entry; 44 Object key; 45 while (iterator.hasNext()) { 46 entry = (Map.Entry ) iterator.next(); 47 key = entry.getKey(); 48 map.put(key, new MapItem(key, entry.getValue())); 49 } 50 return map; 51 } 52 53 public Object newInstance(Object parent) { 54 return new MapItem(); 55 } 56 57 public void resetValue(Object object) { 58 } 60 61 public void setValue(Object object, Object value) { 62 MapItem item = (MapItem) value; 63 ((Aspectalizable) object).addPersistentAspectData( 64 (String ) item.getKey(), 65 item.getValue()); 66 } 67 68 69 } 70 | Popular Tags |