protected Writer _createWriter(OutputStream out, JsonEncoding enc, IOContext ctxt) throws IOException { // note: this should not get called any more (caller checks, dispatches) if (enc == JsonEncoding.UTF8) { // We have optimized writer for UTF-8 return new UTF8Writer(ctxt, out); } // not optimal, but should do unless we really care about UTF-16/32 encoding speed return new OutputStreamWriter(out, enc.getJavaName()); }
write(cbuf[off]); char second = cbuf[off++]; --len; write(convertSurrogate(second)); illegalSurrogate(c); break; c = convertSurrogate(cbuf[off++]); if (c > 0x10FFFF) { // illegal in JSON as well as in XML _outPtr = outPtr; illegalSurrogate(c);
private static void _illegal(int c) { throw new IllegalArgumentException(UTF8Writer.illegalSurrogateDesc(c)); } }
c = convertSurrogate(c); illegalSurrogate(c); } else { // 4 bytes if (c > 0x10FFFF) { // illegal illegalSurrogate(c);
@Override public Writer append(char c) throws IOException { write(c); return this; }
write(cbuf[off]); char second = cbuf[off++]; --len; write(convertSurrogate(second)); throwIllegal(c); break; c = convertSurrogate(cbuf[off++]); if (c > 0x10FFFF) { // illegal in JSON as well as in XML _outPtr = outPtr; throwIllegal(c);
c = convertSurrogate(c); throwIllegal(c); } else { // 4 bytes if (c > 0x10FFFF) { // illegal throwIllegal(c);
@Override public void close() throws IOException { if (_out != null) { if (_outPtr > 0) { _out.write(_outBuffer, 0, _outPtr); _outPtr = 0; } OutputStream out = _out; _out = null; byte[] buf = _outBuffer; if (buf != null) { _outBuffer = null; _context.releaseWriteEncodingBuffer(buf); } out.close(); /* Let's 'flush' orphan surrogate, no matter what; but only * after cleanly closing everything else. */ int code = _surrogate; _surrogate = 0; if (code > 0) { illegalSurrogate(code); } } }
@Override public void close() throws IOException { if (_out != null) { if (_outPtr > 0) { _out.write(_outBuffer, 0, _outPtr); _outPtr = 0; } OutputStream out = _out; _out = null; byte[] buf = _outBuffer; if (buf != null) { _outBuffer = null; _context.releaseWriteEncodingBuffer(buf); } out.close(); /* Let's 'flush' orphan surrogate, no matter what; but only * after cleanly closing everything else. */ int code = _surrogate; _surrogate = 0; if (code > 0) { throwIllegal(code); } } }
@Override public void write(char[] cbuf) throws IOException { write(cbuf, 0, cbuf.length); }
write(cbuf[off]); char second = cbuf[off++]; --len; write(convertSurrogate(second)); throwIllegal(c); break; c = convertSurrogate(cbuf[off++]); if (c > 0x10FFFF) { // illegal in JSON as well as in XML _outPtr = outPtr; throwIllegal(c);
c = convertSurrogate(c); illegalSurrogate(c); } else { // 4 bytes if (c > 0x10FFFF) { // illegal illegalSurrogate(c);
c = convertSurrogate(c); throwIllegal(c); } else { // 4 bytes if (c > 0x10FFFF) { // illegal throwIllegal(c);
@Override public void close() throws IOException { if (_out != null) { if (_outPtr > 0) { _out.write(_outBuffer, 0, _outPtr); _outPtr = 0; } OutputStream out = _out; _out = null; byte[] buf = _outBuffer; if (buf != null) { _outBuffer = null; _context.releaseWriteEncodingBuffer(buf); } out.close(); /* Let's 'flush' orphan surrogate, no matter what; but only * after cleanly closing everything else. */ int code = _surrogate; _surrogate = 0; if (code > 0) { illegalSurrogate(code); } } }
@Override public void close() throws IOException { if (_out != null) { if (_outPtr > 0) { _out.write(_outBuffer, 0, _outPtr); _outPtr = 0; } OutputStream out = _out; _out = null; byte[] buf = _outBuffer; if (buf != null) { _outBuffer = null; _context.releaseWriteEncodingBuffer(buf); } out.close(); /* Let's 'flush' orphan surrogate, no matter what; but only * after cleanly closing everything else. */ int code = _surrogate; _surrogate = 0; if (code > 0) { throwIllegal(code); } } }
write(str.charAt(off)); char second = str.charAt(off++); --len; write(convertSurrogate(second)); illegalSurrogate(c); break; c = convertSurrogate(str.charAt(off++)); if (c > 0x10FFFF) { // illegal, as per RFC 4627 _outPtr = outPtr; illegalSurrogate(c);
@Override public Writer append(char c) throws IOException { write(c); return this; }
write(str.charAt(off)); char second = str.charAt(off++); --len; write(convertSurrogate(second)); throwIllegal(c); break; c = convertSurrogate(str.charAt(off++)); if (c > 0x10FFFF) { // illegal, as per RFC 4627 _outPtr = outPtr; throwIllegal(c);
c = convertSurrogate(c); illegalSurrogate(c); } else { // 4 bytes if (c > 0x10FFFF) { // illegal illegalSurrogate(c);
protected Writer _createWriter(IOContext ioCtxt, OutputStream out, JsonEncoding enc) throws IOException { // note: this should not get called any more (caller checks, dispatches) if (enc == JsonEncoding.UTF8) { // We have optimized writer for UTF-8 return new UTF8Writer(ioCtxt, out); } // not optimal, but should do unless we really care about UTF-16/32 encoding speed return new OutputStreamWriter(out, enc.getJavaName()); } }