1 | public class LongPropertyConverter implements Converter {↵ | | 1 | public class StringPropertyConverter implements Converter {↵
|
|
2 | private static final String ATT_NAME = "name"; // $NON-NLS-1$↵ | | 2 | private static final String ATT_NAME = "name"; // $NON-NLS-1$↵
|
|
3 | /**↵ | | 3 | /**↵
|
4 | * Returns the converter version; used to check for possible↵ | | 4 | * Returns the converter version; used to check for possible↵
|
5 | * incompatibilities↵ | | 5 | * incompatibilities↵
|
6 | */↵ | | 6 | */↵
|
7 | public static String getVersion() {↵ | | 7 | public static String getVersion() {↵
|
8 | return "$Revision: 493779 $"; // $NON-NLS-1$↵ | | 8 | return "$Revision: 493779 $"; // $NON-NLS-1$↵
|
9 | }↵ | | 9 | }↵
|
|
10 | /*↵ | | 10 | /*↵
|
11 | * (non-Javadoc)↵ | | 11 | * (non-Javadoc)↵
|
12 | * ↵ | | 12 | * ↵
|
13 | * @see com.thoughtworks.xstream.converters.Converter#canConvert(java.lang.Class)↵ | | 13 | * @see com.thoughtworks.xstream.converters.Converter#canConvert(java.lang.Class)↵
|
14 | */↵ | | 14 | */↵
|
15 | public boolean canConvert(Class arg0) {↵ | | 15 | public boolean canConvert(Class arg0) {↵
|
16 | return arg0.equals(LongProperty.class);↵ | | 16 | return StringProperty.class.equals(arg0);↵
|
17 | }↵ | | 17 | }↵
|
|
18 | /*↵ | | 18 | /*↵
|
19 | * (non-Javadoc)↵ | | 19 | * (non-Javadoc)↵
|
20 | * ↵ | | 20 | * ↵
|
21 | * @see com.thoughtworks.xstream.converters.Converter#marshal(java.lang.Object,↵ | | 21 | * @see com.thoughtworks.xstream.converters.Converter#marshal(java.lang.Object,↵
|
22 | * com.thoughtworks.xstream.io.HierarchicalStreamWriter,↵ | | 22 | * com.thoughtworks.xstream.io.HierarchicalStreamWriter,↵
|
23 | * com.thoughtworks.xstream.converters.MarshallingContext)↵ | | 23 | * com.thoughtworks.xstream.converters.MarshallingContext)↵
|
24 | */↵ | | 24 | */↵
|
25 | public void marshal(Object obj, HierarchicalStreamWriter writer, MarshallingContext arg2) {↵ | | 25 | public void marshal(Object obj, HierarchicalStreamWriter writer, MarshallingContext arg2) {↵
|
26 | LongProperty prop = (LongProperty) obj;↵ | | 26 | StringProperty prop = (StringProperty) obj;↵
|
27 | writer.addAttribute(ATT_NAME, ConversionHelp.encode(prop.getName()));↵ | | 27 | writer.addAttribute(ATT_NAME, ConversionHelp.encode(prop.getName()));↵
|
28 | writer.setValue(prop.getStringValue());↵ | | 28 | writer.setValue(ConversionHelp.encode(prop.getStringValue()));↵
|
29 | }↵ | | 29 | }↵
|
|
30 | /*↵ | | 30 | /*↵
|
31 | * (non-Javadoc)↵ | | 31 | * (non-Javadoc)↵
|
32 | * ↵ | | 32 | * ↵
|
33 | * @see com.thoughtworks.xstream.converters.Converter#unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader,↵ | | 33 | * @see com.thoughtworks.xstream.converters.Converter#unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader,↵
|
34 | * com.thoughtworks.xstream.converters.UnmarshallingContext)↵ | | 34 | * com.thoughtworks.xstream.converters.UnmarshallingContext)↵
|
35 | */↵ | | 35 | */↵
|
36 | public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext arg1) {↵ | | 36 | public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext arg1) {↵
|
37 | LongProperty prop = new LongProperty(ConversionHelp.decode(reader.getAttribute(ATT_NAME)), Long.parseLong↵ | | 37 | StringProperty prop = new StringProperty(ConversionHelp.decode(reader.getAttribute(ATT_NAME)), ConversionHelp↵
|
38 | (reader↵ | | 38 | .decode(reader↵
|
39 | .getValue()));↵ | | 39 | .getValue()));↵
|
40 | return prop;↵ | | 40 | return prop;↵
|
41 | | | 41 |
|