Java Code Examples for com.fasterxml.jackson.core.util.BufferRecyclers#encodeAsUTF8()

The following examples show how to use com.fasterxml.jackson.core.util.BufferRecyclers#encodeAsUTF8() . 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: SerializedString.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 2
Source File: SerializedString.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@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 3
Source File: SerializedString.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@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 4
Source File: SerializedString.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@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;
}