public final class JsonStringEncoder extends Object
Note that methods in here are somewhat optimized, but not ridiculously so. Reason is that conversion method results are expected to be cached so that these methods will not be hot spots during normal operation.
限定符和类型 | 字段和说明 |
---|---|
protected ByteArrayBuilder |
_byteBuilder
Lazily-constructed builder used for UTF-8 encoding of text values
(quoted and unquoted)
|
protected char[] |
_quoteBuffer
Temporary buffer used for composing quote/escape sequences
|
protected TextBuffer |
_textBuffer
Lazily constructed text buffer used to produce JSON encoded Strings
as characters (without UTF-8 encoding)
|
protected static ThreadLocal<SoftReference<JsonStringEncoder>> |
_threadEncoder
This
ThreadLocal contains a SoftRerefence
to a BufferRecycler used to provide a low-cost
buffer recycling between reader and writer instances. |
构造器和说明 |
---|
JsonStringEncoder() |
限定符和类型 | 方法和说明 |
---|---|
byte[] |
encodeAsUTF8(String text)
Will encode given String as UTF-8 (without any quoting), return
resulting byte array.
|
static JsonStringEncoder |
getInstance()
Factory method for getting an instance; this is either recycled per-thread instance,
or a newly constructed one.
|
char[] |
quoteAsString(String input)
Method that will quote text contents using JSON standard quoting,
and return results as a character array
|
byte[] |
quoteAsUTF8(String text)
Will quote given JSON String value using standard quoting, encode
results as UTF-8, and return result as a byte array.
|
protected static final ThreadLocal<SoftReference<JsonStringEncoder>> _threadEncoder
ThreadLocal
contains a SoftRerefence
to a BufferRecycler
used to provide a low-cost
buffer recycling between reader and writer instances.protected TextBuffer _textBuffer
protected ByteArrayBuilder _byteBuilder
protected final char[] _quoteBuffer
public static JsonStringEncoder getInstance()
public char[] quoteAsString(String input)
public byte[] quoteAsUTF8(String text)
public byte[] encodeAsUTF8(String text)