org.deegree.commons.utils.nio
Class PooledByteBuffer

java.lang.Object
  extended by org.deegree.commons.utils.nio.PooledByteBuffer

public class PooledByteBuffer
extends Object

The PooledByteBuffer defines the interface to a direct 'native' byte buffer which can be reused again.

Version:
$Revision: $, $Date: $
Author:
Rutger Bezema, last edited by: $Author: rbezema $

Constructor Summary
PooledByteBuffer(int capacity)
           
 
Method Summary
 int capacity()
          call the Buffer.capacity() method.
 void clear()
          call the Buffer.clear() method.
 boolean equals(Object other)
           
 void free()
          Mark this bytebuffer as free.
 ByteBuffer getBuffer()
          Get the pooled direct, native buffer.
 long getId()
           
 int hashCode()
          Implementation as proposed by Joshua Block in Effective Java (Addison-Wesley 2001), which supplies an even distribution and is relatively fast.
 int limit()
          call the Buffer.limit() method.
 void limit(int capacity)
          call the Buffer.limit(int) method.
 void markAsFree()
          Just set the reference to null.
 int position()
          call the Buffer.position() method.
 void position(int position)
          call the Buffer.position() method.
 void rewind()
          call the Buffer.rewind() method.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PooledByteBuffer

public PooledByteBuffer(int capacity)
Parameters:
capacity - of the bytebuffer.
Method Detail

getBuffer

public ByteBuffer getBuffer()
Get the pooled direct, native buffer.

Returns:
the ByteBuffer wrapped by this class.

free

public void free()
Mark this bytebuffer as free.


markAsFree

public void markAsFree()
Just set the reference to null.


rewind

public void rewind()
call the Buffer.rewind() method.


clear

public void clear()
call the Buffer.clear() method.


limit

public void limit(int capacity)
call the Buffer.limit(int) method.

Parameters:
capacity -

limit

public int limit()
call the Buffer.limit() method.

Returns:
the limit of the buffer.

capacity

public int capacity()
call the Buffer.capacity() method.

Returns:
the limit of the buffer.

position

public int position()
call the Buffer.position() method.

Returns:
the limit of the buffer.

position

public void position(int position)
call the Buffer.position() method.

Parameters:
position - of the buffer.

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Implementation as proposed by Joshua Block in Effective Java (Addison-Wesley 2001), which supplies an even distribution and is relatively fast. It is created from field f as follows:

Combining the hash code(s) computed above: result = 37 * result + code;

Overrides:
hashCode in class Object
Returns:
(int) ( result >>> 32 ) ^ (int) result;
See Also:
Object.hashCode()

getId

public long getId()
Returns:
the id


Copyright © 2011. All Rights Reserved.