1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.jetspeed.serializer.objects;
19
20 import javolution.xml.XMLFormat;
21 import javolution.xml.stream.XMLStreamException;
22
23 import org.apache.commons.lang.StringEscapeUtils;
24
25 public class JSNVPElement
26 {
27
28
29 private String key;
30 private String value;
31 public JSNVPElement() {};
32 public JSNVPElement(String key, String value)
33 {
34 this.key = key;
35 this.value = value;
36 }
37
38 private static final XMLFormat XML = new XMLFormat(JSNVPElement.class)
39 {
40 public boolean isReferencable() {
41 return false;
42 }
43 public void write(Object o, OutputElement xml)
44 throws XMLStreamException
45 {
46
47 xml.add(((JSNVPElement)o).key,"name",String.class);
48 xml.add(((JSNVPElement)o).value,"value",String.class);
49 }
50 public void read(InputElement xml, Object o)
51 {
52 try
53 {
54 JSNVPElement g = (JSNVPElement) o;
55 g.key = StringEscapeUtils.unescapeHtml((String)xml.get("name", String.class));
56 g.value = StringEscapeUtils.unescapeHtml((String)xml.get("value", String.class));
57 } catch (Exception e)
58 {
59 e.printStackTrace();
60 }
61 }
62 };
63 public String getKey()
64 {
65 return key;
66 }
67 public void setKey(String key)
68 {
69 this.key = key;
70 }
71 public String getValue()
72 {
73 return value;
74 }
75 public void setValue(String value)
76 {
77 this.value = value;
78 }
79 }
80
81