1 package org.exoplatform.services.portal.skin.converter; 2 3 import java.util.* ; 4 import org.exoplatform.services.portal.skin.model.*; 5 6 import com.thoughtworks.xstream.converters.Converter; 7 import com.thoughtworks.xstream.converters.MarshallingContext; 8 import com.thoughtworks.xstream.converters.UnmarshallingContext; 9 import com.thoughtworks.xstream.io.HierarchicalStreamReader; 10 import com.thoughtworks.xstream.io.HierarchicalStreamWriter; 11 12 15 public class PortletStyleConfigConverter implements Converter { 16 17 public boolean canConvert(Class type) { 18 return type.equals(PortletStyleConfig.class) ; 19 } 20 21 public void marshal(Object source, HierarchicalStreamWriter w, MarshallingContext context) { 22 PortletStyleConfig decorator = (PortletStyleConfig) source ; 23 } 24 25 public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { 26 PortletStyleConfig psconfig = new PortletStyleConfig() ; 27 while (reader.hasMoreChildren()) { 28 reader.moveDown(); 29 String nodeName = reader.getNodeName() ; 30 if("portlet-name".equals(nodeName)) { 31 psconfig.setPortletName(reader.getValue()) ; 32 } else { 33 Object o = context.convertAnother(psconfig, Style.class) ; 34 psconfig.getStyles().add(o) ; 35 } 36 reader.moveUp(); 37 } 38 return psconfig ; 39 } 40 } | Popular Tags |