16
16
* JDK 1.5. Types are directly needed by JAXB, but may be unavailable on some
17
17
* limited platforms; hence separate out from basic deserializer factory.
18
18
*/
19
- public class CoreXMLDeserializers extends Deserializers .Base {
19
+ public class CoreXMLDeserializers extends Deserializers .Base
20
+ {
20
21
protected final static QName EMPTY_QNAME = QName .valueOf ("" );
21
22
22
23
/**
@@ -25,7 +26,6 @@ public class CoreXMLDeserializers extends Deserializers.Base {
25
26
* introspection) can be expensive we better reuse the instance.
26
27
*/
27
28
final static DatatypeFactory _dataTypeFactory ;
28
-
29
29
static {
30
30
try {
31
31
_dataTypeFactory = DatatypeFactory .newInstance ();
@@ -36,7 +36,8 @@ public class CoreXMLDeserializers extends Deserializers.Base {
36
36
37
37
@ Override
38
38
public JsonDeserializer <?> findBeanDeserializer (JavaType type ,
39
- DeserializationConfig config , BeanDescription beanDesc ) {
39
+ DeserializationConfig config , BeanDescription beanDesc )
40
+ {
40
41
Class <?> raw = type .getRawClass ();
41
42
if (raw == QName .class ) {
42
43
return new Std (raw , TYPE_QNAME );
@@ -76,7 +77,8 @@ public boolean hasDeserializerFor(DeserializationConfig config, Class<?> valueTy
76
77
*
77
78
* @since 2.4
78
79
*/
79
- public static class Std extends FromStringDeserializer <Object > {
80
+ public static class Std extends FromStringDeserializer <Object >
81
+ {
80
82
private static final long serialVersionUID = 1L ;
81
83
82
84
protected final int _kind ;
@@ -88,7 +90,8 @@ public Std(Class<?> raw, int kind) {
88
90
89
91
@ Override
90
92
public Object deserialize (JsonParser p , DeserializationContext ctxt )
91
- throws IOException {
93
+ throws IOException
94
+ {
92
95
// GregorianCalendar also allows integer value (timestamp),
93
96
// which needs separate handling
94
97
if (_kind == TYPE_G_CALENDAR ) {
@@ -105,7 +108,9 @@ public Object deserialize(JsonParser p, DeserializationContext ctxt)
105
108
return super .deserialize (p , ctxt );
106
109
}
107
110
108
- private QName _parseQNameObject (JsonParser p , DeserializationContext ctxt ) throws IOException {
111
+ private QName _parseQNameObject (JsonParser p , DeserializationContext ctxt )
112
+ throws IOException
113
+ {
109
114
JsonNode tree = ctxt .readTree (p );
110
115
111
116
if (!tree .has ("localPart" )) {
@@ -133,22 +138,24 @@ private QName _parseQNameObject(JsonParser p, DeserializationContext ctxt) throw
133
138
134
139
@ Override
135
140
protected Object _deserialize (String value , DeserializationContext ctxt )
136
- throws IOException {
141
+ throws IOException
142
+ {
137
143
switch (_kind ) {
138
- case TYPE_DURATION :
139
- return _dataTypeFactory .newDuration (value );
140
- case TYPE_QNAME :
141
- return QName .valueOf (value );
142
- case TYPE_G_CALENDAR :
143
- Date d ;
144
- try {
145
- d = _parseDate (value , ctxt );
146
- } catch (JsonMappingException e ) {
147
- // try to parse from native XML Schema 1.0 lexical representation String,
148
- // which includes time-only formats not handled by parseXMLGregorianCalendarFromJacksonFormat(...)
149
- return _dataTypeFactory .newXMLGregorianCalendar (value );
150
- }
151
- return _gregorianFromDate (ctxt , d );
144
+ case TYPE_DURATION :
145
+ return _dataTypeFactory .newDuration (value );
146
+ case TYPE_QNAME :
147
+ return QName .valueOf (value );
148
+ case TYPE_G_CALENDAR :
149
+ Date d ;
150
+ try {
151
+ d = _parseDate (value , ctxt );
152
+ }
153
+ catch (JsonMappingException e ) {
154
+ // try to parse from native XML Schema 1.0 lexical representation String,
155
+ // which includes time-only formats not handled by parseXMLGregorianCalendarFromJacksonFormat(...)
156
+ return _dataTypeFactory .newXMLGregorianCalendar (value );
157
+ }
158
+ return _gregorianFromDate (ctxt , d );
152
159
}
153
160
throw new IllegalStateException ();
154
161
}
@@ -162,7 +169,8 @@ protected Object _deserializeFromEmptyString(DeserializationContext ctxt) throws
162
169
}
163
170
164
171
protected XMLGregorianCalendar _gregorianFromDate (DeserializationContext ctxt ,
165
- Date d ) {
172
+ Date d )
173
+ {
166
174
if (d == null ) {
167
175
return null ;
168
176
}
@@ -174,6 +182,5 @@ protected XMLGregorianCalendar _gregorianFromDate(DeserializationContext ctxt,
174
182
}
175
183
return _dataTypeFactory .newXMLGregorianCalendar (calendar );
176
184
}
177
-
178
185
}
179
186
}
0 commit comments