protected final String _getText2(JsonToken t) { if (t == null) { return null; } switch (t.id()) { case ID_FIELD_NAME: return _parsingContext.getCurrentName(); case ID_STRING: // fall through case ID_NUMBER_INT: case ID_NUMBER_FLOAT: return _textBuffer.contentsAsString(); default: return t.asString(); } }
char[] outBuf = _textBuffer.emptyAndGetCurrentSegment(); c = _verifyNoLeadingZeroes(); return _parseNumber2(outBuf, outPtr, false, intLen); return _parseFloat(outBuf, outPtr, c, false, intLen); _textBuffer.setCurrentLength(outPtr); if (_parsingContext.inRoot()) { _verifyRootSpace(c);
private String _handleOddName2(int startPtr, int hash, int[] codes) throws IOException _textBuffer.resetWithShared(_inputBuffer, startPtr, (_inputPtr - startPtr)); char[] outBuf = _textBuffer.getCurrentSegment(); int outPtr = _textBuffer.getCurrentSegmentSize(); final int maxCode = codes.length; outBuf = _textBuffer.finishCurrentSegment(); outPtr = 0; _textBuffer.setCurrentLength(outPtr); char[] buf = tb.getTextBuffer(); int start = tb.getTextOffset(); int len = tb.size();
/** * Main access method that will construct a String that contains * all the contents, release all internal buffers we may have, * and return result String. * Note that the method is not idempotent -- if called second time, * will just return an empty String. */ public String getAndClear() { String result = _buffer.contentsAsString(); _buffer.releaseBuffers(); return result; } }
protected JsonToken _finishErrorToken() throws IOException { while (_inputPtr < _inputEnd) { int i = (int) _inputBuffer[_inputPtr++]; // !!! TODO: Decode UTF-8 characters properly... // char c = (char) _decodeCharForError(i); char ch = (char) i; if (Character.isJavaIdentifierPart(ch)) { // 11-Jan-2016, tatu: note: we will fully consume the character, // included or not, so if recovery was possible, it'd be off-by-one... _textBuffer.append(ch); if (_textBuffer.size() < MAX_ERROR_TOKEN_LENGTH) { continue; } } return _reportErrorToken(_textBuffer.contentsAsString()); } return (_currToken = JsonToken.NOT_AVAILABLE); }
_loadMoreGuaranteed(); ptr = _inputPtr; char[] outBuf = _textBuffer.emptyAndGetCurrentSegment(); final int[] codes = _icUTF8; if (c == INT_QUOTE) { _inputPtr = ptr+1; return _textBuffer.setCurrentAndReturn(outPtr); _finishString2(outBuf, outPtr); return _textBuffer.contentsAsString();
@Override public int getTextLength() throws IOException { if (_currToken != null) { // null only before/after document switch (_currToken.id()) { case ID_FIELD_NAME: return _parsingContext.getCurrentName().length(); case ID_STRING: // fall through case ID_NUMBER_INT: case ID_NUMBER_FLOAT: return _textBuffer.size(); default: return _currToken.asCharArray().length; } } return 0; }
switch (_currToken.id()) { String name = _parsingContext.getCurrentName(); int nameLen = name.length(); if (_nameCopyBuffer == null) { _nameCopyBuffer = _ioContext.allocNameCopyBuffer(nameLen); } else if (_nameCopyBuffer.length < nameLen) { _nameCopyBuffer = new char[nameLen]; if (_tokenIncomplete) { _tokenIncomplete = false; _finishString(); // only strings can be incomplete return _textBuffer.getTextBuffer(); return _currToken.asCharArray();
switch (_currToken.id()) { String name = _parsingContext.currentName(); int nameLen = name.length(); if (_nameCopyBuffer == null) { _nameCopyBuffer = _ioContext.allocNameCopyBuffer(nameLen); } else if (_nameCopyBuffer.length < nameLen) { _nameCopyBuffer = new char[nameLen]; return _textBuffer.getTextBuffer(); return _currToken.asCharArray();
@Override public int getTextLength() throws IOException { if (_currToken == JsonToken.VALUE_STRING) { if (_tokenIncomplete) { _tokenIncomplete = false; _finishString(); // only strings can be incomplete } return _textBuffer.size(); } if (_currToken == JsonToken.FIELD_NAME) { return _parsingContext.getCurrentName().length(); } if (_currToken != null) { // null only before/after document if (_currToken.isNumeric()) { return _textBuffer.size(); } return _currToken.asCharArray().length; } return 0; }
@Override public String nextTextValue() throws IOException { // two distinct cases; either got name and we know next type, or 'other' if (_currToken == JsonToken.FIELD_NAME) { // mostly copied from '_nextAfterName' _nameCopied = false; JsonToken t = _nextToken; _nextToken = null; _currToken = t; if (t == JsonToken.VALUE_STRING) { if (_tokenIncomplete) { _tokenIncomplete = false; return _finishAndReturnString(); } return _textBuffer.contentsAsString(); } if (t == JsonToken.START_ARRAY) { _parsingContext = _parsingContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); } else if (t == JsonToken.START_OBJECT) { _parsingContext = _parsingContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); } return null; } // !!! TODO: optimize this case as well return (nextToken() == JsonToken.VALUE_STRING) ? getText() : null; }
outBuf = _textBuffer.finishCurrentSegment(); outPtr = 0; outBuf = _textBuffer.finishCurrentSegment(); outPtr = 0; reportUnexpectedNumberChar(c, "Decimal point not followed by a digit"); if (c == INT_e || c == INT_E) { // exponent? if (outPtr >= outBuf.length) { outBuf = _textBuffer.finishCurrentSegment(); outPtr = 0; _loadMoreGuaranteed(); outBuf = _textBuffer.finishCurrentSegment(); outPtr = 0; ++expLen; if (outPtr >= outBuf.length) { outBuf = _textBuffer.finishCurrentSegment(); outPtr = 0; --_inputPtr; _textBuffer.setCurrentLength(outPtr);
if (_inputPtr >= _inputEnd && !_loadMore()) { _textBuffer.setCurrentLength(outPtr); return resetInt(negative, intPartLength); return _parseFloat(outBuf, outPtr, c, negative, intPartLength); outBuf = _textBuffer.finishCurrentSegment(); outPtr = 0; _textBuffer.setCurrentLength(outPtr); if (_parsingContext.inRoot()) { _verifyRootSpace(_inputBuffer[_inputPtr++] & 0xFF);
@Override public int getTextLength() throws IOException { if (_currToken != null) { // null only before/after document switch (_currToken.id()) { case ID_FIELD_NAME: return _parsingContext.currentName().length(); case ID_STRING: // fall through case ID_NUMBER_INT: case ID_NUMBER_FLOAT: return _textBuffer.size(); default: return _currToken.asCharArray().length; } } return 0; }
if (textBuffer == null) { _text = textBuffer = new TextBuffer(null); char[] outputBuffer = textBuffer.emptyAndGetCurrentSegment(); final int[] escCodes = CharTypes.get7BitOutputEscapes(); final int escCodeCount = escCodes.length; outputBuffer = textBuffer.finishCurrentSegment(); outPtr = 0; System.arraycopy(_qbuf, 0, outputBuffer, outPtr, first); outputBuffer = textBuffer.finishCurrentSegment(); int second = length - first; System.arraycopy(_qbuf, first, outputBuffer, 0, second); textBuffer.setCurrentLength(outPtr); return textBuffer.contentsAsArray();
_minorState = MINOR_NUMBER_EXPONENT_DIGITS; if (ch == INT_MINUS || ch == INT_PLUS) { _textBuffer.append((char) ch); if (_inputPtr >= _inputEnd) { _minorState = MINOR_NUMBER_EXPONENT_DIGITS; char[] outBuf = _textBuffer.getBufferWithoutReset(); int outPtr = _textBuffer.getCurrentSegmentSize(); int expLen = _expLength; ++expLen; if (outPtr >= outBuf.length) { outBuf = _textBuffer.expandCurrentSegment(); _textBuffer.setCurrentLength(outPtr); _expLength = expLen; return JsonToken.NOT_AVAILABLE; _textBuffer.setCurrentLength(outPtr);
protected JsonToken _handleApos() throws IOException char[] outBuf = _textBuffer.emptyAndGetCurrentSegment(); int outPtr = _textBuffer.getCurrentSegmentSize(); outBuf = _textBuffer.finishCurrentSegment(); outPtr = 0; _textBuffer.setCurrentLength(outPtr); return JsonToken.VALUE_STRING;
char[] cbuf = _textBuffer.emptyAndGetCurrentSegment(); int cix = 0; needed = 3; } else { // 5- and 6-byte chars not valid xml chars _reportInvalidInitial(ch); needed = ch = 1; // never really gets this far _reportInvalidEOF(" in field name", JsonToken.FIELD_NAME); _reportInvalidOther(ch2); ch -= 0x10000; // to normalize it starting with 0x0 if (cix >= cbuf.length) { cbuf = _textBuffer.expandCurrentSegment(); cbuf = _textBuffer.expandCurrentSegment();
protected void _finishString2() throws IOException char[] outBuf = _textBuffer.getCurrentSegment(); int outPtr = _textBuffer.getCurrentSegmentSize(); final int[] codes = _icLatin1; final int maxCode = codes.length; outBuf = _textBuffer.finishCurrentSegment(); outPtr = 0; _textBuffer.setCurrentLength(outPtr);
protected JsonToken _startPositiveNumber(int ch) throws IOException char[] outBuf = _textBuffer.emptyAndGetCurrentSegment(); outBuf[0] = (char) ch; _textBuffer.setCurrentLength(1); return (_currToken = JsonToken.NOT_AVAILABLE); outBuf = _textBuffer.expandCurrentSegment(); _textBuffer.setCurrentLength(outPtr); return (_currToken = JsonToken.NOT_AVAILABLE); _textBuffer.setCurrentLength(outPtr); return _valueComplete(JsonToken.VALUE_NUMBER_INT);