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 import org.apache.jetspeed.profiler.rules.RuleCriterion;
24
25 public class JSRuleCriterion
26 {
27
28
29 private String name;
30
31
32 private String type;
33
34 private String value;
35
36 private int fallBackOrder;
37
38 private int fallBackType;
39
40 public JSRuleCriterion()
41 {
42
43 }
44
45 public JSRuleCriterion(RuleCriterion c)
46 {
47 this.name = c.getName();
48 this.type = c.getType();
49 this.value = c.getValue();
50 this.fallBackOrder = c.getFallbackOrder();
51 this.fallBackType = c.getFallbackType();
52 }
53
54 /****************************************************************************
55 * SERIALIZER
56 */
57 private static final XMLFormat XML = new XMLFormat(JSRuleCriterion.class)
58 {
59 public void write(Object o, OutputElement xml)
60 throws XMLStreamException
61 {
62
63 try
64 {
65 JSRuleCriterion g = (JSRuleCriterion) o;
66 xml.setAttribute("name", g.name);
67 xml.add( g.type, "type",String.class);
68 xml.add(g.value,"value", String.class);
69 xml.add(new Integer(g.fallBackOrder), "fallBackOrder", Integer.class);
70 xml.add(new Integer(g.fallBackType), "fallBackType", Integer.class);
71
72
73
74 } catch (Exception e)
75 {
76 e.printStackTrace();
77 }
78 }
79
80 public void read(InputElement xml, Object o)
81 {
82 try
83 {
84 JSRuleCriterion g = (JSRuleCriterion) o;
85 g.name = StringEscapeUtils.unescapeHtml(xml.getAttribute("name","unknown_name"));
86 Object o1 = xml.get("type",String.class);
87 if (o1 instanceof String) g.type = StringEscapeUtils.unescapeHtml((String) o1);
88 o1 = xml.get("value",String.class);
89 if (o1 instanceof String) g.value = StringEscapeUtils.unescapeHtml((String) o1);
90
91 o1 = xml.get("fallBackOrder",String.class);
92 if (o1 instanceof String)
93 g.fallBackOrder = Integer.parseInt(((String) o1));
94 o1 = xml.get("fallBackType",String.class);
95 if (o1 instanceof String)
96 g.fallBackType = Integer.parseInt(((String) o1));
97
98 while (xml.hasNext())
99 {
100 }
101 } catch (Exception e)
102 {
103 e.printStackTrace();
104 }
105 }
106 };
107
108
109 /***
110 * @return Returns the type.
111 */
112 public String getType()
113 {
114 return type;
115 }
116
117 /***
118 * @param type The type to set.
119 */
120 public void setType(String type)
121 {
122 this.type = type;
123 }
124
125 /***
126 * @return Returns the fallBackOrder.
127 */
128 public int getFallBackOrder()
129 {
130 return fallBackOrder;
131 }
132
133 /***
134 * @param fallBackOrder The fallBackOrder to set.
135 */
136 public void setFallBackOrder(int fallBackOrder)
137 {
138 this.fallBackOrder = fallBackOrder;
139 }
140 /***
141 * @return Returns the fallBackType.
142 */
143 public int getFallBackType()
144 {
145 return fallBackType;
146 }
147
148 /***
149 * @param fallBackTye The fallBackType to set.
150 */
151 public void setFallBackType(int fallBackType)
152 {
153 this.fallBackType = fallBackType;
154 }
155
156
157
158 /***
159 * @return Returns the name.
160 */
161 public String getName()
162 {
163 return name;
164 }
165
166 /***
167 * @param name The name to set.
168 */
169 public void setName(String name)
170 {
171 this.name = name;
172 }
173
174 /***
175 * @return Returns the value.
176 */
177 public String getValue()
178 {
179 return value;
180 }
181
182 /***
183 * @param value The value to set.
184 */
185 public void setValue(String value)
186 {
187 this.value = value;
188 }
189
190
191 }