public Parser(TokenBuffer.Segment paramSegment, ObjectCodec paramObjectCodec) { super(); this._segment = paramSegment; this._segmentPtr = -1; this._codec = paramObjectCodec; this._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) { _parsingContext.setCurrentName((String) _currentObject()); } 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; }
public TokenBuffer$Parser(TokenBuffer.Segment paramSegment, ObjectCodec paramObjectCodec) { super(0); this._segment = paramSegment; this._segmentPtr = -1; this._codec = paramObjectCodec; this._parsingContext = JsonReadContext.createRootContext(-1, -1); }
public JsonToken nextToken() throws IOException, JsonParseException { if ((this._closed) || (this._segment == null)); do { return null; int i = 1 + this._segmentPtr; this._segmentPtr = i; if (i < 16) break; this._segmentPtr = 0; this._segment = this._segment.next(); } while (this._segment == null); this._currToken = this._segment.type(this._segmentPtr); Object localObject; String str; if (this._currToken == JsonToken.FIELD_NAME) { localObject = _currentObject(); if ((localObject instanceof String)) { str = (String)localObject; this._parsingContext.setCurrentName(str); } } while (true) { return this._currToken; str = localObject.toString(); break; if (this._currToken == JsonToken.START_OBJECT) { this._parsingContext = this._parsingContext.createChildObjectContext(-1, -1); continue; } if (this._currToken == JsonToken.START_ARRAY) { this._parsingContext = this._parsingContext.createChildArrayContext(-1, -1); continue; } if ((this._currToken != JsonToken.END_OBJECT) && (this._currToken != JsonToken.END_ARRAY)) continue; this._parsingContext = this._parsingContext.getParent(); if (this._parsingContext != null) continue; this._parsingContext = JsonReadContext.createRootContext(-1, -1); } }
public Parser(Segment firstSeg, ObjectCodec codec) { _segment = firstSeg; _segmentPtr = -1; // not yet read _codec = codec; _parsingContext = JsonReadContext.createRootContext(-1, -1); }
public final JsonToken nextToken() { if ((this._closed) || (this._segment == null)); do { return null; int i = 1 + this._segmentPtr; this._segmentPtr = i; if (i < 16) break; this._segmentPtr = 0; this._segment = this._segment.next(); } while (this._segment == null); this._currToken = this._segment.type(this._segmentPtr); Object localObject; String str; if (this._currToken == JsonToken.FIELD_NAME) { localObject = _currentObject(); if ((localObject instanceof String)) { str = (String)localObject; this._parsingContext.setCurrentName(str); } } while (true) { return this._currToken; str = localObject.toString(); break; 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); } } }