@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; }
public JsonWriteContext createChildArrayContext() { JsonWriteContext ctxt = _child; if (ctxt == null) { _child = ctxt = new JsonWriteContext(TYPE_ARRAY, this, (_dups == null) ? null : _dups.child()); return ctxt; } return ctxt.reset(TYPE_ARRAY); }
@Override public JsonGenerator enable(Feature f) { final int mask = f.getMask(); _features |= mask; if ((mask & DERIVED_FEATURES_MASK) != 0) { // why not switch? Requires addition of a generated class, alas if (f == Feature.WRITE_NUMBERS_AS_STRINGS) { _cfgNumbersAsStrings = true; } else if (f == Feature.ESCAPE_NON_ASCII) { setHighestNonEscapedChar(127); } else if (f == Feature.STRICT_DUPLICATE_DETECTION) { if (_writeContext.getDupDetector() == null) { // but only if disabled currently _writeContext = _writeContext.withDupDetector(DupDetector.rootDetector(this)); } } } return this; }
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); }
public JsonReadContext createChildObjectContext(int lineNr, int colNr) { JsonReadContext ctxt = _child; if (ctxt == null) { _child = ctxt = new JsonReadContext(this, (_dups == null) ? null : _dups.child(), TYPE_OBJECT, lineNr, colNr); return ctxt; } ctxt.reset(TYPE_OBJECT, lineNr, colNr); return ctxt; }
protected GeneratorBase(int features, ObjectCodec codec) { super(); _features = features; _objectCodec = codec; DupDetector dups = Feature.STRICT_DUPLICATE_DETECTION.enabledIn(features) ? DupDetector.rootDetector(this) : null; _writeContext = JsonWriteContext.createRootContext(dups); _cfgNumbersAsStrings = Feature.WRITE_NUMBERS_AS_STRINGS.enabledIn(features); }
protected void reset(int type, int lineNr, int colNr) { _type = type; _index = -1; _lineNr = lineNr; _columnNr = colNr; _currentName = null; _currentValue = null; if (_dups != null) { _dups.reset(); } }
private void _checkDup(DupDetector dd, String name) throws JsonProcessingException { if (dd.isDup(name)) { // 04-MAy-2016, tatu: Would be great to pass JsonParser, alas, not available so: throw new JsonParseException(null, "Duplicate field '"+name+"'", dd.findLocation()); } }
public static DupDetector rootDetector(JsonGenerator g) { return new DupDetector(g); }
private final void _checkDup(DupDetector dd, String name) throws JsonProcessingException { if (dd.isDup(name)) { throw new JsonGenerationException("Duplicate field '"+name+"'"); } }
@Override public JsonGenerator enable(StreamWriteFeature f) { final int mask = f.getMask(); _streamWriteFeatures |= mask; if ((mask & DERIVED_FEATURES_MASK) != 0) { // why not switch? Requires addition of a generated class, alas if (f == StreamWriteFeature.WRITE_NUMBERS_AS_STRINGS) { _cfgNumbersAsStrings = true; } else if (f == StreamWriteFeature.STRICT_DUPLICATE_DETECTION) { if (_outputContext.getDupDetector() == null) { // but only if disabled currently _outputContext = _outputContext.withDupDetector(DupDetector.rootDetector(this)); } } } return this; }
protected ParserBase(ObjectReadContext readCtxt, IOContext ctxt, int features) { super(readCtxt, features); _ioContext = ctxt; _textBuffer = ctxt.constructTextBuffer(); DupDetector dups = StreamReadFeature.STRICT_DUPLICATE_DETECTION.enabledIn(features) ? DupDetector.rootDetector(this) : null; _parsingContext = JsonReadContext.createRootContext(dups); }
public JsonReadContext createChildArrayContext(int lineNr, int colNr) { JsonReadContext ctxt = _child; if (ctxt == null) { _child = ctxt = new JsonReadContext(this, (_dups == null) ? null : _dups.child(), TYPE_ARRAY, lineNr, colNr); } else { ctxt.reset(TYPE_ARRAY, lineNr, colNr); } return ctxt; }
protected GeneratorBase(ObjectWriteContext writeCtxt, int features) { super(); _objectWriteContext = writeCtxt; _streamWriteFeatures = features; DupDetector dups = StreamWriteFeature.STRICT_DUPLICATE_DETECTION.enabledIn(features) ? DupDetector.rootDetector(this) : null; _outputContext = JsonWriteContext.createRootContext(dups); _cfgNumbersAsStrings = StreamWriteFeature.WRITE_NUMBERS_AS_STRINGS.enabledIn(features); }
protected JsonWriteContext reset(int type) { _type = type; _index = -1; _currentName = null; _gotName = false; _currentValue = null; if (_dups != null) { _dups.reset(); } return this; }
private void _checkDup(DupDetector dd, String name) throws JsonProcessingException { if (dd.isDup(name)) { throw new JsonParseException("Duplicate field '"+name+"'", dd.findLocation()); } }
public DupDetector child() { return new DupDetector(_source); }
private final void _checkDup(DupDetector dd, String name) throws JsonProcessingException { if (dd.isDup(name)) { throw new JsonGenerationException("Duplicate field '"+name+"'"); } }
/** * Helper method called to verify changes to standard features. * * @param newFeatureFlags Bitflag of standard features after they were changed * @param changedFeatures Bitflag of standard features for which setting * did change * * @since 2.7 */ protected void _checkStdFeatureChanges(int newFeatureFlags, int changedFeatures) { int f = Feature.STRICT_DUPLICATE_DETECTION.getMask(); if ((changedFeatures & f) != 0) { if ((newFeatureFlags & f) != 0) { if (_parsingContext.getDupDetector() == null) { _parsingContext = _parsingContext.withDupDetector(DupDetector.rootDetector(this)); } else { // disabling _parsingContext = _parsingContext.withDupDetector(null); } } } }