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 * Import ProfilingRule
26 *
27 * <profilingRule name = j2>
28 * <description>whatever</description>
29 * <className>org.apache.jetspeed.profile.RuleImpl</className>
30 * <criteria>
31 * ...
32 * </criteria>
33 * </profilingRule>
34 *
35 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
36 * @version $Id: $
37 */
38 public class JSProfilingRule
39 {
40 private String id;
41 private boolean standardRule;
42 private String description;
43 JSRuleCriterions criterions = new JSRuleCriterions();
44
45
46 public JSProfilingRule()
47 {
48 }
49
50
51 public boolean isStandardRule()
52 {
53 return standardRule;
54 }
55
56
57 public void setStandardRule(boolean standard)
58 {
59 this.standardRule = standard;
60 }
61
62
63 public String getDescription()
64 {
65 return description;
66 }
67
68
69 public void setDescription(String description)
70 {
71 this.description = description;
72 }
73
74
75 public String getId()
76 {
77 return id;
78 }
79
80
81 public void setId(String id)
82 {
83 this.id = id;
84 }
85
86
87
88 /****************************************************************************
89 * SERIALIZER
90 */
91 private static final XMLFormat XML = new XMLFormat(JSProfilingRule.class)
92 {
93 public void write(Object o, OutputElement xml)
94 throws XMLStreamException
95 {
96
97 try
98 {
99 JSProfilingRule g = (JSProfilingRule) o;
100 xml.setAttribute("id", g.id);
101 xml.setAttribute("standardRule", g.standardRule);
102 xml.add( g.description, "description",String.class);
103 xml.add(g.criterions);
104
105 } catch (Exception e)
106 {
107 e.printStackTrace();
108 }
109 }
110
111 public void read(InputElement xml, Object o)
112 {
113 try
114 {
115 JSProfilingRule g = (JSProfilingRule) o;
116 g.id = StringEscapeUtils.unescapeHtml(xml.getAttribute("id","unkwown_id"));
117 g.standardRule = xml.getAttribute("standardRule",false);
118 Object o1 = xml.get("description",String.class);
119 if (o1 instanceof String)
120 g.description = (String) o1;
121 while (xml.hasNext())
122 {
123 o1 = xml.getNext();
124
125 if (o1 instanceof JSRuleCriterions)
126 g.criterions = (JSRuleCriterions) o1;
127 }
128 } catch (Exception e)
129 {
130 e.printStackTrace();
131 }
132 }
133 };
134
135
136 /***
137 * @return Returns the criterions.
138 */
139 public JSRuleCriterions getCriterions()
140 {
141 return criterions;
142 }
143
144
145 /***
146 * @param criterions The criterions to set.
147 */
148 public void setCriterions(JSRuleCriterions criterions)
149 {
150 this.criterions = criterions;
151 }
152
153
154 }