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;
}
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();
}
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();
}
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();
}
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();
}
Aggregations