1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.serializer.objects;
18
19 import javolution.xml.XMLFormat;
20 import javolution.xml.stream.XMLStreamException;
21
22 import org.apache.commons.lang.StringEscapeUtils;
23
24 /***
25 * Jetspeed Serialized (JS) User
26 *
27 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
28 * @version $Id: $
29 */
30 public class JSPortlet
31 {
32
33 private String name;
34
35
36 private JSEntities entities = null;
37
38
39 public JSPortlet()
40 {
41 }
42
43
44 public void setName(String name)
45 {
46 this.name = name;
47 }
48
49
50 public String getName()
51 {
52 return name;
53 }
54
55 /***
56 * @param entities
57 * The entities to set.
58 */
59 public void setEntities(JSEntities entities)
60 {
61 this.entities = entities;
62 }
63
64 /***
65 * @return Returns the entities.
66 */
67 public JSEntities getEntities()
68 {
69 return entities;
70 }
71
72 /****************************************************************************
73 * SERIALIZER
74 */
75 private static final XMLFormat XML = new XMLFormat(JSPortlet.class)
76 {
77
78 public void write(Object o, OutputElement xml)
79 throws XMLStreamException
80 {
81 try
82 {
83 JSPortlet g = (JSPortlet) o;
84 String s = g.getName();
85 if ((s != null) && (s.length() > 0))
86 xml.setAttribute("name", s);
87 xml.add(g.entities);
88
89 } catch (Exception e)
90 {
91 e.printStackTrace();
92 }
93 }
94
95 public void read(InputElement xml, Object o)
96 {
97 try
98 {
99 JSPortlet g = (JSPortlet) o;
100 g.name = StringEscapeUtils.unescapeHtml(xml.getAttribute("name", "unknown"));
101
102
103 Object o1 = null;
104
105
106 while (xml.hasNext())
107 {
108 o1 = xml.getNext();
109
110 if (o1 instanceof JSEntities)
111 g.entities = (JSEntities) o1;
112 }
113
114
115 } catch (Exception e)
116 {
117 e.printStackTrace();
118 }
119 }
120
121 };
122
123
124 }