KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > portal > impl > converter > ComponentConverter


1 package org.exoplatform.services.portal.impl.converter;
2
3 import org.exoplatform.services.portal.model.*;
4 import com.thoughtworks.xstream.converters.Converter;
5 import com.thoughtworks.xstream.io.HierarchicalStreamReader;
6 import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
7
8 /**
9  * @author Tuan Nguyen
10  */

11 abstract public class ComponentConverter implements Converter {
12
13     public void writeBasicProperties(HierarchicalStreamWriter w, Component comp) {
14         if(comp.getId() != null) w.addAttribute("id", comp.getId()) ;
15         if(comp.getRenderer() != null) w.addAttribute("renderer", comp.getRenderer()) ;
16         if(comp.getDecorator() != null) w.addAttribute("decorator", comp.getDecorator()) ;
17         if(comp.getWidth() != null) w.addAttribute("width", comp.getWidth()) ;
18         if(comp.getHeight() != null) w.addAttribute("height", comp.getHeight()) ;
19     }
20     
21     public void readBasicProperty(HierarchicalStreamReader reader, Component comp) {
22         comp.setId(reader.getAttribute("id")) ;
23         comp.setRenderer(reader.getAttribute("renderer")) ;
24         comp.setDecorator(reader.getAttribute("decorator")) ;
25         comp.setWidth(reader.getAttribute("width")) ;
26         comp.setHeight(reader.getAttribute("height")) ;
27     }
28 }
Popular Tags