Skip to content

Commit

Permalink
Update XmlMapper.java
Browse files Browse the repository at this point in the history
Update XmlFactory.java

Update XmlFactory.java
  • Loading branch information
pjfanning committed May 1, 2023
1 parent 006f092 commit 96ee4e9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
18 changes: 15 additions & 3 deletions src/main/java/com/fasterxml/jackson/dataformat/xml/XmlFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,21 @@ public ToXmlGenerator createGenerator(OutputStream out, JsonEncoding enc) throws
}

/**
* @param out
* @param encoding
* @return
* Method for constructing a {@link ToXmlGenerator} for writing XML content
* using specified output stream.
* Encoding to use must be specified.
*<p>
* Underlying stream <b>is NOT owned</b> by the generator constructed,
* so that generator will NOT close the output stream when
* {@link ToXmlGenerator#close} is called (unless auto-closing
* feature,
* {@link com.fasterxml.jackson.core.JsonGenerator.Feature#AUTO_CLOSE_TARGET}
* is enabled).
* Using application needs to close it explicitly if this is the case.
*
* @param out OutputStream to use for writing JSON content
* @param encoding Character encoding to use
* @return a {@link ToXmlGenerator} instance
* @throws IOException
* @since 2.16
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ public void writeValue(XMLStreamWriter w0, Object value) throws IOException {
* Method that can be used to serialize any Java value as
* a byte array.
*
* @param value value to write as XML bytes
* @param value value to serialize as XML bytes
* @param encoding character encoding for the XML output
* @return byte array representing the XML output
* @throws JsonProcessingException
Expand All @@ -425,9 +425,9 @@ public byte[] writeValueAsBytes(Object value, String encoding) throws JsonProces
* Method that can be used to serialize any Java value as
* XML output, written to File provided.
*
* @param resultFile
* @param value
* @param encoding
* @param resultFile the file to write to
* @param value the value to serialize
* @param encoding character encoding for the XML output
* @throws IOException
* @throws StreamWriteException
* @throws DatabindException
Expand Down Expand Up @@ -458,14 +458,14 @@ public void writeValue(OutputStream out, Object value, String encoding)
_writeValueAndClose(createGenerator(out, encoding), value);
}

private JsonGenerator createGenerator(OutputStream out, String encoding) throws IOException {
protected final JsonGenerator createGenerator(OutputStream out, String encoding) throws IOException {
this._assertNotNull("out", out);
JsonGenerator g = ((XmlFactory) _jsonFactory).createGenerator(out, encoding);
this._serializationConfig.initialize(g);
return g;
}

private JsonGenerator createGenerator(File outputFile, String encoding) throws IOException {
protected final JsonGenerator createGenerator(File outputFile, String encoding) throws IOException {
_assertNotNull("outputFile", outputFile);
JsonGenerator g = ((XmlFactory) _jsonFactory).createGenerator(
new FileOutputStream(outputFile), encoding);
Expand Down

0 comments on commit 96ee4e9

Please sign in to comment.