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