protected JsonParserBase(IOContext ctxt, int features) { super(); _features = features; _ioContext = ctxt; _textBuffer = ctxt.constructTextBuffer(); _parsingContext = JsonReadContext.createRootContext(); }
/** * Method called to release internal buffers owned by the base reader. This may be called along * with {@link #_closeInput} (for example, when explicitly closing this reader instance), or * separately (if need be). */ protected void _releaseBuffers() throws IOException { _textBuffer.releaseBuffers(); char[] buf = _nameCopyBuffer; if (buf != null) { _nameCopyBuffer = null; _ioContext.releaseNameCopyBuffer(buf); } }
/** * Method that return the <b>starting</b> location of the current token; that is, position of the * first character from input that starts the current token. */ @Override public JsonLocation getTokenLocation() { return new JsonLocation( _ioContext.getSourceReference(), getTokenCharacterOffset(), getTokenLineNr(), getTokenColumnNr()); }
/** * Method called when an EOF is encountered between tokens. If so, it may be a legitimate EOF, but * only iff there is no open non-root context. */ @Override protected void _handleEOF() throws JsonParseException { if (!_parsingContext.inRoot()) { _reportInvalidEOF( ": expected close marker for " + _parsingContext.getTypeDesc() + " (from " + _parsingContext.getStartLocation(_ioContext.getSourceReference()) + ")"); } }
protected void _reportMismatchedEndMarker(int actCh, char expCh) throws JsonParseException { String startDesc = "" + _parsingContext.getStartLocation(_ioContext.getSourceReference()); _reportError( "Unexpected close marker '" + ((char) actCh) + "': expected '" + expCh + "' (for " + _parsingContext.getTypeDesc() + " starting at " + startDesc + ")"); }
/** * Method that returns location of the last processed character; usually for error reporting * purposes */ @Override public JsonLocation getCurrentLocation() { int col = _inputPtr - _currInputRowStart + 1; // 1-based return new JsonLocation( _ioContext.getSourceReference(), _currInputProcessed + _inputPtr - 1, _currInputRow, col); }