Build 1.0_r1(from source)

java.nio
Class CharArrayBuffer

java.lang.Object
  extended by java.nio.Buffer
      extended by java.nio.CharBuffer
          extended by java.nio.CharArrayBuffer
All Implemented Interfaces:
Appendable, CharSequence, Comparable<CharBuffer>, Readable
Direct Known Subclasses:
ReadOnlyCharArrayBuffer, ReadWriteCharArrayBuffer

abstract class CharArrayBuffer
extends CharBuffer

CharArrayBuffer, ReadWriteCharArrayBuffer and ReadOnlyCharArrayBuffer compose the implementation of array based char buffers.

CharArrayBuffer implements all the shared readonly methods and is extended by the other two classes.

All methods are marked final for runtime performance.


Field Summary
protected  char[] backingArray
           
protected  int offset
           
 
Fields inherited from class java.nio.Buffer
_elementSizeShift, capacity, limit, mark, position, UNSET_MARK
 
Constructor Summary
CharArrayBuffer(char[] array)
           
CharArrayBuffer(int capacity)
           
CharArrayBuffer(int capacity, char[] backingArray, int offset)
           
 
Method Summary
 char get()
          Returns the char at the current position and increase the position by 1.
 CharBuffer get(char[] dest, int off, int len)
          Reads chars from the current position into the specified char array, starting from the specified offset, and increase the position by the number of chars read.
 char get(int index)
          Returns a char at the specified index, and the position is not changed.
 boolean isDirect()
          Returns true if this buffer is direct.
 ByteOrder order()
          Returns the byte order used by this buffer when converting chars from/to bytes.
 CharSequence subSequence(int start, int end)
          Returns a new char buffer represents a sub-sequence of this buffer's current remaining content.
 String toString()
          Returns a string represents the current remaining chars of this buffer.
 
Methods inherited from class java.nio.CharBuffer
_array, _arrayOffset, allocate, append, append, append, array, arrayOffset, asReadOnlyBuffer, charAt, compact, compareTo, duplicate, equals, get, hasArray, hashCode, length, protectedArray, protectedArrayOffset, protectedHasArray, put, put, put, put, put, put, put, read, slice, wrap, wrap, wrap, wrap
 
Methods inherited from class java.nio.Buffer
capacity, clear, flip, hasRemaining, isReadOnly, limit, limit, mark, position, position, remaining, reset, rewind
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

backingArray

protected final char[] backingArray

offset

protected final int offset
Constructor Detail

CharArrayBuffer

CharArrayBuffer(char[] array)

CharArrayBuffer

CharArrayBuffer(int capacity)

CharArrayBuffer

CharArrayBuffer(int capacity,
                char[] backingArray,
                int offset)
Method Detail

get

public final char get()
Description copied from class: CharBuffer
Returns the char at the current position and increase the position by 1.

Specified by:
get in class CharBuffer
Returns:
The char at the current position.

get

public final char get(int index)
Description copied from class: CharBuffer
Returns a char at the specified index, and the position is not changed.

Specified by:
get in class CharBuffer
Parameters:
index - The index, must be no less than zero and less than limit
Returns:
A char at the specified index.

get

public final CharBuffer get(char[] dest,
                            int off,
                            int len)
Description copied from class: CharBuffer
Reads chars from the current position into the specified char array, starting from the specified offset, and increase the position by the number of chars read.

Overrides:
get in class CharBuffer
Parameters:
dest - The target char array
off - The offset of the char array, must be no less than zero and no greater than dest.length
len - The number of chars to read, must be no less than zero and no greater than dest.length - off
Returns:
This buffer

isDirect

public final boolean isDirect()
Description copied from class: CharBuffer
Returns true if this buffer is direct.

A direct buffer will try its best to take advantage of native memory APIs and it may not stay in java heap, thus not affected by GC.

A char buffer is direct, if it is based on a byte buffer and the byte buffer is direct.

Specified by:
isDirect in class CharBuffer
Returns:
True if this buffer is direct.

order

public final ByteOrder order()
Description copied from class: CharBuffer
Returns the byte order used by this buffer when converting chars from/to bytes.

If this buffer is not based on a byte buffer, then always return the platform's native byte order.

Specified by:
order in class CharBuffer
Returns:
The byte order used by this buffer when converting chars from/to bytes.

subSequence

public final CharSequence subSequence(int start,
                                      int end)
Description copied from class: CharBuffer
Returns a new char buffer represents a sub-sequence of this buffer's current remaining content.

The new buffer's position will be position() + start, limit will be position() + end, capacity will be same as this buffer. The new buffer's readonly property and byte order are same as this buffer.

The new buffer shares content with this buffer, which means either buffer's change of content will be visible to the other. The two buffer's position, limit and mark are independent.

Specified by:
subSequence in interface CharSequence
Specified by:
subSequence in class CharBuffer
Parameters:
start - The start index of the sub-sequence, referenced from the current buffer position. Must not be less than zero and not greater than the value obtained from a call to remaining().
end - The end index of the sub-sequence, referenced from the current buffer position. Must not be less than start and not be greater than the value obtained from a call to remaining()
Returns:
A new char buffer represents a sub-sequence of this buffer's current remaining content.

toString

public final String toString()
Description copied from class: CharBuffer
Returns a string represents the current remaining chars of this buffer.

Specified by:
toString in interface CharSequence
Overrides:
toString in class CharBuffer
Returns:
A string represents the current remaining chars of this buffer.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature