/** * Optional factory method, expected to be overridden * * @since 2.8 */ protected JsonParser _createParser(DataInput input, IOContext ctxt) throws IOException { // 13-May-2016, tatu: Need to take care not to accidentally create JSON parser for // non-JSON input. _requireJSONFactory("InputData source not (yet?) support for this format (%s)"); // Also: while we can't do full bootstrapping (due to read-ahead limitations), should // at least handle possible UTF-8 BOM int firstByte = ByteSourceJsonBootstrapper.skipUTF8BOM(input); ByteQuadsCanonicalizer can = _byteSymbolCanonicalizer.makeChild(_factoryFeatures); return new UTF8DataInputJsonParser(ctxt, _parserFeatures, input, _objectCodec, can, firstByte); }
/** * Optional method for constructing parser for non-blocking parsing * via {@link com.fasterxml.jackson.core.async.ByteArrayFeeder} * interface (accessed using {@link JsonParser#getNonBlockingInputFeeder()} * from constructed instance). *<p> * If this factory does not support non-blocking parsing (either at all, * or from byte array), * will throw {@link UnsupportedOperationException} * * @since 2.9 */ public JsonParser createNonBlockingByteArrayParser() throws IOException { // 17-May-2017, tatu: Need to take care not to accidentally create JSON parser // for non-JSON input: _requireJSONFactory("Non-blocking source not (yet?) support for this format (%s)"); IOContext ctxt = _createNonBlockingContext(null); ByteQuadsCanonicalizer can = _byteSymbolCanonicalizer.makeChild(_factoryFeatures); return new NonBlockingJsonParser(ctxt, _parserFeatures, can); }
@Override public JsonParser createNonBlockingByteArrayParser(ObjectReadContext readCtxt) throws IOException { IOContext ioCtxt = _createNonBlockingContext(null); ByteQuadsCanonicalizer can = _byteSymbolCanonicalizer.makeChild(_factoryFeatures); return new NonBlockingJsonParser(readCtxt, ioCtxt, readCtxt.getStreamReadFeatures(_streamReadFeatures), readCtxt.getFormatReadFeatures(_formatReadFeatures), can); }
@Override protected JsonParser _createParser(ObjectReadContext readCtxt, IOContext ioCtxt, DataInput input) throws IOException { // Also: while we can't do full bootstrapping (due to read-ahead limitations), should // at least handle possible UTF-8 BOM int firstByte = ByteSourceJsonBootstrapper.skipUTF8BOM(input); ByteQuadsCanonicalizer can = _byteSymbolCanonicalizer.makeChild(_factoryFeatures); return new UTF8DataInputJsonParser(readCtxt, ioCtxt, readCtxt.getStreamReadFeatures(_streamReadFeatures), readCtxt.getFormatReadFeatures(_formatReadFeatures), input, can, firstByte); }
/** * Creates a {@link UTF8StreamJsonParser} from the inputstream with the supplied buf {@code inBuffer} to use. */ static UTF8StreamJsonParser newJsonParser(InputStream in, byte[] buf, int offset, int limit, boolean bufferRecyclable, IOContext context) throws IOException { return new UTF8StreamJsonParser(context, DEFAULT_JSON_FACTORY.getParserFeatures(), in, DEFAULT_JSON_FACTORY.getCodec(), DEFAULT_JSON_FACTORY.getRootByteSymbols().makeChild(1), buf, offset, limit, bufferRecyclable); }
public JsonParser constructParser(int parserFeatures, ObjectCodec codec, ByteQuadsCanonicalizer rootByteSymbols, CharsToNameCanonicalizer rootCharSymbols, int factoryFeatures) throws IOException { JsonEncoding enc = detectEncoding(); if (enc == JsonEncoding.UTF8) { /* and without canonicalization, byte-based approach is not performant; just use std UTF-8 reader * (which is ok for larger input; not so hot for smaller; but this is not a common case) */ if (JsonFactory.Feature.CANONICALIZE_FIELD_NAMES.enabledIn(factoryFeatures)) { ByteQuadsCanonicalizer can = rootByteSymbols.makeChild(factoryFeatures); return new UTF8StreamJsonParser(_context, parserFeatures, _in, codec, can, _inputBuffer, _inputPtr, _inputEnd, _bufferRecyclable); } } return new ReaderBasedJsonParser(_context, parserFeatures, constructReader(), codec, rootCharSymbols.makeChild(factoryFeatures)); }
/** * Creates a {@link SmileParser} from the inputstream with the supplied buf {@code inBuffer} to use. */ static SmileParser newSmileParser(InputStream in, byte[] buf, int offset, int limit, boolean bufferRecyclable, IOContext context) throws IOException { return new SmileParser(context, DEFAULT_SMILE_FACTORY.getParserFeatures(), DEFAULT_SMILE_FACTORY.getSmileParserFeatures(), DEFAULT_SMILE_FACTORY.getCodec(), DEFAULT_SMILE_FACTORY.getRootByteSymbols().makeChild(1), in, buf, offset, limit, bufferRecyclable); }
public JsonParser constructParser(ObjectReadContext readCtxt, int streamReadFeatures, int formatReadFeatures, ByteQuadsCanonicalizer rootByteSymbols, CharsToNameCanonicalizer rootCharSymbols, int factoryFeatures) throws IOException { JsonEncoding enc = detectEncoding(); if (enc == JsonEncoding.UTF8) { /* and without canonicalization, byte-based approach is not performant; just use std UTF-8 reader * (which is ok for larger input; not so hot for smaller; but this is not a common case) */ if (JsonFactory.Feature.CANONICALIZE_FIELD_NAMES.enabledIn(factoryFeatures)) { ByteQuadsCanonicalizer can = rootByteSymbols.makeChild(factoryFeatures); return new UTF8StreamJsonParser(readCtxt, _context, streamReadFeatures, formatReadFeatures, _in, can, _inputBuffer, _inputPtr, _inputEnd, _bufferRecyclable); } } return new ReaderBasedJsonParser(readCtxt, _context, streamReadFeatures, formatReadFeatures, constructReader(), rootCharSymbols.makeChild(factoryFeatures)); }
/** * @since 2.9 */ @Override public NonBlockingByteArrayParser createNonBlockingByteArrayParser() throws IOException { IOContext ctxt = _createContext(null, false); ByteQuadsCanonicalizer can = _byteSymbolCanonicalizer.makeChild(_factoryFeatures); return new NonBlockingByteArrayParser(ctxt, _parserFeatures, _smileParserFeatures, can); }
/** * @since 2.8 */ protected JsonParser _createParser(DataInput input, IOContext ctxt) throws IOException { // 13-May-2016, tatu: Need to take care not to accidentally create JSON parser for // non-JSON input. So, bit unclean but... String format = getFormatName(); if (format != FORMAT_NAME_JSON) { // NOTE: only ensure override; full equality NOT needed throw new UnsupportedOperationException(String.format( "InputData source not (yet?) support for this format (%s)", format)); } // Also: while we can't do full bootstrapping (due to read-ahead limitations), should // at least handle possible UTF-8 BOM int firstByte = ByteSourceJsonBootstrapper.skipUTF8BOM(input); ByteQuadsCanonicalizer can = _byteSymbolCanonicalizer.makeChild(_factoryFeatures); return new UTF8DataInputJsonParser(ctxt, _parserFeatures, input, _objectCodec, can, firstByte); }
public CBORParser constructParser(int factoryFeatures, int generalParserFeatures, int formatFeatures, ObjectCodec codec, ByteQuadsCanonicalizer rootByteSymbols) throws IOException, JsonParseException { ByteQuadsCanonicalizer can = rootByteSymbols.makeChild(factoryFeatures); // We just need a single byte to recognize possible "empty" document. ensureLoaded(1); CBORParser p = new CBORParser(_context, generalParserFeatures, formatFeatures, codec, can, _in, _inputBuffer, _inputPtr, _inputEnd, _bufferRecyclable); if (_inputPtr < _inputEnd) { // only false for empty doc ; // anything we should verify? In future, could verify } else { /* 13-Jan-2014, tatu: Actually, let's allow empty documents even if * header signature would otherwise be needed. This is useful for * JAX-RS provider, empty PUT/POST payloads? */ ; } return p; }
public CBORParser constructParser(int factoryFeatures, int generalParserFeatures, int formatFeatures, ObjectCodec codec, ByteQuadsCanonicalizer rootByteSymbols) throws IOException, JsonParseException { ByteQuadsCanonicalizer can = rootByteSymbols.makeChild(factoryFeatures); // We just need a single byte to recognize possible "empty" document. ensureLoaded(1); CBORParser p = new CBORParser(_context, generalParserFeatures, formatFeatures, codec, can, _in, _inputBuffer, _inputPtr, _inputEnd, _bufferRecyclable); if (_inputPtr < _inputEnd) { // only false for empty doc ; // anything we should verify? In future, could verify } else { /* 13-Jan-2014, tatu: Actually, let's allow empty documents even if * header signature would otherwise be needed. This is useful for * JAX-RS provider, empty PUT/POST payloads? */ ; } return p; }
public CBORParser constructParser(int factoryFeatures, int generalParserFeatures, int formatFeatures, ObjectCodec codec, ByteQuadsCanonicalizer rootByteSymbols) throws IOException, JsonParseException { ByteQuadsCanonicalizer can = rootByteSymbols.makeChild(factoryFeatures); // We just need a single byte to recognize possible "empty" document. ensureLoaded(1); CBORParser p = new CBORParser(_context, generalParserFeatures, formatFeatures, codec, can, _in, _inputBuffer, _inputPtr, _inputEnd, _bufferRecyclable); if (_inputPtr < _inputEnd) { // only false for empty doc ; // anything we should verify? In future, could verify } else { /* 13-Jan-2014, tatu: Actually, let's allow empty documents even if * header signature would otherwise be needed. This is useful for * JAX-RS provider, empty PUT/POST payloads? */ ; } return p; }
/** * Optional factory method, expected to be overridden * * @since 2.8 */ protected JsonParser _createParser(DataInput input, IOContext ctxt) throws IOException { // 13-May-2016, tatu: Need to take care not to accidentally create JSON parser for // non-JSON input. _requireJSONFactory("InputData source not (yet?) support for this format (%s)"); // Also: while we can't do full bootstrapping (due to read-ahead limitations), should // at least handle possible UTF-8 BOM int firstByte = ByteSourceJsonBootstrapper.skipUTF8BOM(input); ByteQuadsCanonicalizer can = _byteSymbolCanonicalizer.makeChild(_factoryFeatures); return new UTF8DataInputJsonParser(ctxt, _parserFeatures, input, _objectCodec, can, firstByte); }
/** * Optional method for constructing parser for non-blocking parsing * via {@link com.fasterxml.jackson.core.async.ByteArrayFeeder} * interface (accessed using {@link JsonParser#getNonBlockingInputFeeder()} * from constructed instance). *<p> * If this factory does not support non-blocking parsing (either at all, * or from byte array), * will throw {@link UnsupportedOperationException} * * @since 2.9 */ public JsonParser createNonBlockingByteArrayParser() throws IOException { // 17-May-2017, tatu: Need to take care not to accidentally create JSON parser // for non-JSON input: _requireJSONFactory("Non-blocking source not (yet?) support for this format (%s)"); IOContext ctxt = _createNonBlockingContext(null); ByteQuadsCanonicalizer can = _byteSymbolCanonicalizer.makeChild(_factoryFeatures); return new NonBlockingJsonParser(ctxt, _parserFeatures, can); }
/** * Creates a {@link UTF8StreamJsonParser} from the inputstream with the supplied buf {@code inBuffer} to use. */ static UTF8StreamJsonParser newJsonParser(InputStream in, byte[] buf, int offset, int limit, boolean bufferRecyclable, IOContext context) throws IOException { return new UTF8StreamJsonParser(context, DEFAULT_JSON_FACTORY.getParserFeatures(), in, DEFAULT_JSON_FACTORY.getCodec(), DEFAULT_JSON_FACTORY.getRootByteSymbols().makeChild(1), buf, offset, limit, bufferRecyclable); }
@Override public NonBlockingByteArrayParser createNonBlockingByteArrayParser(ObjectReadContext readCtxt) throws IOException { ByteQuadsCanonicalizer can = _byteSymbolCanonicalizer.makeChild(_factoryFeatures); return new NonBlockingByteArrayParser(readCtxt, _createContext(null, false), readCtxt.getStreamReadFeatures(_streamReadFeatures), readCtxt.getFormatReadFeatures(_formatReadFeatures), can); }
/** * Creates a {@link SmileParser} from the inputstream with the supplied buf {@code inBuffer} to use. */ static SmileParser newSmileParser(InputStream in, byte[] buf, int offset, int limit, boolean bufferRecyclable, IOContext context) throws IOException { return new SmileParser(context, DEFAULT_SMILE_FACTORY.getParserFeatures(), DEFAULT_SMILE_FACTORY.getSmileParserFeatures(), DEFAULT_SMILE_FACTORY.getCodec(), DEFAULT_SMILE_FACTORY.getRootByteSymbols().makeChild(1), in, buf, offset, limit, bufferRecyclable); }
public JsonParser constructParser(int parserFeatures, ObjectCodec codec, ByteQuadsCanonicalizer rootByteSymbols, CharsToNameCanonicalizer rootCharSymbols, int factoryFeatures) throws IOException { JsonEncoding enc = detectEncoding(); if (enc == JsonEncoding.UTF8) { /* and without canonicalization, byte-based approach is not performant; just use std UTF-8 reader * (which is ok for larger input; not so hot for smaller; but this is not a common case) */ if (JsonFactory.Feature.CANONICALIZE_FIELD_NAMES.enabledIn(factoryFeatures)) { ByteQuadsCanonicalizer can = rootByteSymbols.makeChild(factoryFeatures); return new UTF8StreamJsonParser(_context, parserFeatures, _in, codec, can, _inputBuffer, _inputPtr, _inputEnd, _bufferRecyclable); } } return new ReaderBasedJsonParser(_context, parserFeatures, constructReader(), codec, rootCharSymbols.makeChild(factoryFeatures)); }
public JsonParser constructParser(int parserFeatures, ObjectCodec codec, ByteQuadsCanonicalizer rootByteSymbols, CharsToNameCanonicalizer rootCharSymbols, int factoryFeatures) throws IOException { JsonEncoding enc = detectEncoding(); if (enc == JsonEncoding.UTF8) { /* and without canonicalization, byte-based approach is not performant; just use std UTF-8 reader * (which is ok for larger input; not so hot for smaller; but this is not a common case) */ if (JsonFactory.Feature.CANONICALIZE_FIELD_NAMES.enabledIn(factoryFeatures)) { ByteQuadsCanonicalizer can = rootByteSymbols.makeChild(factoryFeatures); return new UTF8StreamJsonParser(_context, parserFeatures, _in, codec, can, _inputBuffer, _inputPtr, _inputEnd, _bufferRecyclable); } } return new ReaderBasedJsonParser(_context, parserFeatures, constructReader(), codec, rootCharSymbols.makeChild(factoryFeatures)); }