State next()

in src/main/java/com/alibaba/com/caucho/hessian/io/HessianDebugState.java [1237:1296]


        State next(int ch) {
            if (_lengthIndex < 2) {
                _length = 256 * _length + (ch & 0xff);

                if (++_lengthIndex == 2 && _length == 0 && _isLastChunk) {
                    String value = "binary(" + _totalLength + ")";

                    if (_next.isShift(value))
                        return _next.shift(value);
                    else {
                        printObject(value);
                        return _next;
                    }
                } else
                    return this;
            } else if (_length == 0) {
                if (ch == 'b') {
                    _isLastChunk = false;
                    _lengthIndex = 0;
                    return this;
                } else if (ch == 'B') {
                    _isLastChunk = true;
                    _lengthIndex = 0;
                    return this;
                } else if (ch == 0x20) {
                    String value = "binary(" + _totalLength + ")";

                    if (_next.isShift(value))
                        return _next.shift(value);
                    else {
                        printObject(value);
                        return _next;
                    }
                } else if (0x20 <= ch && ch < 0x30) {
                    _isLastChunk = true;
                    _lengthIndex = 2;
                    _length = (ch & 0xff) - 0x20;
                    return this;
                } else {
                    println(String.valueOf((char) ch) + ": unexpected character");
                    return _next;
                }
            }

            _length--;
            _totalLength++;

            if (_length == 0 && _isLastChunk) {
                String value = "binary(" + _totalLength + ")";

                if (_next.isShift(value))
                    return _next.shift(value);
                else {
                    printObject(value);

                    return _next;
                }
            } else
                return this;
        }