protected final JsonToken _closeArrayScope() throws IOException { if (!_parsingContext.inArray()) { _reportMismatchedEndMarker(']', '}'); } JsonReadContext ctxt = _parsingContext.getParent(); _parsingContext = ctxt; int st; if (ctxt.inObject()) { st = MAJOR_OBJECT_FIELD_NEXT; } else if (ctxt.inArray()) { st = MAJOR_ARRAY_ELEMENT_NEXT; } else { st = MAJOR_ROOT; } _majorState = st; _majorStateAfterValue = st; return (_currToken = JsonToken.END_ARRAY); }
protected final JsonToken _closeObjectScope() throws IOException { if (!_parsingContext.inObject()) { _reportMismatchedEndMarker('}', ']'); } JsonReadContext ctxt = _parsingContext.getParent(); _parsingContext = ctxt; int st; if (ctxt.inObject()) { st = MAJOR_OBJECT_FIELD_NEXT; } else if (ctxt.inArray()) { st = MAJOR_ARRAY_ELEMENT_NEXT; } else { st = MAJOR_ROOT; } _majorState = st; _majorStateAfterValue = st; return (_currToken = JsonToken.END_OBJECT); }
@Override public void overrideCurrentName(String name) { // Simple, but need to look for START_OBJECT/ARRAY's "off-by-one" thing: JsonReadContext ctxt = _parsingContext; if (_currToken == JsonToken.START_OBJECT || _currToken == JsonToken.START_ARRAY) { ctxt = ctxt.getParent(); } /* 24-Sep-2013, tatu: Unfortunate, but since we did not expose exceptions, * need to wrap this here */ try { ctxt.setCurrentName(name); } catch (IOException e) { throw new IllegalStateException(e); } }
protected ParserBase(ObjectReadContext readCtxt, IOContext ctxt, int features) { super(readCtxt, features); _ioContext = ctxt; _textBuffer = ctxt.constructTextBuffer(); DupDetector dups = Feature.STRICT_DUPLICATE_DETECTION.enabledIn(features) ? DupDetector.rootDetector(this) : null; _parsingContext = JsonReadContext.createRootContext(dups); }
/** * Method that can be called to get the name associated with * the current event. */ @Override public String currentName() throws IOException { // [JACKSON-395]: start markers require information from parent if (_currToken == JsonToken.START_OBJECT || _currToken == JsonToken.START_ARRAY) { JsonReadContext parent = _parsingContext.getParent(); if (parent != null) { return parent.currentName(); } } return _parsingContext.currentName(); }
@Override public void overrideCurrentName(String name) { // Simple, but need to look for START_OBJECT/ARRAY's "off-by-one" thing: JsonReadContext ctxt = _parsingContext; if (_currToken == JsonToken.START_OBJECT || _currToken == JsonToken.START_ARRAY) { ctxt = ctxt.getParent(); } // 24-Sep-2013, tatu: Unfortunate, but since we did not expose exceptions, // need to wrap this here try { ctxt.setCurrentName(name); } catch (IOException e) { throw new IllegalStateException(e); } }
public Parser(TokenBuffer.Segment paramSegment, ObjectCodec paramObjectCodec) { super(); this._segment = paramSegment; this._segmentPtr = -1; this._codec = paramObjectCodec; this._parsingContext = JsonReadContext.createRootContext(-1, -1); }
public final void overrideCurrentName(String paramString) { JsonReadContext localJsonReadContext = this._parsingContext; if ((this._currToken == JsonToken.START_OBJECT) || (this._currToken == JsonToken.START_ARRAY)) localJsonReadContext = localJsonReadContext.getParent(); localJsonReadContext.setCurrentName(paramString); }
@Override public String getCurrentName() throws IOException { if (_currToken == JsonToken.START_OBJECT || _currToken == JsonToken.START_ARRAY) { JsonReadContext parent = parsingContext.getParent(); return parent.getCurrentName(); } return parsingContext.getCurrentName(); }
protected ParserBase(IOContext ctxt, int features) { super(); _features = features; _ioContext = ctxt; _textBuffer = ctxt.constructTextBuffer(); DupDetector dups = Feature.STRICT_DUPLICATE_DETECTION.enabledIn(features) ? DupDetector.rootDetector(this) : null; JsonReadContext readCtxt = JsonReadContext.createRootContext(dups); _parsingContext = readCtxt; }
/** * Method that can be called to get the name associated with * the current event. */ @Override public String getCurrentName() throws IOException, JsonParseException { // [JACKSON-395]: start markers require information from parent if (_currToken == JsonToken.START_OBJECT || _currToken == JsonToken.START_ARRAY) { JsonReadContext parent = _parsingContext.getParent(); return parent.getCurrentName(); } return _parsingContext.getCurrentName(); }
protected ParserBase(int features, BufferRecycler _bufferRecycler, Object sourceRef, boolean managedResource) { super(); _features = features; _ioContext = new IOContext(_bufferRecycler, sourceRef, managedResource); _textBuffer = new TextBuffer(_bufferRecycler); //ctxt.constructTextBuffer(); _parsingContext = JsonReadContext.createRootContext(); }
@Override public void overrideCurrentName(String name) { // Simple, but need to look for START_OBJECT/ARRAY's "off-by-one" thing: JsonReadContext ctxt = _parsingContext; if (_currToken == JsonToken.START_OBJECT || _currToken == JsonToken.START_ARRAY) { ctxt = ctxt.getParent(); } ctxt.setCurrentName(name); }
public Parser(Segment firstSeg, ObjectCodec codec) { super(0); _segment = firstSeg; _segmentPtr = -1; // not yet read _codec = codec; _parsingContext = JsonReadContext.createRootContext(-1, -1); }
@Override public JsonToken nextToken() throws IOException, JsonParseException { // If we are closed, nothing more to do if (_closed || (_segment == null)) return null; // Ok, then: any more tokens? if (++_segmentPtr >= Segment.TOKENS_PER_SEGMENT) { _segmentPtr = 0; _segment = _segment.next(); if (_segment == null) { return null; } } _currToken = _segment.type(_segmentPtr); // Field name? Need to update context if (_currToken == JsonToken.FIELD_NAME) { Object ob = _currentObject(); String name = (ob instanceof String) ? ((String) ob) : ob.toString(); _parsingContext.setCurrentName(name); } else if (_currToken == JsonToken.START_OBJECT) { _parsingContext = _parsingContext.createChildObjectContext(-1, -1); } else if (_currToken == JsonToken.START_ARRAY) { _parsingContext = _parsingContext.createChildArrayContext(-1, -1); } else if (_currToken == JsonToken.END_OBJECT || _currToken == JsonToken.END_ARRAY) { // Closing JSON Object/Array? Close matching context _parsingContext = _parsingContext.getParent(); // but allow unbalanced cases too (more close markers) if (_parsingContext == null) { _parsingContext = JsonReadContext.createRootContext(-1, -1); } } return _currToken; }
protected ParserBase(IOContext ctxt, int features) { super(); _features = features; _ioContext = ctxt; _textBuffer = ctxt.constructTextBuffer(); _parsingContext = JsonReadContext.createRootContext(); }
protected void _reportMismatchedEndMarker(int actCh, char expCh) throws JsonParseException { JsonReadContext ctxt = getParsingContext(); _reportError(String.format( "Unexpected close marker '%s': expected '%c' (for %s starting at %s)", (char) actCh, expCh, ctxt.typeDesc(), ctxt.getStartLocation(_getSourceReference()))); }
public final JsonToken nextToken() { if ((this._closed) || (this._segment == null)) return null; int i = 1 + this._segmentPtr; this._segmentPtr = i; if (i >= 16) { this._segmentPtr = 0; this._segment = this._segment.next(); if (this._segment == null) return null; } this._currToken = this._segment.type(this._segmentPtr); if (this._currToken == JsonToken.FIELD_NAME) { Object localObject = _currentObject(); String str1; if ((localObject instanceof String)) str1 = (String)localObject; else str1 = localObject.toString(); String str2 = str1; this._parsingContext.setCurrentName(str2); } else if (this._currToken == JsonToken.START_OBJECT) { this._parsingContext = this._parsingContext.createChildObjectContext(-1, -1); } else if (this._currToken == JsonToken.START_ARRAY) { this._parsingContext = this._parsingContext.createChildArrayContext(-1, -1); } else if ((this._currToken == JsonToken.END_OBJECT) || (this._currToken == JsonToken.END_ARRAY)) { this._parsingContext = this._parsingContext.getParent(); if (this._parsingContext == null) this._parsingContext = JsonReadContext.createRootContext(-1, -1); } return this._currToken; }
@Override public JsonReadContext getParsingContext() { return _parsingContext; }