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 JSApplication
31 {
32
33 private String name;
34
35 private String id;
36
37
38
39 private JSPortlets portlets = null;
40
41
42 public JSApplication()
43 {
44 }
45
46
47 public String getID()
48 {
49 return id;
50 }
51
52
53 public void setID(String id)
54 {
55 this.id = id;
56 }
57
58 public void setName(String name)
59 {
60 this.name = name;
61 }
62
63
64 public String getName()
65 {
66 return name;
67 }
68
69
70
71 /****************************************************************************
72 * SERIALIZER
73 */
74 private static final XMLFormat XML = new XMLFormat(JSApplication.class)
75 {
76
77 public void write(Object o, OutputElement xml)
78 throws XMLStreamException
79 {
80 try
81 {
82 JSApplication g = (JSApplication) o;
83 String s = g.getName();
84 if ((s != null) && (s.length() > 0))
85 xml.setAttribute("name", s);
86
87 xml.add(g.id, "ID",String.class);
88 xml.add(g.portlets);
89
90 } catch (Exception e)
91 {
92 e.printStackTrace();
93 }
94 }
95
96 public void read(InputElement xml, Object o)
97 {
98 try
99 {
100 JSApplication g = (JSApplication) o;
101 g.name = StringEscapeUtils.unescapeHtml(xml.getAttribute("name", "unknown"));
102
103
104
105 Object o1 = xml.get("ID",String.class);
106 if (o1 instanceof String) g.id = StringEscapeUtils.unescapeHtml((String) o1);
107
108 while (xml.hasNext())
109 {
110 o1 = xml.getNext();
111
112
113 if (o1 instanceof JSPortlets)
114 {
115 g.portlets = (JSPortlets) o1;
116 }
117 }
118
119
120 } catch (Exception e)
121 {
122 e.printStackTrace();
123 }
124 }
125
126 };
127
128
129
130
131
132 public JSPortlets getPortlets()
133 {
134 return portlets;
135 }
136
137 public void setPortlets(JSPortlets portlets)
138 {
139 this.portlets = portlets;
140 }
141
142 }