/** * Method called when character sequence to write is long enough that * its maximum encoded and escaped form is not guaranteed to fit in * the output buffer. If so, we will need to choose smaller output * chunks to write at a time. */ private final void _writeStringSegments(char[] cbuf, int offset, int totalLen) throws IOException, JsonGenerationException { do { int len = Math.min(_outputMaxContiguous, totalLen); if ((_outputTail + len) > _outputEnd) { // caller must ensure enough space _flushBuffer(); } _writeStringSegment(cbuf, offset, len); offset += len; totalLen -= len; } while (totalLen > 0); }
_flushBuffer(); _writeStringSegment(_charBuffer, 0, len); } else { _writeStringSegments(_charBuffer, 0, len);
_flushBuffer(); _writeStringSegment(_charBuffer, 0, len); } else { _writeStringSegments(_charBuffer, 0, len);
/** * Method called when String to write is long enough not to fit * completely in temporary copy buffer. If so, we will actually * copy it in small enough chunks so it can be directly fed * to single-segment writes (instead of maximum slices that * would fit in copy buffer) */ private final void _writeStringSegments(String text) throws IOException, JsonGenerationException { int left = text.length(); int offset = 0; final char[] cbuf = _charBuffer; while (left > 0) { int len = Math.min(_outputMaxContiguous, left); text.getChars(offset, offset+len, cbuf, 0); if ((_outputTail + len) > _outputEnd) { // caller must ensure enough space _flushBuffer(); } _writeStringSegment(cbuf, 0, len); offset += len; left -= len; } }
@Override public void writeString(char[] text, int offset, int len) throws IOException, JsonGenerationException { _verifyValueWrite("write text value"); if (_outputTail >= _outputEnd) { _flushBuffer(); } _outputBuffer[_outputTail++] = BYTE_QUOTE; // One or multiple segments? if (len <= _outputMaxContiguous) { if ((_outputTail + len) > _outputEnd) { // caller must ensure enough space _flushBuffer(); } _writeStringSegment(text, offset, len); } else { _writeStringSegments(text, offset, len); } // And finally, closing quotes if (_outputTail >= _outputEnd) { _flushBuffer(); } _outputBuffer[_outputTail++] = BYTE_QUOTE; }
_writeStringSegment(_charBuffer, 0, len); // we checked space already above
_flushBuffer(); _writeStringSegment(_charBuffer, 0, len); } else { _writeStringSegments(_charBuffer, 0, len);
/** * Method called when character sequence to write is long enough that * its maximum encoded and escaped form is not guaranteed to fit in * the output buffer. If so, we will need to choose smaller output * chunks to write at a time. */ private final void _writeStringSegments(char[] cbuf, int offset, int totalLen) throws IOException, JsonGenerationException { do { int len = Math.min(_outputMaxContiguous, totalLen); if ((_outputTail + len) > _outputEnd) { // caller must ensure enough space _flushBuffer(); } _writeStringSegment(cbuf, offset, len); offset += len; totalLen -= len; } while (totalLen > 0); }
_flushBuffer(); _writeStringSegment(_charBuffer, 0, len); } else { _writeStringSegments(_charBuffer, 0, len);
/** * Method called when String to write is long enough not to fit * completely in temporary copy buffer. If so, we will actually * copy it in small enough chunks so it can be directly fed * to single-segment writes (instead of maximum slices that * would fit in copy buffer) */ private final void _writeStringSegments(String text) throws IOException, JsonGenerationException { int left = text.length(); int offset = 0; final char[] cbuf = _charBuffer; while (left > 0) { int len = Math.min(_outputMaxContiguous, left); text.getChars(offset, offset+len, cbuf, 0); if ((_outputTail + len) > _outputEnd) { // caller must ensure enough space _flushBuffer(); } _writeStringSegment(cbuf, 0, len); offset += len; left -= len; } }
@Override public void writeString(char[] text, int offset, int len) throws IOException, JsonGenerationException { _verifyValueWrite("write text value"); if (_outputTail >= _outputEnd) { _flushBuffer(); } _outputBuffer[_outputTail++] = BYTE_QUOTE; // One or multiple segments? if (len <= _outputMaxContiguous) { if ((_outputTail + len) > _outputEnd) { // caller must ensure enough space _flushBuffer(); } _writeStringSegment(text, offset, len); } else { _writeStringSegments(text, offset, len); } // And finally, closing quotes if (_outputTail >= _outputEnd) { _flushBuffer(); } _outputBuffer[_outputTail++] = BYTE_QUOTE; }
_writeStringSegment(_charBuffer, 0, len); // we checked space already above
@Override public void writeString(char[] text, int offset, int len) throws IOException, JsonGenerationException { _verifyValueWrite("write text value"); if (_outputTail >= _outputEnd) { _flushBuffer(); } _outputBuffer[_outputTail++] = BYTE_QUOTE; // One or multiple segments? if (len <= _outputMaxContiguous) { if ((_outputTail + len) > _outputEnd) { // caller must ensure enough space _flushBuffer(); } _writeStringSegment(text, offset, len); } else { _writeStringSegments(text, offset, len); } // And finally, closing quotes if (_outputTail >= _outputEnd) { _flushBuffer(); } _outputBuffer[_outputTail++] = BYTE_QUOTE; }
/** * Method called when character sequence to write is long enough that * its maximum encoded and escaped form is not guaranteed to fit in * the output buffer. If so, we will need to choose smaller output * chunks to write at a time. */ private final void _writeStringSegments(char[] cbuf, int offset, int totalLen) throws IOException, JsonGenerationException { do { int len = Math.min(_outputMaxContiguous, totalLen); if ((_outputTail + len) > _outputEnd) { // caller must ensure enough space _flushBuffer(); } _writeStringSegment(cbuf, offset, len); offset += len; totalLen -= len; } while (totalLen > 0); }
@Override public void writeString(char[] text, int offset, int len) throws IOException, JsonGenerationException { _verifyValueWrite("write text value"); if (_outputTail >= _outputEnd) { _flushBuffer(); } _outputBuffer[_outputTail++] = BYTE_QUOTE; // One or multiple segments? if (len <= _outputMaxContiguous) { if ((_outputTail + len) > _outputEnd) { // caller must ensure enough space _flushBuffer(); } _writeStringSegment(text, offset, len); } else { _writeStringSegments(text, offset, len); } // And finally, closing quotes if (_outputTail >= _outputEnd) { _flushBuffer(); } _outputBuffer[_outputTail++] = BYTE_QUOTE; }
/** * Method called when character sequence to write is long enough that * its maximum encoded and escaped form is not guaranteed to fit in * the output buffer. If so, we will need to choose smaller output * chunks to write at a time. */ private final void _writeStringSegments(char[] cbuf, int offset, int totalLen) throws IOException, JsonGenerationException { do { int len = Math.min(_outputMaxContiguous, totalLen); if ((_outputTail + len) > _outputEnd) { // caller must ensure enough space _flushBuffer(); } _writeStringSegment(cbuf, offset, len); offset += len; totalLen -= len; } while (totalLen > 0); }
/** * Method called when String to write is long enough not to fit * completely in temporary copy buffer. If so, we will actually * copy it in small enough chunks so it can be directly fed * to single-segment writes (instead of maximum slices that * would fit in copy buffer) */ private final void _writeStringSegments(String text) throws IOException, JsonGenerationException { int left = text.length(); int offset = 0; final char[] cbuf = _charBuffer; while (left > 0) { int len = Math.min(_outputMaxContiguous, left); text.getChars(offset, offset+len, cbuf, 0); if ((_outputTail + len) > _outputEnd) { // caller must ensure enough space _flushBuffer(); } _writeStringSegment(cbuf, 0, len); offset += len; left -= len; } }
/** * Method called when String to write is long enough not to fit * completely in temporary copy buffer. If so, we will actually * copy it in small enough chunks so it can be directly fed * to single-segment writes (instead of maximum slices that * would fit in copy buffer) */ private final void _writeStringSegments(String text) throws IOException, JsonGenerationException { int left = text.length(); int offset = 0; final char[] cbuf = _charBuffer; while (left > 0) { int len = Math.min(_outputMaxContiguous, left); text.getChars(offset, offset+len, cbuf, 0); if ((_outputTail + len) > _outputEnd) { // caller must ensure enough space _flushBuffer(); } _writeStringSegment(cbuf, 0, len); offset += len; left -= len; } }
@Override public void writeString(String text) throws IOException, JsonGenerationException { _verifyValueWrite("write text value"); if (text == null) { _writeNull(); return; } // First: can we make a local copy of chars that make up text? final int len = text.length(); if (len > _charBufferLength) { // nope: off-line handling _writeLongString(text); return; } // yes: good. text.getChars(0, len, _charBuffer, 0); // Output: if we can't guarantee it fits in output buffer, off-line as well: if (len > _outputMaxContiguous) { _writeLongString(_charBuffer, 0, len); return; } if ((_outputTail + len + 2) > _outputEnd) { _flushBuffer(); } _outputBuffer[_outputTail++] = BYTE_QUOTE; _writeStringSegment(_charBuffer, 0, len); // we checked space already above _outputBuffer[_outputTail++] = BYTE_QUOTE; }
@Override public void writeString(String text) throws IOException, JsonGenerationException { _verifyValueWrite("write text value"); if (text == null) { _writeNull(); return; } // First: can we make a local copy of chars that make up text? final int len = text.length(); if (len > _charBufferLength) { // nope: off-line handling _writeLongString(text); return; } // yes: good. text.getChars(0, len, _charBuffer, 0); // Output: if we can't guarantee it fits in output buffer, off-line as well: if (len > _outputMaxContiguous) { _writeLongString(_charBuffer, 0, len); return; } if ((_outputTail + len + 2) > _outputEnd) { _flushBuffer(); } _outputBuffer[_outputTail++] = BYTE_QUOTE; _writeStringSegment(_charBuffer, 0, len); // we checked space already above _outputBuffer[_outputTail++] = BYTE_QUOTE; }