use of nl.nn.adapterframework.stream.json.JsonWriter in project iaf by ibissource.
the class MessageOutputStream method captureBinaryStream.
@SuppressWarnings("resource")
public void captureBinaryStream(OutputStream outputStream, int maxSize) {
log.debug("creating capture of " + ClassUtils.nameOf(requestStream));
closeOnClose(outputStream);
if (requestStream instanceof OutputStream) {
requestStream = StreamUtil.captureOutputStream((OutputStream) requestStream, outputStream, maxSize);
return;
}
if (requestStream instanceof ContentHandler) {
requestStream = new XmlTee((ContentHandler) requestStream, new PrettyPrintFilter(new XmlWriter(StreamUtil.limitSize(outputStream, maxSize))));
return;
}
if (requestStream instanceof JsonEventHandler) {
requestStream = new JsonTee((JsonEventHandler) requestStream, new JsonWriter(StreamUtil.limitSize(outputStream, maxSize)));
return;
}
if (requestStream instanceof Writer) {
requestStream = StreamUtil.captureWriter((Writer) requestStream, new OutputStreamWriter(outputStream, StreamUtil.DEFAULT_CHARSET), maxSize);
return;
}
log.warn("captureBinaryStream() called before stream is installed.");
}
use of nl.nn.adapterframework.stream.json.JsonWriter in project iaf by ibissource.
the class MessageOutputStream method captureCharacterStream.
@SuppressWarnings("resource")
public void captureCharacterStream(Writer writer, int maxSize) {
log.debug("creating capture of " + ClassUtils.nameOf(requestStream));
closeOnClose(writer);
if (requestStream instanceof Writer) {
requestStream = StreamUtil.captureWriter((Writer) requestStream, writer, maxSize);
return;
}
if (requestStream instanceof ContentHandler) {
requestStream = new XmlTee((ContentHandler) requestStream, new PrettyPrintFilter(new XmlWriter(StreamUtil.limitSize(writer, maxSize))));
return;
}
if (requestStream instanceof JsonEventHandler) {
requestStream = new JsonTee((JsonEventHandler) requestStream, new JsonWriter(StreamUtil.limitSize(writer, maxSize)));
return;
}
if (requestStream instanceof OutputStream) {
requestStream = StreamUtil.captureOutputStream((OutputStream) requestStream, new WriterOutputStream(writer, StreamUtil.DEFAULT_CHARSET), maxSize);
return;
}
log.warn("captureCharacterStream() called before stream is installed.");
}
use of nl.nn.adapterframework.stream.json.JsonWriter in project iaf by ibissource.
the class DocumentBuilderTest method testJsonDocumentBuilder.
@Test
public void testJsonDocumentBuilder() throws SAXException {
String expected = expectedJson;
JsonWriter writer = new JsonWriter();
try (IDocumentBuilder root = new JsonDocumentBuilder(writer)) {
buildDocument(root);
}
// MatchUtils.assertJsonEqual("", expected, root.getRoot().toString());
assertEquals(expected, writer.toString());
}
Aggregations