Search in sources :

Example 1 with INodeBuilder

use of nl.nn.adapterframework.stream.document.INodeBuilder in project iaf by ibissource.

the class StrictJsonDocumentWriter method writeStartObject.

@Override
public void writeStartObject() {
    if (state != State.INITIAL && state != State.VALUE) {
        throw new BsonInvalidOperationException("Invalid state " + state);
    }
    try {
        INodeBuilder nodeBuilder = context.contextType == JsonContextType.ARRAY ? ((IArrayBuilder) stack.peek()).addElement() : (INodeBuilder) stack.peek();
        stack.push((nodeBuilder).startObject());
    } catch (SAXException e) {
        throwBSONException(e);
    }
    context = new StrictJsonContext(context, JsonContextType.DOCUMENT, settings.getIndentCharacters());
    state = State.NAME;
}
Also used : BsonInvalidOperationException(org.bson.BsonInvalidOperationException) INodeBuilder(nl.nn.adapterframework.stream.document.INodeBuilder) SAXException(org.xml.sax.SAXException)

Example 2 with INodeBuilder

use of nl.nn.adapterframework.stream.document.INodeBuilder in project iaf by ibissource.

the class StrictJsonDocumentWriter method writeBoolean.

@Override
public void writeBoolean(final boolean value) {
    checkState(State.VALUE);
    try (INodeBuilder nodeBuilder = context.contextType == JsonContextType.ARRAY ? ((IArrayBuilder) stack.peek()).addElement() : (INodeBuilder) stack.pop()) {
        nodeBuilder.setValue(value ? Boolean.TRUE : Boolean.FALSE);
    } catch (SAXException e) {
        throwBSONException(e);
    }
    setNextState();
}
Also used : INodeBuilder(nl.nn.adapterframework.stream.document.INodeBuilder) SAXException(org.xml.sax.SAXException)

Example 3 with INodeBuilder

use of nl.nn.adapterframework.stream.document.INodeBuilder in project iaf by ibissource.

the class StrictJsonDocumentWriter method writeNull.

@Override
public void writeNull() {
    checkState(State.VALUE);
    try {
        try (INodeBuilder nodeBuilder = context.contextType == JsonContextType.ARRAY ? ((IArrayBuilder) stack.peek()).addElement() : (INodeBuilder) stack.pop()) {
            nodeBuilder.setValue(null);
        }
    } catch (SAXException e) {
        throwBSONException(e);
    }
    setNextState();
}
Also used : INodeBuilder(nl.nn.adapterframework.stream.document.INodeBuilder) SAXException(org.xml.sax.SAXException)

Example 4 with INodeBuilder

use of nl.nn.adapterframework.stream.document.INodeBuilder in project iaf by ibissource.

the class StrictJsonDocumentWriter method writeString.

@Override
public void writeString(final String value) {
    notNull("value", value);
    checkState(State.VALUE);
    try {
        try (INodeBuilder nodeBuilder = context.contextType == JsonContextType.ARRAY ? ((IArrayBuilder) stack.peek()).addElement() : (INodeBuilder) stack.pop()) {
            nodeBuilder.setValue(value);
        }
    } catch (SAXException e) {
        throwBSONException(e);
    }
    setNextState();
}
Also used : INodeBuilder(nl.nn.adapterframework.stream.document.INodeBuilder) SAXException(org.xml.sax.SAXException)

Example 5 with INodeBuilder

use of nl.nn.adapterframework.stream.document.INodeBuilder in project iaf by ibissource.

the class StrictJsonDocumentWriter method writeNumber.

@Override
public void writeNumber(final String value) {
    notNull("value", value);
    checkState(State.VALUE);
    try {
        try (INodeBuilder nodeBuilder = context.contextType == JsonContextType.ARRAY ? ((IArrayBuilder) stack.peek()).addElement() : (INodeBuilder) stack.pop()) {
            nodeBuilder.setValue(Long.parseLong(value));
        }
    } catch (SAXException e) {
        throwBSONException(e);
    }
    setNextState();
}
Also used : INodeBuilder(nl.nn.adapterframework.stream.document.INodeBuilder) SAXException(org.xml.sax.SAXException)

Aggregations

INodeBuilder (nl.nn.adapterframework.stream.document.INodeBuilder)7 SAXException (org.xml.sax.SAXException)7 IOException (java.io.IOException)1 Writer (java.io.Writer)1 NamingException (javax.naming.NamingException)1 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)1 ParameterException (nl.nn.adapterframework.core.ParameterException)1 SenderException (nl.nn.adapterframework.core.SenderException)1 TimeoutException (nl.nn.adapterframework.core.TimeoutException)1 StreamingException (nl.nn.adapterframework.stream.StreamingException)1 ArrayBuilder (nl.nn.adapterframework.stream.document.ArrayBuilder)1 BsonInvalidOperationException (org.bson.BsonInvalidOperationException)1 Document (org.bson.Document)1 DocumentCodec (org.bson.codecs.DocumentCodec)1 JsonWriterSettings (org.bson.json.JsonWriterSettings)1