CharBuffer arrayOffset - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for CharBuffer arrayOffset method.

This code example shows how to use the following methods:limit, position, array, arrayOffset
            byte[] sa = src.array();
            int sp = src.arrayOffset() + src.position();
            int sl = src.arrayOffset() + src.limit();
            assert (sp <= sl);
            sp = (sp <= sl ? sp : sl);
            char[] da = dst.array();
            int dp = dst.arrayOffset() + dst.position();
            int dl = dst.arrayOffset() + dst.limit();
            assert (dp <= dl);
            dp = (dp <= dl ? dp : dl);
 
 
            try { 
                while (sp < sl) {
                    if ( sl - sp < 2) {
                        return CoderResult.UNDERFLOW;
                    } 
                    int b1 = sa[sp] & 0xFF | 0x80;
                    int b2 = sa[sp + 1] & 0xFF | 0x80;
                    char c = decodeDouble(b1, b2);

7
CodeRank
This code example shows how to use the following methods:limit, position, array, arrayOffset, hasArray
            return 0; 
        } 
    } 
 
    private final int getArray(CharBuffer in) {
        if(in.hasArray()){
            // BEGIN android-changed: take arrayOffset into account 
            input = in.array();
            inEnd = in.arrayOffset() + in.limit();
            return in.arrayOffset() + in.position() + savedInputHeldLen;/*exclude the number fo bytes held in previous conversion*/
            // END android-changed 
        }else{ 
            inEnd = in.remaining();
            // BEGIN android-added 
            if (allocatedInput == null || (inEnd > allocatedInput.length)) {
                allocatedInput = new char[inEnd];
            } 
            input = allocatedInput;
            // END android-added 
            // save the current position 

7
CodeRank
This code example shows how to use the following methods:limit, position, array, arrayOffset, hasArray
    //------------------------------------------ 
    // private utility methods 
    //------------------------------------------ 
 
    private final int getArray(CharBuffer out){
        if(out.hasArray()){
            // BEGIN android-changed: take arrayOffset into account 
            output = out.array();
            outEnd = out.arrayOffset() + out.limit();
            return out.arrayOffset() + out.position();
            // END android-changed 
        }else{ 
            outEnd = out.remaining();
            // BEGIN android-added 
            if (allocatedOutput == null || (outEnd > allocatedOutput.length)) {
                allocatedOutput = new char[outEnd];
            } 
            output = allocatedOutput;
            // END android-added 
            //since the new  
7
CodeRank
This code example shows how to use the following methods:array, arrayOffset, hasArray, limit
   *             method will be removed in Lucene 4.0 
   */ 
  @Deprecated 
  public static int getDecodedLength(CharBuffer encoded) 
    throws IllegalArgumentException {
    if (encoded.hasArray()) {
      return getDecodedLength(encoded.array(), encoded.arrayOffset(), 
          encoded.limit() - encoded.arrayOffset());
    } else { 
      throw new IllegalArgumentException("encoded argument must have a backing array");
    } 
  } 
   
  /** 
   * Returns the number of bytes required to decode the given char sequence. 
   *  
   * @param encoded char sequence to be decoded 
   * @param offset initial offset 
   * @param length number of characters 
   * @return The number of bytes required to decode the given char sequence 
6
CodeRank
This code example shows how to use the following methods:arrayOffset, limit, position
      } 
    } 
  } 
 
  public void append(CharBuffer buffer) throws IOException {
    append(buffer, buffer.arrayOffset() + buffer.position(), buffer.limit() - buffer.arrayOffset());
  } 
} 
6
CodeRank
This code example shows how to use the following methods:array, arrayOffset, hasArray, position, remaining
            option.setNull();
        } 
    } 
 
    private BigDecimal toBigDecimal() {
        if (lineBuffer.hasArray()) {
            char[] array = lineBuffer.array();
            int offset = lineBuffer.arrayOffset() + lineBuffer.position();
            int length = lineBuffer.remaining();
            return new BigDecimal(array, offset, length);
        } else { 
            return new BigDecimal(lineBuffer.toString());
        } 
    } 
 
    @SuppressWarnings("deprecation") 
    @Override 
    public void fill(StringOption option) throws CsvFormatException, IOException {
        seekBuffer(); 
        if (lineBuffer.hasRemaining()) {
6
CodeRank
This code example shows how to use the following methods:limit, array, arrayOffset, CharBuffer.position
            byte[] sa = src.array();
            int sp = src.arrayOffset() + src.position();
            int sl = src.arrayOffset() + src.limit();
            assert (sp <= sl);
            sp = (sp <= sl ? sp : sl);
            char[] da = dst.array();
            int dp = dst.arrayOffset() + dst.position();
            int dl = dst.arrayOffset() + dst.limit();
            assert (dp <= dl);
            dp = (dp <= dl ? dp : dl);
 
 
            try { 
                while (sp < sl) {
                    if ( sl - sp < 2) {
                        return CoderResult.UNDERFLOW;
                    } 
                    int b1 = sa[sp] & 0xFF | 0x80;
                    int b2 = sa[sp + 1] & 0xFF | 0x80;
                    char c = decodeDouble(b1, b2);

6
CodeRank
This code example shows how to use the following methods:array, arrayOffset, capacity, clear, flip
 
        // normal case, one complete operation, but call twice, first time set 
        // endOfInput to false 
        decoder.reset();
        in.rewind();
        out.clear();
        assertSame(CoderResult.UNDERFLOW, decoder.decode(in, out, false));
        assertEquals(out.limit(), 100);
        assertEquals(out.position(), getString().length());
        assertEquals(out.remaining(), 100 - getString().length());
        assertEquals(out.capacity(), 100);
        assertCharBufferValue(getString(), out);
 
        decoder.reset();
        in.rewind();
        out.clear();
        assertSame(CoderResult.UNDERFLOW, decoder.decode(in, out, false));
        in = getHeadlessByteBuffer();
        assertSame(CoderResult.UNDERFLOW, decoder.decode(in, out, false));
        in.rewind();

6
CodeRank
This code example shows how to use the following methods:limit, position, array, arrayOffset, hasArray
            return 0; 
        } 
    } 
 
    private final int getArray(CharBuffer in) {
        if(in.hasArray()){
            // BEGIN android-changed: take arrayOffset into account 
            input = in.array();
            inEnd = in.arrayOffset() + in.limit();
            return in.arrayOffset() + in.position() + savedInputHeldLen;/*exclude the number fo bytes held in previous conversion*/
            // END android-changed 
        }else{ 
            inEnd = in.remaining();
            // BEGIN android-added 
            if (allocatedInput == null || (inEnd > allocatedInput.length)) {
                allocatedInput = new char[inEnd];
            } 
            input = allocatedInput;
            // END android-added 
            // save the current position 

6
CodeRank
This code example shows how to use the following methods:array, arrayOffset, hasArray, isReadOnly, position
      return ((CharSequenceBackedByArray)seq).getChars();
    } 
 
    if (seq instanceof CharBuffer) {
      final CharBuffer buffer = (CharBuffer)seq;
      if (buffer.hasArray() && !buffer.isReadOnly() && buffer.arrayOffset() == 0 && buffer.position() == 0) {
        return buffer.array();
      } 
    } 
 
    return null; 
  } 
 
  /** 
   * @return the underlying char[] array if any, or the new chara array if not 
   */ 
  @NotNull 
  public static char[] fromSequence(@NotNull CharSequence seq) {
    char[] underlying = fromSequenceWithoutCopying(seq);
    return underlying != null ? Arrays.copyOf(underlying, underlying.length) : fromSequence(seq, 0, seq.length());
5
CodeRank
arrayOffset Method Overview
Returns the offset within this buffer's backing array of the first element of the buffer  (optional operation).
See Code Examples for other Java 8 CharBuffer Methods: