mirror of
https://github.com/Fishwaldo/rundeck-api-java-client.git
synced 2025-07-10 06:58:47 +00:00
PRoduces xml stream from a document
This commit is contained in:
parent
9ebd63e953
commit
c3b1cbc39f
1 changed files with 38 additions and 0 deletions
|
@ -0,0 +1,38 @@
|
|||
package org.rundeck.api.util;
|
||||
|
||||
import org.apache.http.entity.ContentProducer;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.io.OutputFormat;
|
||||
import org.dom4j.io.XMLWriter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* DocumentContentProducer writes XML document to a stream
|
||||
*
|
||||
* @author greg
|
||||
* @since 2014-02-27
|
||||
*/
|
||||
public class DocumentContentProducer implements ContentProducer {
|
||||
Document document;
|
||||
private OutputFormat format;
|
||||
|
||||
public DocumentContentProducer(final Document document, final OutputFormat format) {
|
||||
this.document = document;
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public DocumentContentProducer(final Document document) {
|
||||
this.document = document;
|
||||
format = new OutputFormat("", false, "UTF-8");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(final OutputStream outstream) throws IOException {
|
||||
|
||||
final XMLWriter xmlWriter = new XMLWriter(outstream, format);
|
||||
xmlWriter.write(document);
|
||||
xmlWriter.flush();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue