use of com.fasterxml.jackson.core.io.IOContext in project jackson-core by FasterXML.
the class TextualTSFactory method createGenerator.
@Override
public JsonGenerator createGenerator(ObjectWriteContext writeCtxt, File f, JsonEncoding enc) throws IOException {
OutputStream out = new FileOutputStream(f);
IOContext ioCtxt = _createContext(f, true, enc);
if (enc == JsonEncoding.UTF8) {
return _createUTF8Generator(writeCtxt, ioCtxt, _decorate(ioCtxt, out));
}
return _createGenerator(writeCtxt, ioCtxt, _decorate(ioCtxt, _createWriter(ioCtxt, out, enc)));
}
use of com.fasterxml.jackson.core.io.IOContext in project jackson-core by FasterXML.
the class JsonParserSequenceTest method testClose.
@Test
public void testClose() throws IOException {
IOContext ioContext = new IOContext(new BufferRecycler(), this, true);
ReaderBasedJsonParser readerBasedJsonParser = new ReaderBasedJsonParser(ObjectReadContext.empty(), ioContext, 2, null, CharsToNameCanonicalizer.createRoot());
JsonParserSequence jsonParserSequence = JsonParserSequence.createFlattened(true, readerBasedJsonParser, readerBasedJsonParser);
assertFalse(jsonParserSequence.isClosed());
jsonParserSequence.close();
assertTrue(jsonParserSequence.isClosed());
assertNull(jsonParserSequence.nextToken());
}
use of com.fasterxml.jackson.core.io.IOContext in project jackson-core by FasterXML.
the class JsonParserSequenceTest method testSkipChildren.
@Test
public void testSkipChildren() throws IOException {
JsonParser[] jsonParserArray = new JsonParser[3];
IOContext ioContext = new IOContext(new BufferRecycler(), jsonParserArray, true);
byte[] byteArray = new byte[8];
InputStream byteArrayInputStream = new ByteArrayInputStream(byteArray, 0, (byte) 58);
UTF8StreamJsonParser uTF8StreamJsonParser = new UTF8StreamJsonParser(ObjectReadContext.empty(), ioContext, 0, byteArrayInputStream, ByteQuadsCanonicalizer.createRoot(), byteArray, -1, (byte) 9, true);
JsonParserDelegate jsonParserDelegate = new JsonParserDelegate(jsonParserArray[0]);
JsonParserSequence jsonParserSequence = JsonParserSequence.createFlattened(true, uTF8StreamJsonParser, jsonParserDelegate);
JsonParserSequence jsonParserSequenceTwo = (JsonParserSequence) jsonParserSequence.skipChildren();
assertEquals(2, jsonParserSequenceTwo.containedParsersCount());
}
use of com.fasterxml.jackson.core.io.IOContext in project neo4j by neo4j.
the class StreamingJsonFormat method createJsonFactory.
private static JsonFactory createJsonFactory() {
final ObjectMapper objectMapper = new ObjectMapper();
objectMapper.disable(FLUSH_AFTER_WRITE_VALUE);
JsonFactory factory = new JsonFactory(objectMapper) {
@Override
protected JsonGenerator _createUTF8Generator(OutputStream out, IOContext ctxt) {
final int bufferSize = 1024 * 8;
UTF8JsonGenerator gen = new UTF8JsonGenerator(ctxt, _generatorFeatures, _objectCodec, out, DEFAULT_QUOTE_CHAR, new byte[bufferSize], 0, true);
if (_characterEscapes != null) {
gen.setCharacterEscapes(_characterEscapes);
}
return gen;
}
};
factory.disable(JsonGenerator.Feature.FLUSH_PASSED_TO_STREAM);
return factory;
}
use of com.fasterxml.jackson.core.io.IOContext in project bson4jackson by michel-kraemer.
the class BsonFactory method createParser.
@Override
public BsonParser createParser(URL url) throws IOException {
IOContext ctxt = _createContext(url, true);
InputStream in = _optimizedStreamFromURL(url);
if (_inputDecorator != null) {
in = _inputDecorator.decorate(ctxt, in);
}
return _createParser(in, ctxt);
}
Aggregations