net.sf.mmm.util.pool.impl
Class ByteArrayPoolImpl

java.lang.Object
  extended by net.sf.mmm.util.pool.base.AbstractPool<byte[]>
      extended by net.sf.mmm.util.pool.impl.ByteArrayPoolImpl
All Implemented Interfaces:
ByteArrayPool, Pool<byte[]>

public class ByteArrayPoolImpl
extends AbstractPool<byte[]>
implements ByteArrayPool

This is the default implementation of the Pool interface for byte-arrays.

Since:
1.0.0
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)

Field Summary
private  int arrayLength
          The actual length of the byte-arrays.
static int DEFAULT_ARRAY_LENGTH
          The default array length.
 
Fields inherited from class net.sf.mmm.util.pool.base.AbstractPool
DEFAULT_CAPACITY
 
Constructor Summary
ByteArrayPoolImpl()
          The constructor.
ByteArrayPoolImpl(int capacity, int arrayLength)
          The constructor.
 
Method Summary
protected  byte[] create()
          This method creates a new element.
protected  boolean reset(byte[] element)
          This method resets the given element so it can be reused.
 
Methods inherited from class net.sf.mmm.util.pool.base.AbstractPool
borrow, clear, getCapacity, getSize, isEmpty, release
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.mmm.util.pool.api.Pool
borrow, isEmpty, release
 

Field Detail

DEFAULT_ARRAY_LENGTH

public static final int DEFAULT_ARRAY_LENGTH
The default array length.

See Also:
Constant Field Values

arrayLength

private final int arrayLength
The actual length of the byte-arrays.

Constructor Detail

ByteArrayPoolImpl

public ByteArrayPoolImpl()
The constructor.


ByteArrayPoolImpl

public ByteArrayPoolImpl(int capacity,
                         int arrayLength)
The constructor.

Parameters:
capacity - is the capacity of the pool.
arrayLength - is the length of each pooled byte-array.
Method Detail

create

protected byte[] create()
This method creates a new element. It is used if there is no instance left in the pool.

Specified by:
create in class AbstractPool<byte[]>
Returns:
the new instance.

reset

protected boolean reset(byte[] element)
This method resets the given element so it can be reused. It is called if an element is released and will be stored in the pool. The implementation depends on the type of element. Some types may become inconsistent if they are directly reused. Further this method may clear data from the element for security reasons, because the same instance may be given to some other component that is NOT trusted enough (because it may be vulnerably).

Overrides:
reset in class AbstractPool<byte[]>
Parameters:
element - the element to reset.
Returns:
true if the given element can be reused and should be added to the pool, false otherwise.


Copyright © 2001-2010 mmm-Team. All Rights Reserved.