com.fasterxml.jackson.core.util.BufferRecyclers Java Examples
The following examples show how to use
com.fasterxml.jackson.core.util.BufferRecyclers.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JsonFactory.java From lams with GNU General Public License v2.0 | 5 votes |
/** * 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(); }
Example #2
Source File: SerializedString.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public final char[] asQuotedChars() { char[] result = _quotedChars; if (result == null) { result = BufferRecyclers.quoteAsJsonText(_value); _quotedChars = result; } return result; }
Example #3
Source File: SerializedString.java From lams with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #4
Source File: SerializedString.java From lams with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #5
Source File: SerializedString.java From lams with GNU General Public License v2.0 | 5 votes |
@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; }
Example #6
Source File: SerializedString.java From lams with GNU General Public License v2.0 | 5 votes |
@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; }
Example #7
Source File: SerializedString.java From lams with GNU General Public License v2.0 | 5 votes |
@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; }
Example #8
Source File: SerializedString.java From lams with GNU General Public License v2.0 | 5 votes |
@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; }
Example #9
Source File: SerializedString.java From lams with GNU General Public License v2.0 | 5 votes |
@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; }
Example #10
Source File: SerializedString.java From lams with GNU General Public License v2.0 | 5 votes |
@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; }
Example #11
Source File: SerializedString.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public int putUnquotedUTF8(ByteBuffer buffer) { byte[] result = _unquotedUTF8Ref; if (result == null) { result = BufferRecyclers.encodeAsUTF8(_value); _unquotedUTF8Ref = result; } final int length = result.length; if (length > buffer.remaining()) { return -1; } buffer.put(result, 0, length); return length; }
Example #12
Source File: CodeRange.java From RefactoringMiner with MIT License | 5 votes |
private String escapeQuotes(String s) { if(s != null) { StringBuilder sb = new StringBuilder(); JsonStringEncoder encoder = BufferRecyclers.getJsonStringEncoder(); encoder.quoteAsString(s, sb); return sb.toString(); } return s; }
Example #13
Source File: Refactoring.java From RefactoringMiner with MIT License | 5 votes |
default public String toJSON() { StringBuilder sb = new StringBuilder(); JsonStringEncoder encoder = BufferRecyclers.getJsonStringEncoder(); sb.append("{").append("\n"); sb.append("\t").append("\"").append("type").append("\"").append(": ").append("\"").append(getName()).append("\"").append(",").append("\n"); sb.append("\t").append("\"").append("description").append("\"").append(": ").append("\""); encoder.quoteAsString(toString().replace('\t', ' '), sb); sb.append("\"").append(",").append("\n"); sb.append("\t").append("\"").append("leftSideLocations").append("\"").append(": ").append(leftSide()).append(",").append("\n"); sb.append("\t").append("\"").append("rightSideLocations").append("\"").append(": ").append(rightSide()).append("\n"); sb.append("}"); return sb.toString(); }
Example #14
Source File: ICALToJsonAttributeTest.java From james-project with Apache License 2.0 | 4 votes |
private String toJsonValue(byte[] ics) { return new String(BufferRecyclers.getJsonStringEncoder().quoteAsUTF8(new String(ics, StandardCharsets.UTF_8)), StandardCharsets.UTF_8); }
Example #15
Source File: JsonStringEncoder.java From lams with GNU General Public License v2.0 | 2 votes |
/** * 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(); }