/** * Factory method for getting an instance; this is either recycled per-thread instance, * or a newly constructed one. * * @deprecated Since 2.9.2 use {@link BufferRecyclers#getJsonStringEncoder()} instead */ @Deprecated public static JsonStringEncoder getInstance() { return BufferRecyclers.getJsonStringEncoder(); }
/** * Accessor for accessing value that has been quoted using JSON * quoting rules, and encoded using UTF-8 encoding. */ @Override public final byte[] asUnquotedUTF8() { byte[] result = _unquotedUTF8Ref; if (result == null) { result = BufferRecyclers.encodeAsUTF8(_value); _unquotedUTF8Ref = result; } return result; }
@Override public final char[] asQuotedChars() { char[] result = _quotedChars; if (result == null) { result = BufferRecyclers.quoteAsJsonText(_value); _quotedChars = result; } return result; }
/** * Accessor for accessing value as is (without JSON quoting) * encoded using UTF-8 encoding. */ @Override public final byte[] asQuotedUTF8() { byte[] result = _quotedUTF8Ref; if (result == null) { result = BufferRecyclers.quoteAsJsonUTF8(_value); _quotedUTF8Ref = result; } return result; }
/** * Method used by factory to create buffer recycler instances * for parsers and generators. *<p> * Note: only public to give access for <code>ObjectMapper</code> */ public BufferRecycler _getBufferRecycler() { /* 23-Apr-2015, tatu: Let's allow disabling of buffer recycling * scheme, for cases where it is considered harmful (possibly * on Android, for example) */ if (Feature.USE_THREAD_LOCAL_FOR_BUFFER_RECYCLING.enabledIn(_factoryFeatures)) { return BufferRecyclers.getBufferRecycler(); } return new BufferRecycler(); }
@Override public int writeQuotedUTF8(OutputStream out) throws IOException { byte[] result = _quotedUTF8Ref; if (result == null) { result = BufferRecyclers.quoteAsJsonUTF8(_value); _quotedUTF8Ref = result; } final int length = result.length; out.write(result, 0, length); return length; }
/** * Method used by factory to create buffer recycler instances * for parsers and generators. *<p> * Note: only public to give access for <code>ObjectMapper</code> */ public BufferRecycler _getBufferRecycler() { /* 23-Apr-2015, tatu: Let's allow disabling of buffer recycling * scheme, for cases where it is considered harmful (possibly * on Android, for example) */ if (Feature.USE_THREAD_LOCAL_FOR_BUFFER_RECYCLING.enabledIn(_factoryFeatures)) { return BufferRecyclers.getBufferRecycler(); } return new BufferRecycler(); }
/** * Factory method for getting an instance; this is either recycled per-thread instance, * or a newly constructed one. * * @deprecated Since 2.9.2 use {@link BufferRecyclers#getJsonStringEncoder()} instead */ @Deprecated public static JsonStringEncoder getInstance() { return BufferRecyclers.getJsonStringEncoder(); }
@Override public int writeUnquotedUTF8(OutputStream out) throws IOException { byte[] result = _unquotedUTF8Ref; if (result == null) { result = BufferRecyclers.encodeAsUTF8(_value); _unquotedUTF8Ref = result; } final int length = result.length; out.write(result, 0, length); return length; }
/** * Accessor for accessing value that has been quoted using JSON * quoting rules, and encoded using UTF-8 encoding. */ @Override public final byte[] asQuotedUTF8() { byte[] result = _quotedUTF8Ref; if (result == null) { result = BufferRecyclers.quoteAsJsonUTF8(_value); _quotedUTF8Ref = result; } return result; }
@Override public final char[] asQuotedChars() { char[] result = _quotedChars; if (result == null) { result = BufferRecyclers.quoteAsJsonText(_value); _quotedChars = result; } return result; }
/** * Method used by factory to create buffer recycler instances * for parsers and generators. *<p> * Note: only public to give access for <code>ObjectMapper</code> */ public BufferRecycler _getBufferRecycler() { /* 23-Apr-2015, tatu: Let's allow disabling of buffer recycling * scheme, for cases where it is considered harmful (possibly * on Android, for example) */ if (Feature.USE_THREAD_LOCAL_FOR_BUFFER_RECYCLING.enabledIn(_factoryFeatures)) { return BufferRecyclers.getBufferRecycler(); } return new BufferRecycler(); }
/** * @since 2.9.4 */ public static void quoteAsJsonText(CharSequence input, StringBuilder output) { getJsonStringEncoder().quoteAsString(input, output); }
/** * Accessor for accessing value as is (without JSON quoting) * encoded using UTF-8 encoding. */ @Override public final byte[] asUnquotedUTF8() { byte[] result = _unquotedUTF8Ref; if (result == null) { result = BufferRecyclers.encodeAsUTF8(_value); _unquotedUTF8Ref = result; } return result; }
@Override public int appendQuotedUTF8(byte[] buffer, int offset) { byte[] result = _quotedUTF8Ref; if (result == null) { result = BufferRecyclers.quoteAsJsonUTF8(_value); _quotedUTF8Ref = result; } final int length = result.length; if ((offset + length) > buffer.length) { return -1; } System.arraycopy(result, 0, buffer, offset, length); return length; }
@Override public int appendQuoted(char[] buffer, int offset) { char[] result = _quotedChars; if (result == null) { result = BufferRecyclers.quoteAsJsonText(_value); _quotedChars = result; } final int length = result.length; if ((offset + length) > buffer.length) { return -1; } System.arraycopy(result, 0, buffer, offset, length); return length; }
/** * Helper method for encoding given String as UTF-8 encoded * * @since 2.9.4 */ public static byte[] encodeAsUTF8(String text) { return getJsonStringEncoder().encodeAsUTF8(text); }
@Override public int appendUnquotedUTF8(byte[] buffer, int offset) { byte[] result = _unquotedUTF8Ref; if (result == null) { result = BufferRecyclers.encodeAsUTF8(_value); _unquotedUTF8Ref = result; } final int length = result.length; if ((offset + length) > buffer.length) { return -1; } System.arraycopy(result, 0, buffer, offset, length); return length; }
@Override public int putQuotedUTF8(ByteBuffer buffer) { byte[] result = _quotedUTF8Ref; if (result == null) { result = BufferRecyclers.quoteAsJsonUTF8(_value); _quotedUTF8Ref = result; } final int length = result.length; if (length > buffer.remaining()) { return -1; } buffer.put(result, 0, length); return length; }
@Override public int appendQuoted(char[] buffer, int offset) { char[] result = _quotedChars; if (result == null) { result = BufferRecyclers.quoteAsJsonText(_value); _quotedChars = result; } final int length = result.length; if ((offset + length) > buffer.length) { return -1; } System.arraycopy(result, 0, buffer, offset, length); return length; }