Build 1.0_r1(from source)

java.nio
Class ReadWriteCharArrayBuffer

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

final class ReadWriteCharArrayBuffer
extends CharArrayBuffer

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

ReadWriteCharArrayBuffer extends CharArrayBuffer with all the write methods.

This class is marked final for runtime performance.


Field Summary
 
Fields inherited from class java.nio.CharArrayBuffer
backingArray, offset
 
Fields inherited from class java.nio.Buffer
_elementSizeShift, capacity, limit, mark, position, UNSET_MARK
 
Constructor Summary
ReadWriteCharArrayBuffer(char[] array)
           
ReadWriteCharArrayBuffer(int capacity)
           
ReadWriteCharArrayBuffer(int capacity, char[] backingArray, int arrayOffset)
           
 
Method Summary
 CharBuffer asReadOnlyBuffer()
          Returns a readonly buffer that shares content with this buffer.
 CharBuffer compact()
          Compacts this char buffer.
(package private) static ReadWriteCharArrayBuffer copy(CharArrayBuffer other, int markOfOther)
           
 CharBuffer duplicate()
          Returns a duplicated buffer that shares content with this buffer.
 boolean isReadOnly()
          Returns whether this buffer is readonly or not.
protected  char[] protectedArray()
          Child class implements this method to realize array().
protected  int protectedArrayOffset()
          Child class implements this method to realize arrayOffset().
protected  boolean protectedHasArray()
          Child class implements this method to realize hasArray().
 CharBuffer put(char c)
          Writes the given char to the current position and increase the position by 1.
 CharBuffer put(char[] src, int off, int len)
          Writes chars in the given char array, starting from the specified offset, to the current position and increase the position by the number of chars written.
 CharBuffer put(int index, char c)
          Write a char to the specified index of this buffer and the position is not changed.
 CharBuffer slice()
          Returns a sliced buffer that shares content with this buffer.
 
Methods inherited from class java.nio.CharArrayBuffer
get, get, get, isDirect, order, subSequence, toString
 
Methods inherited from class java.nio.CharBuffer
_array, _arrayOffset, allocate, append, append, append, array, arrayOffset, charAt, compareTo, equals, get, hasArray, hashCode, length, put, put, put, put, read, wrap, wrap, wrap, wrap
 
Methods inherited from class java.nio.Buffer
capacity, clear, flip, hasRemaining, limit, limit, mark, position, position, remaining, reset, rewind
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReadWriteCharArrayBuffer

ReadWriteCharArrayBuffer(char[] array)

ReadWriteCharArrayBuffer

ReadWriteCharArrayBuffer(int capacity)

ReadWriteCharArrayBuffer

ReadWriteCharArrayBuffer(int capacity,
                         char[] backingArray,
                         int arrayOffset)
Method Detail

copy

static ReadWriteCharArrayBuffer copy(CharArrayBuffer other,
                                     int markOfOther)

asReadOnlyBuffer

public CharBuffer asReadOnlyBuffer()
Description copied from class: CharBuffer
Returns a readonly buffer that shares content with this buffer.

The returned buffer is guaranteed to be a new instance, even this buffer is readonly itself. The new buffer's position, limit, capacity and mark are the same as this buffer.

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

Specified by:
asReadOnlyBuffer in class CharBuffer
Returns:
A readonly version of this buffer.

compact

public CharBuffer compact()
Description copied from class: CharBuffer
Compacts this char buffer.

The remaining chars will be moved to the head of the buffer, staring from position zero. Then the position is set to remaining(); the limit is set to capacity; the mark is cleared.

Specified by:
compact in class CharBuffer
Returns:
This buffer

duplicate

public CharBuffer duplicate()
Description copied from class: CharBuffer
Returns a duplicated buffer that shares content with this buffer.

The duplicated buffer's position, limit, capacity and mark are the same as this buffer. The duplicated buffer's readonly property and byte order are same as this buffer too.

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:
duplicate in class CharBuffer
Returns:
A duplicated buffer that shares content with this buffer.

isReadOnly

public boolean isReadOnly()
Description copied from class: Buffer
Returns whether this buffer is readonly or not.

Specified by:
isReadOnly in class Buffer
Returns:
Whether this buffer is readonly or not.

protectedArray

protected char[] protectedArray()
Description copied from class: CharBuffer
Child class implements this method to realize array().

Specified by:
protectedArray in class CharBuffer
Returns:
see array()

protectedArrayOffset

protected int protectedArrayOffset()
Description copied from class: CharBuffer
Child class implements this method to realize arrayOffset().

Specified by:
protectedArrayOffset in class CharBuffer
Returns:
see arrayOffset()

protectedHasArray

protected boolean protectedHasArray()
Description copied from class: CharBuffer
Child class implements this method to realize hasArray().

Specified by:
protectedHasArray in class CharBuffer
Returns:
see hasArray()

put

public CharBuffer put(char c)
Description copied from class: CharBuffer
Writes the given char to the current position and increase the position by 1.

Specified by:
put in class CharBuffer
Parameters:
c - The char to write
Returns:
This buffer

put

public CharBuffer put(int index,
                      char c)
Description copied from class: CharBuffer
Write a char to the specified index of this buffer and the position is not changed.

Specified by:
put in class CharBuffer
Parameters:
index - The index, must be no less than zero and less than the limit
c - The char to write
Returns:
This buffer

put

public CharBuffer put(char[] src,
                      int off,
                      int len)
Description copied from class: CharBuffer
Writes chars in the given char array, starting from the specified offset, to the current position and increase the position by the number of chars written.

Overrides:
put in class CharBuffer
Parameters:
src - The source char array
off - The offset of char array, must be no less than zero and no greater than src.length
len - The number of chars to write, must be no less than zero and no greater than src.length - off
Returns:
This buffer

slice

public CharBuffer slice()
Description copied from class: CharBuffer
Returns a sliced buffer that shares content with this buffer.

The sliced buffer's capacity will be this buffer's remaining(), and its zero position will correspond to this buffer's current position. The new buffer's position will be 0, limit will be its capacity, and its mark is unset. 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:
slice in class CharBuffer
Returns:
A sliced buffer that shares content with this buffer.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature