Package com.cloudhopper.commons.charset.CharSequenceAccessor

Examples of com.cloudhopper.commons.charset.CharSequenceAccessor.CharArrayWrapper


    @Override
    public byte[] encode(CharSequence charSeq) {
        if (charSeq == null) {
            return null;
        }
        CharArrayWrapper wrapper = CharSequenceAccessor.access(charSeq);
        if (wrapper != null) {
            // use more efficient direct access to char array using the wrapper
            int utf8len = calculateByteLength(null, wrapper.value, wrapper.offset, wrapper.length);
            byte[] buf = new byte[utf8len];
            encodeToByteArray(null, wrapper.value, wrapper.offset, wrapper.length, buf, 0);
View Full Code Here


        if (bytes == null) {
            return;
        }
        // expand buffer as necessary to support all possible UTF-8 bytes
        buffer.ensureCapacity(buffer.length()+bytes.length);
        CharArrayWrapper wrapper = CharSequenceAccessor.access(buffer);
        // since we want to mimic an "append", the "length" of the existing char
        // array represents how much data is currently contained inside it
        // we'll start our "append" at that offset
        int charLength = decodeToCharArray(bytes, 0, bytes.length, wrapper.value, wrapper.length);
        // the "wrapper" is merely prepped for reading
View Full Code Here

TOP

Related Classes of com.cloudhopper.commons.charset.CharSequenceAccessor.CharArrayWrapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.