Build 1.0_r1(from source)

java.nio
Class ReadWriteShortArrayBuffer

java.lang.Object
  extended by java.nio.Buffer
      extended by java.nio.ShortBuffer
          extended by java.nio.ShortArrayBuffer
              extended by java.nio.ReadWriteShortArrayBuffer
All Implemented Interfaces:
Comparable<ShortBuffer>

final class ReadWriteShortArrayBuffer
extends ShortArrayBuffer

ShortArrayBuffer, ReadWriteShortArrayBuffer and ReadOnlyShortArrayBuffer compose the implementation of array based short buffers.

ReadWriteShortArrayBuffer extends ShortArrayBuffer with all the write methods.

This class is marked final for runtime performance.


Field Summary
 
Fields inherited from class java.nio.ShortArrayBuffer
backingArray, offset
 
Fields inherited from class java.nio.Buffer
_elementSizeShift, capacity, limit, mark, position, UNSET_MARK
 
Constructor Summary
ReadWriteShortArrayBuffer(int capacity)
           
ReadWriteShortArrayBuffer(int capacity, short[] backingArray, int arrayOffset)
           
ReadWriteShortArrayBuffer(short[] array)
           
 
Method Summary
 ShortBuffer asReadOnlyBuffer()
          Returns a readonly buffer that shares content with this buffer.
 ShortBuffer compact()
          Compacts this short buffer.
(package private) static ReadWriteShortArrayBuffer copy(ShortArrayBuffer other, int markOfOther)
           
 ShortBuffer duplicate()
          Returns a duplicated buffer that shares content with this buffer.
 boolean isReadOnly()
          Returns whether this buffer is readonly or not.
protected  short[] 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().
 ShortBuffer put(int index, short c)
          Write a short to the specified index of this buffer and the position is not changed.
 ShortBuffer put(short c)
          Writes the given short to the current position and increase the position by 1.
 ShortBuffer put(short[] src, int off, int len)
          Writes shorts in the given short array, starting from the specified offset, to the current position and increase the position by the number of shorts written.
 ShortBuffer slice()
          Returns a sliced buffer that shares content with this buffer.
 
Methods inherited from class java.nio.ShortArrayBuffer
get, get, get, isDirect, order
 
Methods inherited from class java.nio.ShortBuffer
_array, _arrayOffset, allocate, array, arrayOffset, compareTo, equals, get, hasArray, hashCode, put, put, toString, 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

ReadWriteShortArrayBuffer

ReadWriteShortArrayBuffer(short[] array)

ReadWriteShortArrayBuffer

ReadWriteShortArrayBuffer(int capacity)

ReadWriteShortArrayBuffer

ReadWriteShortArrayBuffer(int capacity,
                          short[] backingArray,
                          int arrayOffset)
Method Detail

copy

static ReadWriteShortArrayBuffer copy(ShortArrayBuffer other,
                                      int markOfOther)

asReadOnlyBuffer

public ShortBuffer asReadOnlyBuffer()
Description copied from class: ShortBuffer
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 ShortBuffer
Returns:
A readonly version of this buffer.

compact

public ShortBuffer compact()
Description copied from class: ShortBuffer
Compacts this short buffer.

The remaining shorts 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 ShortBuffer
Returns:
This buffer

duplicate

public ShortBuffer duplicate()
Description copied from class: ShortBuffer
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 ShortBuffer
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 short[] protectedArray()
Description copied from class: ShortBuffer
Child class implements this method to realize array().

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

protectedArrayOffset

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

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

protectedHasArray

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

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

put

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

Specified by:
put in class ShortBuffer
Parameters:
c - The short to write
Returns:
This buffer

put

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

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

put

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

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

slice

public ShortBuffer slice()
Description copied from class: ShortBuffer
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 ShortBuffer
Returns:
A sliced buffer that shares content with this buffer.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature