Package java.nio

Examples of java.nio.CharBuffer.arrayOffset()


                        decoder.onUnmappableCharacter(CodingErrorAction.REPORT);
                        try {
                            boolean bDecodeLoop = true;
                            while (bDecodeLoop) {
                                CoderResult result = decoder.decode(bb, cb, true);
                                sb.append(cb.array(), cb.arrayOffset(), cb.position());
                                cb.clear();
                                if (result == CoderResult.UNDERFLOW) {
                                       bDecodeLoop = false;
                                } else if (result.isError()) {
                                    bb.position(Math.min(bb.position() + result.length(), bb.limit()));
View Full Code Here


      return ((CharSequenceBackedByArray)seq).getChars();
    }

    if (seq instanceof CharBuffer) {
      final CharBuffer buffer = (CharBuffer)seq;
      if (buffer.hasArray() && !buffer.isReadOnly() && buffer.arrayOffset() == 0) {
        return buffer.array();
      }
    }

    return null;
View Full Code Here

      return ((CharSequenceBackedByArray)seq).getChars();
    }

    if (seq instanceof CharBuffer) {
      final CharBuffer buffer = (CharBuffer)seq;
      if (buffer.hasArray() && !buffer.isReadOnly() && buffer.arrayOffset() == 0) {
        return buffer.array();
        // final char[] bufArray = buffer.array();
        // return larger array. Clients may use seq.length() to calculate correct processing range.
        // if (bufArray.length == seq.length())
        // return bufArray;
View Full Code Here

        ((StringBuilder) csq).getChars(start, end, termBuffer, termLength);
      } else if (csq instanceof CharTermAttribute) {
        System.arraycopy(((CharTermAttribute) csq).buffer(), start, termBuffer, termLength, len);
      } else if (csq instanceof CharBuffer && ((CharBuffer) csq).hasArray()) {
        final CharBuffer cb = (CharBuffer) csq;
        System.arraycopy(cb.array(), cb.arrayOffset() + cb.position() + start, termBuffer, termLength, len);
      } else if (csq instanceof StringBuffer) {
        ((StringBuffer) csq).getChars(start, end, termBuffer, termLength);
      } else {
        while (start < end)
          termBuffer[termLength++] = csq.charAt(start++);
View Full Code Here

        // new String(byte[], int, int, Charset) takes a defensive copy of the
        // entire byte array. This is expensive if only a small subset of the
        // bytes will be used. The code below is from Apache Harmony.
        CharBuffer cb;
        cb = charset.decode(ByteBuffer.wrap(buff, start, end-start));
        return new String(cb.array(), cb.arrayOffset(), cb.length());
    }

    public long getLong() {
        return Ascii.parseLong(buff, start,end-start);
    }
View Full Code Here

        // new String(byte[], int, int, Charset) takes a defensive copy of the
        // entire byte array. This is expensive if only a small subset of the
        // bytes will be used. The code below is from Apache Harmony.
        CharBuffer cb;
        cb = charset.decode(ByteBuffer.wrap(buff, start, end-start));
        return new String(cb.array(), cb.arrayOffset(), cb.length());
    }

    public long getLong() {
        return Ascii.parseLong(buff, start,end-start);
    }
View Full Code Here

        if (string instanceof CharBuffer) {
            CharBuffer buf = (CharBuffer) string;
            if (buf.hasArray()) {
                return copiedBuffer(
                        buf.array(),
                        buf.arrayOffset() + buf.position() + offset,
                        length, charset);
            }

            buf = buf.slice();
            buf.limit(length);
View Full Code Here

        // new String(byte[], int, int, Charset) takes a defensive copy of the
        // entire byte array. This is expensive if only a small subset of the
        // bytes will be used. The code below is from Apache Harmony.
        CharBuffer cb;
        cb = charset.decode(ByteBuffer.wrap(buff, start, end-start));
        return new String(cb.array(), cb.arrayOffset(), cb.length());
    }

    /**
     * @deprecated Unused. Will be removed in Tomcat 8.0.x onwards.
     */
 
View Full Code Here

                        charBuffer = decoder.decode(buf);
                    } catch (CharacterCodingException e) {
                        throw Utils.asRuntime(e);
                    }
                    buf.limit(buf.capacity());
                    String s = new String(charBuffer.array(), charBuffer.arrayOffset(), charBuffer.limit());
                    buf.position(0);
                    return s;
                } else {
                    return "";
                }
View Full Code Here

            CharBuffer buf = (CharBuffer) string;
            if (buf.hasArray()) {
                return copiedBuffer(
                        endianness,
                        buf.array(),
                        buf.arrayOffset() + buf.position() + offset,
                        length, charset);
            }

            buf = buf.slice();
            buf.limit(length);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.