@Override public JsonGenerator createGenerator(ObjectWriteContext writeCtxt, OutputStream out, JsonEncoding enc) throws IOException { // false -> we won't manage the stream unless explicitly directed to IOContext ioCtxt = _createContext(out, false, enc); if (enc == JsonEncoding.UTF8) { return _createUTF8Generator(writeCtxt, ioCtxt, _decorate(ioCtxt, out)); } return _createGenerator(writeCtxt, ioCtxt, _decorate(ioCtxt, _createWriter(ioCtxt, out, enc))); }
@Override public JsonParser createParser(ObjectReadContext readCtxt, Reader r) throws IOException { // false -> we do NOT own Reader (did not create it) IOContext ioCtxt = _createContext(r, false); return _createParser(readCtxt, ioCtxt, _decorate(ioCtxt, r)); }
@Override public JsonParser createParser(ObjectReadContext readCtxt, URL url) throws IOException { // true, since we create InputStream from URL IOContext ioCtxt = _createContext(url, true); return _createParser(readCtxt, ioCtxt, _decorate(ioCtxt, _optimizedStreamFromURL(url))); }
@Override public JsonGenerator createGenerator(ObjectWriteContext writeCtxt, Writer w) throws IOException { IOContext ioCtxt = _createContext(w, false); return _createGenerator(writeCtxt, ioCtxt, _decorate(ioCtxt, w)); }
@Override public JsonParser createParser(ObjectReadContext readCtxt, String content) throws IOException { final int strLen = content.length(); // Actually, let's use this for medium-sized content, up to 64kB chunk (32kb char) if ((_inputDecorator != null) || (strLen > 0x8000) || !canUseCharArrays()) { // easier to just wrap in a Reader than extend InputDecorator; or, if content // is too long for us to copy it over return createParser(readCtxt, new StringReader(content)); } IOContext ioCtxt = _createContext(content, true); char[] buf = ioCtxt.allocTokenBuffer(strLen); content.getChars(0, strLen, buf, 0); return _createParser(readCtxt, ioCtxt, buf, 0, strLen, true); }
@Override public JsonParser createParser(ObjectReadContext readCtxt, char[] content, int offset, int len) throws IOException { if (_inputDecorator != null) { // easier to just wrap in a Reader than extend InputDecorator return createParser(readCtxt, new CharArrayReader(content, offset, len)); } return _createParser(readCtxt, _createContext(content, true), content, offset, len, // important: buffer is NOT recyclable, as it's from caller false); }
@Override public JsonParser createParser(ObjectReadContext readCtxt, byte[] data, int offset, int len) throws IOException { IOContext ioCtxt = _createContext(data, true); if (_inputDecorator != null) { InputStream in = _inputDecorator.decorate(ioCtxt, data, offset, len); if (in != null) { return _createParser(readCtxt, ioCtxt, in); } } return _createParser(readCtxt, ioCtxt, data, offset, len); }
@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))); }
@Override public JsonParser createParser(ObjectReadContext readCtxt, InputStream in) throws IOException { IOContext ioCtxt = _createContext(in, false); return _createParser(readCtxt, ioCtxt, _decorate(ioCtxt, in)); }
@Override public JsonParser createParser(ObjectReadContext readCtxt, DataInput in) throws IOException { IOContext ioCtxt = _createContext(in, false); return _createParser(readCtxt, ioCtxt, _decorate(ioCtxt, in)); }
@Override public JsonParser createParser(ObjectReadContext readCtxt, File f) throws IOException { // true, since we create InputStream from File IOContext ioCtxt = _createContext(f, true); return _createParser(readCtxt, ioCtxt, _decorate(ioCtxt, new FileInputStream(f))); }