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 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);
}
use of com.fasterxml.jackson.core.io.IOContext in project bson4jackson by michel-kraemer.
the class BsonFactory method createGenerator.
@Override
public BsonGenerator createGenerator(File f, JsonEncoding enc) throws IOException {
OutputStream out = new FileOutputStream(f);
IOContext ctxt = _createContext(out, true);
ctxt.setEncoding(enc);
if (enc == JsonEncoding.UTF8 && _outputDecorator != null) {
out = _outputDecorator.decorate(ctxt, out);
}
return createGenerator(out, enc);
}
Aggregations