File tree 4 files changed +50
-7
lines changed
main/java/com/fasterxml/jackson/dataformat/xml/deser
test/java/com/fasterxml/jackson/dataformat/xml
4 files changed +50
-7
lines changed Original file line number Diff line number Diff line change 14
14
* abstract out all irrelevant details, and to expose equivalent of flat token
15
15
* stream with no "fluff" tokens (comments, processing instructions, mixed
16
16
* content) all of which is just to simplify
17
- * actual higher-level conversion to JSON tokens
17
+ * actual higher-level conversion to JSON tokens.
18
+ *<p>
19
+ * Beyond initial idea there are also couple of other detours like ability
20
+ * to "replay" some tokens, add virtual wrappers (ironically to support "unwrapped"
21
+ * array values), and to unroll "Objects" into String values in some cases.
18
22
*/
19
23
public class XmlTokenStream
20
24
{
@@ -146,7 +150,7 @@ protected void setFormatFeatures(int f) {
146
150
147
151
// DEBUGGING
148
152
/*
149
- public int next() throws IOException
153
+ public int next() throws XMLStreamException
150
154
{
151
155
int n = next0();
152
156
switch (n) {
@@ -270,6 +274,10 @@ protected void skipAttributes()
270
274
}
271
275
}
272
276
277
+ /**
278
+ * Helper method called by XML String deserializer to concatenate textual contents
279
+ * contained in logical "Object": mostly just to skip attribute values.
280
+ */
273
281
protected String convertToString () throws XMLStreamException
274
282
{
275
283
// only applicable to cases where START_OBJECT was induced by attributes
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ public boolean equals(Object o)
104
104
return true ;
105
105
}
106
106
}
107
-
107
+
108
108
protected static class StringBean
109
109
{
110
110
public String text ;
@@ -118,7 +118,7 @@ public String toString() {
118
118
return "\" " +text +"\" " ;
119
119
}
120
120
}
121
-
121
+
122
122
/**
123
123
* Simple wrapper around String type, usually to test value
124
124
* conversions or wrapping
@@ -131,7 +131,7 @@ public StringWrapper(String value) {
131
131
str = value ;
132
132
}
133
133
}
134
-
134
+
135
135
protected static class IntWrapper {
136
136
public int i ;
137
137
@@ -141,7 +141,6 @@ public IntWrapper(int value) {
141
141
}
142
142
}
143
143
144
- // since 2.9.6
145
144
public static class Point {
146
145
public int x , y ;
147
146
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ static class Issue167Bean {
27
27
/**********************************************************
28
28
*/
29
29
30
- private final XmlMapper MAPPER = new XmlMapper ();
30
+ private final XmlMapper MAPPER = newMapper ();
31
31
32
32
public void testSimpleStringElement () throws Exception
33
33
{
Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .dataformat .xml .failing ;
2
+
3
+ import com .fasterxml .jackson .dataformat .xml .XmlMapper ;
4
+ import com .fasterxml .jackson .dataformat .xml .XmlTestBase ;
5
+
6
+ public class XsiNil354Test extends XmlTestBase
7
+ {
8
+ protected static class DoubleWrapper {
9
+ public Double d ;
10
+
11
+ public DoubleWrapper () { }
12
+ public DoubleWrapper (Double value ) {
13
+ d = value ;
14
+ }
15
+ }
16
+
17
+ private final XmlMapper MAPPER = newMapper ();
18
+
19
+ public void testWithDoubleAsNull () throws Exception
20
+ {
21
+ DoubleWrapper bean = MAPPER .readValue (
22
+ "<DoubleWrapper xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" ><d xsi:nil='true'></DoubleWrapper>" ,
23
+ DoubleWrapper .class );
24
+ assertNotNull (bean );
25
+ assertNull (bean .d );
26
+ }
27
+
28
+ public void testWithDoubleAsNonNull () throws Exception
29
+ {
30
+ DoubleWrapper bean = MAPPER .readValue (
31
+ "<DoubleWrapper xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" ><d xsi:nil='false'>0.25</DoubleWrapper>" ,
32
+ DoubleWrapper .class );
33
+ assertNotNull (bean );
34
+ assertEquals (Double .valueOf (0.25 ), bean .d );
35
+ }
36
+ }
You can’t perform that action at this time.
0 commit comments