protected ParserBase(IOContext ctxt, int features) { super(features); _ioContext = ctxt; _textBuffer = ctxt.constructTextBuffer(); DupDetector dups = Feature.STRICT_DUPLICATE_DETECTION.enabledIn(features) ? DupDetector.rootDetector(this) : null; _parsingContext = JsonReadContext.createRootContext(dups); }
@Override public JsonParser enable(Feature f) { _features |= f.getMask(); if (f == Feature.STRICT_DUPLICATE_DETECTION) { // enabling dup detection? if (_parsingContext.getDupDetector() == null) { // but only if disabled currently _parsingContext = _parsingContext.withDupDetector(DupDetector.rootDetector(this)); } } return this; }
@JsonCreator public JSONParseSpec( @JsonProperty("timestampSpec") TimestampSpec timestampSpec, @JsonProperty("dimensionsSpec") DimensionsSpec dimensionsSpec, @JsonProperty("flattenSpec") JSONPathSpec flattenSpec, @JsonProperty("featureSpec") Map<String, Boolean> featureSpec ) { super(timestampSpec, dimensionsSpec, flattenSpec != null ? flattenSpec : JSONPathSpec.DEFAULT); this.objectMapper = new ObjectMapper(); this.featureSpec = (featureSpec == null) ? new HashMap<>() : featureSpec; for (Map.Entry<String, Boolean> entry : this.featureSpec.entrySet()) { Feature feature = Feature.valueOf(entry.getKey()); objectMapper.configure(feature, entry.getValue()); } }
if (_parsingContext.expectComma()) { if (i != INT_COMMA) { _reportUnexpectedChar(i, "was expecting comma to separate "+_parsingContext.typeDesc()+" entries"); if (Feature.ALLOW_TRAILING_COMMA.enabledIn(_features)) { if (i == INT_RBRACKET || i == INT_RCURLY) { _closeScope(i); if (!_parsingContext.inObject()) { _nextTokenNotInObject(i); return null;
public CBORParser(IOContext ctxt, int parserFeatures, int cborFeatures, ObjectCodec codec, ByteQuadsCanonicalizer sym, InputStream in, byte[] inputBuffer, int start, int end, boolean bufferRecyclable) { super(parserFeatures); _ioContext = ctxt; _objectCodec = codec; _symbols = sym; _inputStream = in; _inputBuffer = inputBuffer; _inputPtr = start; _inputEnd = end; _bufferRecyclable = bufferRecyclable; _textBuffer = ctxt.constructTextBuffer(); DupDetector dups = JsonParser.Feature.STRICT_DUPLICATE_DETECTION.enabledIn(parserFeatures) ? DupDetector.rootDetector(this) : null; _parsingContext = CBORReadContext.createRootContext(dups); _tokenInputRow = -1; _tokenInputCol = -1; }
public CsvParser(CsvIOContext ctxt, int stdFeatures, int csvFeatures, ObjectCodec codec, Reader reader) { super(stdFeatures); _objectCodec = codec; _textBuffer = ctxt.csvTextBuffer(); DupDetector dups = JsonParser.Feature.STRICT_DUPLICATE_DETECTION.enabledIn(stdFeatures) ? DupDetector.rootDetector(this) : null; _formatFeatures = csvFeatures; _parsingContext = JsonReadContext.createRootContext(dups); _reader = new CsvDecoder(this, ctxt, reader, _schema, _textBuffer, stdFeatures, csvFeatures); }
/** * Fluent factory method that will construct and return a new configuration * object instance with specified features disabled. * * @since 2.5 */ public DeserializationConfig withoutFeatures(JsonParser.Feature... features) { int newSet = _parserFeatures; int newMask = _parserFeaturesToChange; for (JsonParser.Feature f : features) { int mask = f.getMask(); newSet &= ~mask; newMask |= mask; } return ((_parserFeatures == newSet) && (_parserFeaturesToChange == newMask)) ? this : new DeserializationConfig(this, _mapperFeatures, _deserFeatures, newSet, newMask, _formatReadFeatures, _formatReadFeaturesToChange); }
/** * Helper method used to encapsulate logic of including (or not) of * "source reference" when constructing {@link JsonLocation} instances. * * @since 2.9 */ protected Object _getSourceReference() { if (JsonParser.Feature.INCLUDE_SOURCE_IN_LOCATION.enabledIn(_features)) { return _ioContext.getSourceReference(); } return null; }
mapper.configure((DeserializationFeature) feature, featureValue); assert mapper.getDeserializationConfig().isEnabled( (DeserializationFeature) feature) == featureValue; getLogger() + " with " + mapper.getDeserializationConfig() .isEnabled( (DeserializationFeature) feature)); } else if (configFeature.equals(MapperFeature.class)) { mapper.configure((MapperFeature) feature, featureValue); assert mapper.getDeserializationConfig().isEnabled( (MapperFeature) feature) == featureValue; assert mapper.getSerializationConfig().isEnabled( (MapperFeature) feature)); } else if (configFeature.equals(JsonParser.class)) { Feature parserFeature = JsonParser.Feature.valueOf(featureKey); getLogger() .info("initializing parser feature: "
@Override public JsonParser disable(Feature f) { _features &= ~f.getMask(); if (f == Feature.STRICT_DUPLICATE_DETECTION) { _parsingContext = _parsingContext.withDupDetector(null); } return this; }
public CsvDecoder(CsvParser owner, IOContext ctxt, Reader r, CsvSchema schema, TextBuffer textBuffer, int stdFeatures, int csvFeatures) // boolean autoCloseInput, boolean trimSpaces) { _owner = owner; _ioContext = ctxt; _inputSource = r; _textBuffer = textBuffer; _autoCloseInput = JsonParser.Feature.AUTO_CLOSE_SOURCE.enabledIn(stdFeatures); _allowComments = JsonParser.Feature.ALLOW_YAML_COMMENTS.enabledIn(stdFeatures); _trimSpaces = CsvParser.Feature.TRIM_SPACES.enabledIn(csvFeatures); _inputBuffer = ctxt.allocTokenBuffer(); _bufferRecyclable = true; // since we allocated it _inputSource = r; _tokenInputRow = -1; _tokenInputCol = -1; setSchema(schema); }
/** * Method for disabling specified parser features * (check {@link JsonParser.Feature} for list of features) */ public JsonFactory disable(JsonParser.Feature f) { _parserFeatures &= ~f.getMask(); return this; }
/** * Checked whether specified parser feature is enabled. */ public final boolean isEnabled(JsonParser.Feature f) { return (_parserFeatures & f.getMask()) != 0; }
/** * Method for enabling specified parser feature * (check {@link JsonParser.Feature} for list of features) */ public JsonFactory enable(JsonParser.Feature f) { _parserFeatures |= f.getMask(); return this; }
/** * Method for disabling specified feature * (check {@link Feature} for list of features) */ public JsonParser disable(Feature f) { _features &= ~f.getMask(); return this; }
/** * Method for enabling specified parser feature * (check {@link Feature} for list of features) */ public JsonParser enable(Feature f) { _features |= f.getMask(); return this; }
/** * Method that calculates bit set (flags) of all features that * are enabled by default. */ public static int collectDefaults() { int flags = 0; for (Feature f : values()) { if (f.enabledByDefault()) { flags |= f.getMask(); } } return flags; }
private Feature(boolean defaultState) { _mask = (1 << ordinal()); _defaultState = defaultState; }