Skip to content

Commit 96ee4e9

Browse files
committed
Update XmlMapper.java
Update XmlFactory.java Update XmlFactory.java
1 parent 006f092 commit 96ee4e9

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

src/main/java/com/fasterxml/jackson/dataformat/xml/XmlFactory.java

+15-3
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,21 @@ public ToXmlGenerator createGenerator(OutputStream out, JsonEncoding enc) throws
519519
}
520520

521521
/**
522-
* @param out
523-
* @param encoding
524-
* @return
522+
* Method for constructing a {@link ToXmlGenerator} for writing XML content
523+
* using specified output stream.
524+
* Encoding to use must be specified.
525+
*<p>
526+
* Underlying stream <b>is NOT owned</b> by the generator constructed,
527+
* so that generator will NOT close the output stream when
528+
* {@link ToXmlGenerator#close} is called (unless auto-closing
529+
* feature,
530+
* {@link com.fasterxml.jackson.core.JsonGenerator.Feature#AUTO_CLOSE_TARGET}
531+
* is enabled).
532+
* Using application needs to close it explicitly if this is the case.
533+
*
534+
* @param out OutputStream to use for writing JSON content
535+
* @param encoding Character encoding to use
536+
* @return a {@link ToXmlGenerator} instance
525537
* @throws IOException
526538
* @since 2.16
527539
*/

src/main/java/com/fasterxml/jackson/dataformat/xml/XmlMapper.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ public void writeValue(XMLStreamWriter w0, Object value) throws IOException {
402402
* Method that can be used to serialize any Java value as
403403
* a byte array.
404404
*
405-
* @param value value to write as XML bytes
405+
* @param value value to serialize as XML bytes
406406
* @param encoding character encoding for the XML output
407407
* @return byte array representing the XML output
408408
* @throws JsonProcessingException
@@ -425,9 +425,9 @@ public byte[] writeValueAsBytes(Object value, String encoding) throws JsonProces
425425
* Method that can be used to serialize any Java value as
426426
* XML output, written to File provided.
427427
*
428-
* @param resultFile
429-
* @param value
430-
* @param encoding
428+
* @param resultFile the file to write to
429+
* @param value the value to serialize
430+
* @param encoding character encoding for the XML output
431431
* @throws IOException
432432
* @throws StreamWriteException
433433
* @throws DatabindException
@@ -458,14 +458,14 @@ public void writeValue(OutputStream out, Object value, String encoding)
458458
_writeValueAndClose(createGenerator(out, encoding), value);
459459
}
460460

461-
private JsonGenerator createGenerator(OutputStream out, String encoding) throws IOException {
461+
protected final JsonGenerator createGenerator(OutputStream out, String encoding) throws IOException {
462462
this._assertNotNull("out", out);
463463
JsonGenerator g = ((XmlFactory) _jsonFactory).createGenerator(out, encoding);
464464
this._serializationConfig.initialize(g);
465465
return g;
466466
}
467467

468-
private JsonGenerator createGenerator(File outputFile, String encoding) throws IOException {
468+
protected final JsonGenerator createGenerator(File outputFile, String encoding) throws IOException {
469469
_assertNotNull("outputFile", outputFile);
470470
JsonGenerator g = ((XmlFactory) _jsonFactory).createGenerator(
471471
new FileOutputStream(outputFile), encoding);

0 commit comments

Comments
 (0)