Build 1.0_r1(from source)

java.nio
Class MappedByteBufferAdapter

java.lang.Object
  extended by java.nio.Buffer
      extended by java.nio.ByteBuffer
          extended by java.nio.MappedByteBuffer
              extended by java.nio.MappedByteBufferAdapter
All Implemented Interfaces:
Comparable<ByteBuffer>, org.apache.harmony.nio.internal.DirectBuffer

 class MappedByteBufferAdapter
extends MappedByteBuffer
implements org.apache.harmony.nio.internal.DirectBuffer


Field Summary
 
Fields inherited from class java.nio.MappedByteBuffer
wrapped
 
Fields inherited from class java.nio.ByteBuffer
order
 
Fields inherited from class java.nio.Buffer
_elementSizeShift, capacity, limit, mark, position, UNSET_MARK
 
Constructor Summary
MappedByteBufferAdapter(ByteBuffer buffer)
           
MappedByteBufferAdapter(org.apache.harmony.luni.platform.PlatformAddress addr, int capa, int offset, int mode)
           
 
Method Summary
 void addressValidityCheck()
           
 CharBuffer asCharBuffer()
          Returns a char buffer which is based on the remaining content of this byte buffer.
 DoubleBuffer asDoubleBuffer()
          Returns a double buffer which is based on the remaining content of this byte buffer.
 FloatBuffer asFloatBuffer()
          Returns a float buffer which is based on the remaining content of this byte buffer.
 IntBuffer asIntBuffer()
          Returns a int buffer which is based on the remaining content of this byte buffer.
 LongBuffer asLongBuffer()
          Returns a long buffer which is based on the remaining content of this byte buffer.
 ByteBuffer asReadOnlyBuffer()
          Returns a readonly buffer that shares content with this buffer.
 ShortBuffer asShortBuffer()
          Returns a short buffer which is based on the remaining content of this byte buffer.
 ByteBuffer compact()
          Compacts this byte buffer.
 ByteBuffer duplicate()
          Returns a duplicated buffer that shares content with this buffer.
 void free()
           
 byte get()
          Returns the byte at the current position and increase the position by 1.
 byte get(int index)
          Returns a byte at the specified index, and the position is not changed.
 org.apache.harmony.luni.platform.PlatformAddress getBaseAddress()
           
 int getByteCapacity()
           
 char getChar()
          Returns the char at the current position and increase the position by 2.
 char getChar(int index)
          Returns the char at the specified index.
 double getDouble()
          Returns the double at the current position and increase the position by 8.
 double getDouble(int index)
          Returns the double at the specified index.
 org.apache.harmony.luni.platform.PlatformAddress getEffectiveAddress()
           
 float getFloat()
          Returns the float at the current position and increase the position by 4.
 float getFloat(int index)
          Returns the float at the specified index.
 int getInt()
          Returns the int at the current position and increase the position by 4.
 int getInt(int index)
          Returns the int at the specified index.
 long getLong()
          Returns the long at the current position and increase the position by 8.
 long getLong(int index)
          Returns the long at the specified index.
 short getShort()
          Returns the short at the current position and increase the position by 2.
 short getShort(int index)
          Returns the short at the specified index.
 boolean isAddressValid()
           
 boolean isDirect()
          Returns true if this buffer is direct.
 boolean isReadOnly()
          Returns whether this buffer is readonly or not.
(package private)  ByteBuffer orderImpl(ByteOrder byteOrder)
           
(package private)  byte[] protectedArray()
          Child class implements this method to realize array().
(package private)  int protectedArrayOffset()
          Child class implements this method to realize arrayOffset().
(package private)  boolean protectedHasArray()
          Child class implements this method to realize hasArray().
 ByteBuffer put(byte b)
          Writes the given byte to the current position and increase the position by 1.
 ByteBuffer put(byte[] src, int off, int len)
          Writes bytes in the given byte array, starting from the specified offset, to the current position and increase the position by the number of bytes written.
 ByteBuffer put(int index, byte b)
          Write a byte to the specified index of this buffer and the position is not changed.
 ByteBuffer putChar(char value)
          Writes the given char to the current position and increase the position by 2.
 ByteBuffer putChar(int index, char value)
          Write a char to the specified index of this buffer.
 ByteBuffer putDouble(double value)
          Writes the given double to the current position and increase the position by 8.
 ByteBuffer putDouble(int index, double value)
          Write a double to the specified index of this buffer.
 ByteBuffer putFloat(float value)
          Writes the given float to the current position and increase the position by 4.
 ByteBuffer putFloat(int index, float value)
          Write a float to the specified index of this buffer.
 ByteBuffer putInt(int value)
          Writes the given int to the current position and increase the position by 4.
 ByteBuffer putInt(int index, int value)
          Write a int to the specified index of this buffer.
 ByteBuffer putLong(int index, long value)
          Write a long to the specified index of this buffer.
 ByteBuffer putLong(long value)
          Writes the given long to the current position and increase the position by 8.
 ByteBuffer putShort(int index, short value)
          Write a short to the specified index of this buffer.
 ByteBuffer putShort(short value)
          Writes the given short to the current position and increase the position by 2.
 ByteBuffer slice()
          Returns a sliced buffer that shares content with this buffer.
 
Methods inherited from class java.nio.MappedByteBuffer
force, isLoaded, load
 
Methods inherited from class java.nio.ByteBuffer
_array, _arrayOffset, allocate, allocateDirect, array, arrayOffset, compareTo, equals, get, get, hasArray, hashCode, order, order, 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

MappedByteBufferAdapter

public MappedByteBufferAdapter(ByteBuffer buffer)

MappedByteBufferAdapter

public MappedByteBufferAdapter(org.apache.harmony.luni.platform.PlatformAddress addr,
                               int capa,
                               int offset,
                               int mode)
Method Detail

asCharBuffer

public CharBuffer asCharBuffer()
Description copied from class: ByteBuffer
Returns a char buffer which is based on the remaining content of this byte buffer.

The new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by two, and its mark is not set. The new buffer's readonly property and byte order are same as this buffer. The new buffer is direct, if this byte buffer is direct.

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:
asCharBuffer in class ByteBuffer
Returns:
A char buffer which is based on the content of this byte buffer.

asDoubleBuffer

public DoubleBuffer asDoubleBuffer()
Description copied from class: ByteBuffer
Returns a double buffer which is based on the remaining content of this byte buffer.

The new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by two, and its mark is not set. The new buffer's readonly property and byte order are same as this buffer. The new buffer is direct, if this byte buffer is direct.

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:
asDoubleBuffer in class ByteBuffer
Returns:
A double buffer which is based on the content of this byte buffer.

asFloatBuffer

public FloatBuffer asFloatBuffer()
Description copied from class: ByteBuffer
Returns a float buffer which is based on the remaining content of this byte buffer.

The new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by two, and its mark is not set. The new buffer's readonly property and byte order are same as this buffer. The new buffer is direct, if this byte buffer is direct.

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:
asFloatBuffer in class ByteBuffer
Returns:
A float buffer which is based on the content of this byte buffer.

asIntBuffer

public IntBuffer asIntBuffer()
Description copied from class: ByteBuffer
Returns a int buffer which is based on the remaining content of this byte buffer.

The new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by two, and its mark is not set. The new buffer's readonly property and byte order are same as this buffer. The new buffer is direct, if this byte buffer is direct.

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:
asIntBuffer in class ByteBuffer
Returns:
A int buffer which is based on the content of this byte buffer.

asLongBuffer

public LongBuffer asLongBuffer()
Description copied from class: ByteBuffer
Returns a long buffer which is based on the remaining content of this byte buffer.

The new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by two, and its mark is not set. The new buffer's readonly property and byte order are same as this buffer. The new buffer is direct, if this byte buffer is direct.

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:
asLongBuffer in class ByteBuffer
Returns:
A long buffer which is based on the content of this byte buffer.

asReadOnlyBuffer

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

asShortBuffer

public ShortBuffer asShortBuffer()
Description copied from class: ByteBuffer
Returns a short buffer which is based on the remaining content of this byte buffer.

The new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by two, and its mark is not set. The new buffer's readonly property and byte order are same as this buffer. The new buffer is direct, if this byte buffer is direct.

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:
asShortBuffer in class ByteBuffer
Returns:
A short buffer which is based on the content of this byte buffer.

compact

public ByteBuffer compact()
Description copied from class: ByteBuffer
Compacts this byte buffer.

The remaining bytes 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 ByteBuffer
Returns:
This buffer

duplicate

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

get

public byte get()
Description copied from class: ByteBuffer
Returns the byte at the current position and increase the position by 1.

Specified by:
get in class ByteBuffer
Returns:
The byte at the current position.

get

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

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

getChar

public char getChar()
Description copied from class: ByteBuffer
Returns the char at the current position and increase the position by 2.

The 2 bytes start from the current position are composed into a char according to current byte order and returned. The position increases by 2.

Specified by:
getChar in class ByteBuffer
Returns:
The char at the current position.

getChar

public char getChar(int index)
Description copied from class: ByteBuffer
Returns the char at the specified index.

The 2 bytes start from the specified index are composed into a char according to current byte order and returned. The position is not changed.

Specified by:
getChar in class ByteBuffer
Parameters:
index - The index, must be no less than zero and equal or less than limit - 2
Returns:
The char at the specified index.

getDouble

public double getDouble()
Description copied from class: ByteBuffer
Returns the double at the current position and increase the position by 8.

The 8 bytes start from the current position are composed into a double according to current byte order and returned. The position increases by 8.

Specified by:
getDouble in class ByteBuffer
Returns:
The double at the current position.

getDouble

public double getDouble(int index)
Description copied from class: ByteBuffer
Returns the double at the specified index.

The 8 bytes start from the specified index are composed into a double according to current byte order and returned. The position is not changed.

Specified by:
getDouble in class ByteBuffer
Parameters:
index - The index, must be no less than zero and equal or less than limit - 8
Returns:
The double at the specified index.

getEffectiveAddress

public org.apache.harmony.luni.platform.PlatformAddress getEffectiveAddress()
Specified by:
getEffectiveAddress in interface org.apache.harmony.nio.internal.DirectBuffer

getFloat

public float getFloat()
Description copied from class: ByteBuffer
Returns the float at the current position and increase the position by 4.

The 4 bytes start from the current position are composed into a float according to current byte order and returned. The position increases by 4.

Specified by:
getFloat in class ByteBuffer
Returns:
The float at the current position.

getFloat

public float getFloat(int index)
Description copied from class: ByteBuffer
Returns the float at the specified index.

The 4 bytes start from the specified index are composed into a float according to current byte order and returned. The position is not changed.

Specified by:
getFloat in class ByteBuffer
Parameters:
index - The index, must be no less than zero and equal or less than limit - 4
Returns:
The float at the specified index.

getInt

public int getInt()
Description copied from class: ByteBuffer
Returns the int at the current position and increase the position by 4.

The 4 bytes start from the current position are composed into a int according to current byte order and returned. The position increases by 4.

Specified by:
getInt in class ByteBuffer
Returns:
The int at the current position.

getInt

public int getInt(int index)
Description copied from class: ByteBuffer
Returns the int at the specified index.

The 4 bytes start from the specified index are composed into a int according to current byte order and returned. The position is not changed.

Specified by:
getInt in class ByteBuffer
Parameters:
index - The index, must be no less than zero and equal or less than limit - 4
Returns:
The int at the specified index.

getLong

public long getLong()
Description copied from class: ByteBuffer
Returns the long at the current position and increase the position by 8.

The 8 bytes start from the current position are composed into a long according to current byte order and returned. The position increases by 8.

Specified by:
getLong in class ByteBuffer
Returns:
The long at the current position.

getLong

public long getLong(int index)
Description copied from class: ByteBuffer
Returns the long at the specified index.

The 8 bytes start from the specified index are composed into a long according to current byte order and returned. The position is not changed.

Specified by:
getLong in class ByteBuffer
Parameters:
index - The index, must be no less than zero and equal or less than limit - 8
Returns:
The long at the specified index.

getShort

public short getShort()
Description copied from class: ByteBuffer
Returns the short at the current position and increase the position by 2.

The 2 bytes start from the current position are composed into a short according to current byte order and returned. The position increases by 2.

Specified by:
getShort in class ByteBuffer
Returns:
The short at the current position.

getShort

public short getShort(int index)
Description copied from class: ByteBuffer
Returns the short at the specified index.

The 2 bytes start from the specified index are composed into a short according to current byte order and returned. The position is not changed.

Specified by:
getShort in class ByteBuffer
Parameters:
index - The index, must be no less than zero and equal or less than limit - 2
Returns:
The short at the specified index.

isDirect

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

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

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

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.

orderImpl

ByteBuffer orderImpl(ByteOrder byteOrder)
Overrides:
orderImpl in class ByteBuffer

put

public ByteBuffer put(byte b)
Description copied from class: ByteBuffer
Writes the given byte to the current position and increase the position by 1.

Specified by:
put in class ByteBuffer
Parameters:
b - The byte to write
Returns:
This buffer

put

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

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

put

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

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

putChar

public ByteBuffer putChar(char value)
Description copied from class: ByteBuffer
Writes the given char to the current position and increase the position by 2.

The char is converted to bytes using the current byte order.

Specified by:
putChar in class ByteBuffer
Parameters:
value - The char to write
Returns:
This buffer

putChar

public ByteBuffer putChar(int index,
                          char value)
Description copied from class: ByteBuffer
Write a char to the specified index of this buffer.

The char is converted to bytes using the current byte order. The position is not changed.

Specified by:
putChar in class ByteBuffer
Parameters:
index - The index, must be no less than zero and equal or less than limit - 2
value - The char to write
Returns:
This buffer

putDouble

public ByteBuffer putDouble(double value)
Description copied from class: ByteBuffer
Writes the given double to the current position and increase the position by 8.

The double is converted to bytes using the current byte order.

Specified by:
putDouble in class ByteBuffer
Parameters:
value - The double to write
Returns:
This buffer

putDouble

public ByteBuffer putDouble(int index,
                            double value)
Description copied from class: ByteBuffer
Write a double to the specified index of this buffer.

The double is converted to bytes using the current byte order. The position is not changed.

Specified by:
putDouble in class ByteBuffer
Parameters:
index - The index, must be no less than zero and equal or less than limit - 8
value - The double to write
Returns:
This buffer

putFloat

public ByteBuffer putFloat(float value)
Description copied from class: ByteBuffer
Writes the given float to the current position and increase the position by 4.

The float is converted to bytes using the current byte order.

Specified by:
putFloat in class ByteBuffer
Parameters:
value - The float to write
Returns:
This buffer

putFloat

public ByteBuffer putFloat(int index,
                           float value)
Description copied from class: ByteBuffer
Write a float to the specified index of this buffer.

The float is converted to bytes using the current byte order. The position is not changed.

Specified by:
putFloat in class ByteBuffer
Parameters:
index - The index, must be no less than zero and equal or less than limit - 4
value - The float to write
Returns:
This buffer

putInt

public ByteBuffer putInt(int index,
                         int value)
Description copied from class: ByteBuffer
Write a int to the specified index of this buffer.

The int is converted to bytes using the current byte order. The position is not changed.

Specified by:
putInt in class ByteBuffer
Parameters:
index - The index, must be no less than zero and equal or less than limit - 4
value - The int to write
Returns:
This buffer

putInt

public ByteBuffer putInt(int value)
Description copied from class: ByteBuffer
Writes the given int to the current position and increase the position by 4.

The int is converted to bytes using the current byte order.

Specified by:
putInt in class ByteBuffer
Parameters:
value - The int to write
Returns:
This buffer

putLong

public ByteBuffer putLong(int index,
                          long value)
Description copied from class: ByteBuffer
Write a long to the specified index of this buffer.

The long is converted to bytes using the current byte order. The position is not changed.

Specified by:
putLong in class ByteBuffer
Parameters:
index - The index, must be no less than zero and equal or less than limit - 8
value - The long to write
Returns:
This buffer

putLong

public ByteBuffer putLong(long value)
Description copied from class: ByteBuffer
Writes the given long to the current position and increase the position by 8.

The long is converted to bytes using the current byte order.

Specified by:
putLong in class ByteBuffer
Parameters:
value - The long to write
Returns:
This buffer

putShort

public ByteBuffer putShort(int index,
                           short value)
Description copied from class: ByteBuffer
Write a short to the specified index of this buffer.

The short is converted to bytes using the current byte order. The position is not changed.

Specified by:
putShort in class ByteBuffer
Parameters:
index - The index, must be no less than zero and equal or less than limit - 2
value - The short to write
Returns:
This buffer

putShort

public ByteBuffer putShort(short value)
Description copied from class: ByteBuffer
Writes the given short to the current position and increase the position by 2.

The short is converted to bytes using the current byte order.

Specified by:
putShort in class ByteBuffer
Parameters:
value - The short to write
Returns:
This buffer

slice

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

protectedArray

byte[] protectedArray()
Description copied from class: ByteBuffer
Child class implements this method to realize array().

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

protectedArrayOffset

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

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

protectedHasArray

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

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

getBaseAddress

public org.apache.harmony.luni.platform.PlatformAddress getBaseAddress()
Specified by:
getBaseAddress in interface org.apache.harmony.nio.internal.DirectBuffer

isAddressValid

public boolean isAddressValid()
Specified by:
isAddressValid in interface org.apache.harmony.nio.internal.DirectBuffer

addressValidityCheck

public void addressValidityCheck()
Specified by:
addressValidityCheck in interface org.apache.harmony.nio.internal.DirectBuffer

free

public void free()
Specified by:
free in interface org.apache.harmony.nio.internal.DirectBuffer

getByteCapacity

public int getByteCapacity()
Specified by:
getByteCapacity in interface org.apache.harmony.nio.internal.DirectBuffer

Build 1.0_r1(from source)

Please submit a feedback, bug or feature