Example usage for com.fasterxml.jackson.core.util TextBuffer getTextOffset

List of usage examples for com.fasterxml.jackson.core.util TextBuffer getTextOffset

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core.util TextBuffer getTextOffset.

Prototype

public int getTextOffset() 

Source Link

Usage

From source file:com.bazaarvoice.jackson.rison.RisonParser.java

private String _parseUnquotedFieldName2(int startPtr, int hash) throws IOException, JsonParseException {
    _textBuffer.resetWithShared(_inputBuffer, startPtr, (_inputPtr - startPtr));
    char[] outBuf = _textBuffer.getCurrentSegment();
    int outPtr = _textBuffer.getCurrentSegmentSize();

    while (true) {
        if (_inputPtr >= _inputEnd) {
            if (!loadMore()) { // acceptable for now (will error out later)
                break;
            }/*w ww  . j  a v  a  2  s .co  m*/
        }
        char c = _inputBuffer[_inputPtr];
        if (!IdentifierUtils.isIdCharLenient(c)) {
            break;
        }
        ++_inputPtr;
        hash = (hash * 31) + c;
        // Ok, let's add char to output:
        outBuf[outPtr++] = c;

        // Need more room?
        if (outPtr >= outBuf.length) {
            outBuf = _textBuffer.finishCurrentSegment();
            outPtr = 0;
        }
    }
    _textBuffer.setCurrentLength(outPtr);
    {
        TextBuffer tb = _textBuffer;
        char[] buf = tb.getTextBuffer();
        int start = tb.getTextOffset();
        int len = tb.size();

        return _symbols.findSymbol(buf, start, len, hash);
    }
}

From source file:com.bazaarvoice.jackson.rison.RisonParser.java

private String _parseFieldName2(int startPtr, int hash, int endChar) throws IOException, JsonParseException {
    _textBuffer.resetWithShared(_inputBuffer, startPtr, (_inputPtr - startPtr));

    /* Output pointers; calls will also ensure that the buffer is
     * not shared and has room for at least one more char.
     *//*  ww  w. j a  v a 2  s  . co m*/
    char[] outBuf = _textBuffer.getCurrentSegment();
    int outPtr = _textBuffer.getCurrentSegmentSize();

    while (true) {
        if (_inputPtr >= _inputEnd) {
            if (!loadMore()) {
                _reportInvalidEOF(": was expecting closing '" + ((char) endChar) + "' for name");
            }
        }
        char c = _inputBuffer[_inputPtr++];
        if (c == endChar) {
            break;
        } else if (c == '!') {
            c = _decodeEscaped();
        }
        hash = (hash * 31) + c;
        // Ok, let's add char to output:
        outBuf[outPtr++] = c;

        // Need more room?
        if (outPtr >= outBuf.length) {
            outBuf = _textBuffer.finishCurrentSegment();
            outPtr = 0;
        }
    }
    _textBuffer.setCurrentLength(outPtr);
    {
        TextBuffer tb = _textBuffer;
        char[] buf = tb.getTextBuffer();
        int start = tb.getTextOffset();
        int len = tb.size();

        return _symbols.findSymbol(buf, start, len, hash);
    }
}