28
28
import java .io .OutputStream ;
29
29
30
30
import org .restlet .data .MediaType ;
31
+ import org .restlet .engine .Edition ;
31
32
import org .restlet .ext .jackson .internal .XmlFactoryProvider ;
32
33
import org .restlet .representation .OutputRepresentation ;
33
34
import org .restlet .representation .Representation ;
62
63
* The type to wrap.
63
64
*/
64
65
public class JacksonRepresentation <T > extends OutputRepresentation {
65
- // [ifndef android] member
66
+
66
67
/**
67
68
* True for expanding entity references when parsing XML representations.
68
69
* Default value provided by system property
@@ -71,7 +72,6 @@ public class JacksonRepresentation<T> extends OutputRepresentation {
71
72
public final static boolean XML_EXPANDING_ENTITY_REFS = Boolean
72
73
.getBoolean ("org.restlet.ext.xml.expandingEntityRefs" );
73
74
74
- // [ifndef android] member
75
75
/**
76
76
* True for validating DTD documents when parsing XML representations.
77
77
* Default value provided by system property
@@ -83,7 +83,6 @@ public class JacksonRepresentation<T> extends OutputRepresentation {
83
83
/** The modifiable Jackson CSV schema. */
84
84
private CsvSchema csvSchema ;
85
85
86
- // [ifndef android] member
87
86
/**
88
87
* Specifies that the parser will expand entity reference nodes. By default
89
88
* the value of this is set to false.
@@ -108,7 +107,6 @@ public class JacksonRepresentation<T> extends OutputRepresentation {
108
107
/** The representation to parse. */
109
108
private volatile Representation representation ;
110
109
111
- // [ifndef android] member
112
110
/**
113
111
* Indicates the desire for validating this type of XML representations
114
112
* against a DTD. Note that for XML schema or Relax NG validation, use the
@@ -137,10 +135,10 @@ public JacksonRepresentation(MediaType mediaType, T object) {
137
135
this .objectReader = null ;
138
136
this .objectWriter = null ;
139
137
this .csvSchema = null ;
140
- // [ifndef android] instruction
141
- this .expandingEntityRefs = XML_EXPANDING_ENTITY_REFS ;
142
- // [ifndef android] instruction
143
- this . validatingDtd = XML_VALIDATING_DTD ;
138
+ if ( Edition . ANDROID . isNotCurrentEdition ()) {
139
+ this .expandingEntityRefs = XML_EXPANDING_ENTITY_REFS ;
140
+ this . validatingDtd = XML_VALIDATING_DTD ;
141
+ }
144
142
}
145
143
146
144
/**
@@ -161,10 +159,10 @@ public JacksonRepresentation(Representation representation,
161
159
this .objectReader = null ;
162
160
this .objectWriter = null ;
163
161
this .csvSchema = null ;
164
- // [ifndef android] instruction
165
- this .expandingEntityRefs = XML_EXPANDING_ENTITY_REFS ;
166
- // [ifndef android] instruction
167
- this . validatingDtd = XML_VALIDATING_DTD ;
162
+ if ( Edition . ANDROID . isNotCurrentEdition ()) {
163
+ this .expandingEntityRefs = XML_EXPANDING_ENTITY_REFS ;
164
+ this . validatingDtd = XML_VALIDATING_DTD ;
165
+ }
168
166
}
169
167
170
168
/**
@@ -207,9 +205,9 @@ protected ObjectMapper createObjectMapper() {
207
205
SmileFactory smileFactory = new SmileFactory ();
208
206
smileFactory .configure (Feature .AUTO_CLOSE_TARGET , false );
209
207
result = new ObjectMapper (smileFactory );
210
- // [ifndef android]
211
- } else if (MediaType .APPLICATION_XML .isCompatible (getMediaType ())
212
- || MediaType .TEXT_XML .isCompatible (getMediaType ())) {
208
+
209
+ } else if (Edition . ANDROID . isNotCurrentEdition () && ( MediaType .APPLICATION_XML .isCompatible (getMediaType ())
210
+ || MediaType .TEXT_XML .isCompatible (getMediaType ()))) {
213
211
javax .xml .stream .XMLInputFactory xif = XmlFactoryProvider .newInputFactory ();
214
212
xif .setProperty (
215
213
javax .xml .stream .XMLInputFactory .IS_SUPPORTING_EXTERNAL_ENTITIES ,
@@ -222,7 +220,7 @@ protected ObjectMapper createObjectMapper() {
222
220
XmlFactory xmlFactory = new XmlFactory (xif , xof );
223
221
xmlFactory .configure (Feature .AUTO_CLOSE_TARGET , false );
224
222
result = new XmlMapper (xmlFactory );
225
- // [enddef]
223
+
226
224
} else if (MediaType .APPLICATION_YAML .isCompatible (getMediaType ())
227
225
|| MediaType .TEXT_YAML .isCompatible (getMediaType ())) {
228
226
YAMLFactory yamlFactory = new YAMLFactory ();
@@ -365,25 +363,30 @@ public ObjectWriter getObjectWriter() {
365
363
return this .objectWriter ;
366
364
}
367
365
368
- // [ifndef android] method
369
366
/**
370
- * Indicates if the parser will expand entity reference nodes. By default
367
+ * Indicates if the parser will expand entity reference nodes. By default,
371
368
* the value of this is set to true.
372
369
*
373
370
* @return True if the parser will expand entity reference nodes.
374
371
*/
375
372
public boolean isExpandingEntityRefs () {
376
- return expandingEntityRefs ;
373
+ if (Edition .ANDROID .isCurrentEdition ()) {
374
+ throw new RuntimeException (); // TODO right thing to do?
375
+ }
376
+ return expandingEntityRefs ;
377
377
}
378
378
379
- // [ifndef android] method
380
379
/**
381
380
* Indicates the desire for validating this type of XML representations
382
381
* against an XML schema if one is referenced within the contents.
383
382
*
384
383
* @return True if the schema-based validation is enabled.
385
384
*/
386
385
public boolean isValidatingDtd () {
386
+ if (Edition .ANDROID .isCurrentEdition ()) {
387
+ throw new RuntimeException (); // TODO right thing to do?
388
+ }
389
+
387
390
return validatingDtd ;
388
391
}
389
392
@@ -397,7 +400,6 @@ public void setCsvSchema(CsvSchema csvSchema) {
397
400
this .csvSchema = csvSchema ;
398
401
}
399
402
400
- // [ifndef android] method
401
403
/**
402
404
* Indicates if the parser will expand entity reference nodes. By default
403
405
* the value of this is set to true.
@@ -406,6 +408,10 @@ public void setCsvSchema(CsvSchema csvSchema) {
406
408
* True if the parser will expand entity reference nodes.
407
409
*/
408
410
public void setExpandingEntityRefs (boolean expandEntityRefs ) {
411
+ if (Edition .ANDROID .isCurrentEdition ()) {
412
+ throw new RuntimeException (); // TODO right thing to do?
413
+ }
414
+
409
415
this .expandingEntityRefs = expandEntityRefs ;
410
416
}
411
417
@@ -459,7 +465,6 @@ public void setObjectWriter(ObjectWriter objectWriter) {
459
465
this .objectWriter = objectWriter ;
460
466
}
461
467
462
- // [ifndef android] method
463
468
/**
464
469
* Indicates the desire for validating this type of XML representations
465
470
* against an XML schema if one is referenced within the contents.
@@ -468,6 +473,10 @@ public void setObjectWriter(ObjectWriter objectWriter) {
468
473
* The new validation flag to set.
469
474
*/
470
475
public void setValidatingDtd (boolean validating ) {
476
+ if (Edition .ANDROID .isCurrentEdition ()) {
477
+ throw new RuntimeException (); // TODO right thing to do?
478
+ }
479
+
471
480
this .validatingDtd = validating ;
472
481
}
473
482
0 commit comments