protected final void _writeString(char[] text, int offset, int len) throws IOException _ensureSpace(MAX_SHORT_STRING_BYTES); // can afford approximate length int actual = _encode(_outputTail+1, text, offset, offset+len); final byte[] buf = _outputBuffer; _ensureSpace(MAX_MEDIUM_STRING_BYTES); // short enough, can approximate int actual = _encode(_outputTail+2, text, offset, offset+len); final byte[] buf = _outputBuffer; _ensureSpace(MAX_LONG_STRING_BYTES); // calculate accurate length to avoid extra flushing int ix = _outputTail; int actual = _encode(ix+3, text, offset, offset+len);
protected final void _writeString(char[] text, int offset, int len) throws IOException _ensureSpace(MAX_SHORT_STRING_BYTES); // can afford approximate length int actual = _encode(_outputTail+1, text, offset, offset+len); final byte[] buf = _outputBuffer; _ensureSpace(MAX_MEDIUM_STRING_BYTES); // short enough, can approximate int actual = _encode(_outputTail+2, text, offset, offset+len); final byte[] buf = _outputBuffer; _ensureSpace(MAX_LONG_STRING_BYTES); // calculate accurate length to avoid extra flushing int ix = _outputTail; int actual = _encode(ix+3, text, offset, offset+len);
_ensureSpace(MAX_SHORT_STRING_BYTES); // can afford approximate length int actual = _encode(_outputTail+1, name, len); final byte[] buf = _outputBuffer;
_ensureSpace(MAX_SHORT_STRING_BYTES); // can afford approximate length int actual = _encode(_outputTail+1, name, len); final byte[] buf = _outputBuffer;
_ensureSpace(MAX_SHORT_STRING_BYTES); // can afford approximate length int actual = _encode(_outputTail + 1, text, offset, offset + len); final byte[] buf = _outputBuffer; _ensureSpace(MAX_MEDIUM_STRING_BYTES); // short enough, can approximate int actual = _encode(_outputTail + 2, text, offset, offset + len); final byte[] buf = _outputBuffer; _ensureSpace(MAX_LONG_STRING_BYTES); // calculate accurate length to
_ensureSpace(MAX_SHORT_STRING_BYTES); // can afford approximate
protected final void _writeChunkedString(char[] text, int offset, int len) throws IOException { // need to use a marker first _writeByte(BYTE_STRING_INDEFINITE); while (len > MAX_LONG_STRING_CHARS) { _ensureSpace(MAX_LONG_STRING_BYTES); // marker and single-byte length? int ix = _outputTail; int actual = _encode(_outputTail+3, text, offset, offset+MAX_LONG_STRING_CHARS); final byte[] buf = _outputBuffer; buf[ix++] = BYTE_STRING_2BYTE_LEN; buf[ix++] = (byte) (actual >> 8); buf[ix++] = (byte) actual; _outputTail = ix+actual; offset += MAX_LONG_STRING_CHARS; len -= MAX_LONG_STRING_CHARS; } // and for the last chunk, just use recursion if (len > 0) { _writeString(text, offset, len); } // plus end marker _writeByte(BYTE_BREAK); }
protected final void _writeChunkedString(char[] text, int offset, int len) throws IOException { // need to use a marker first _writeByte(BYTE_STRING_INDEFINITE); while (len > MAX_LONG_STRING_CHARS) { _ensureSpace(MAX_LONG_STRING_BYTES); // marker and single-byte length? int ix = _outputTail; int actual = _encode(_outputTail+3, text, offset, offset+MAX_LONG_STRING_CHARS); final byte[] buf = _outputBuffer; buf[ix++] = BYTE_STRING_2BYTE_LEN; buf[ix++] = (byte) (actual >> 8); buf[ix++] = (byte) actual; _outputTail = ix+actual; offset += MAX_LONG_STRING_CHARS; len -= MAX_LONG_STRING_CHARS; } // and for the last chunk, just use recursion if (len > 0) { _writeString(text, offset, len); } // plus end marker _writeByte(BYTE_BREAK); }
_ensureSpace(MAX_LONG_STRING_BYTES); // marker and single-byte length? int ix = _outputTail; int amount = MAX_LONG_STRING_CHARS;