net.sf.mmm.util.io.impl
Class PooledByteArray

java.lang.Object
  extended by net.sf.mmm.util.io.base.AbstractByteArray
      extended by net.sf.mmm.util.io.base.ByteArrayImpl
          extended by net.sf.mmm.util.io.impl.PooledByteArray
All Implemented Interfaces:
ByteArray, ByteProvider

public class PooledByteArray
extends ByteArrayImpl

This is an implementation of ByteArray that holds a pooled byte-array.

Since:
1.1.0
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)
See Also:
ByteArrayPool

Field Summary
private  int childCount
          The number of children created.
private  PooledByteArray parent
          The parent that created this array.
private  boolean released
           
 
Constructor Summary
  PooledByteArray(byte[] buffer)
          The constructor.
  PooledByteArray(byte[] buffer, int startIndex, int maximumIndex)
          The constructor.
protected PooledByteArray(byte[] buffer, int startIndex, int maximumIndex, PooledByteArray parent)
          The constructor.
 
Method Summary
 ByteArrayImpl createSubArray(int minimum, int maximum)
          This method creates a new ByteArray with the same bytes but the given indices.
ATTENTION:
If the implementation is immutable and the given minimum and maximum index are both equal to the current indices of this ByteArray this method may return the instance itself ( this) rather than creating a new one.
 boolean release()
          This method marks this array to be released.
 
Methods inherited from class net.sf.mmm.util.io.base.ByteArrayImpl
getBytes, getCurrentIndex, getMaximumIndex, getMinimumIndex, setMaximumIndex, toString
 
Methods inherited from class net.sf.mmm.util.io.base.AbstractByteArray
checkSubArray, getBytesAvailable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

private final PooledByteArray parent
The parent that created this array.


childCount

private int childCount
The number of children created.


released

private boolean released
See Also:
release()
Constructor Detail

PooledByteArray

public PooledByteArray(byte[] buffer)
The constructor.

Parameters:
buffer - is the internal buffer.

PooledByteArray

public PooledByteArray(byte[] buffer,
                       int startIndex,
                       int maximumIndex)
The constructor.

Parameters:
buffer - is the internal buffer.
startIndex - is the current index as well as the minimum index.
maximumIndex - is the maximum index.

PooledByteArray

protected PooledByteArray(byte[] buffer,
                          int startIndex,
                          int maximumIndex,
                          PooledByteArray parent)
The constructor.

Parameters:
buffer - is the internal buffer.
startIndex - is the current index as well as the minimum index.
maximumIndex - is the maximum index.
parent - is the parent that created this array.
Method Detail

createSubArray

public ByteArrayImpl createSubArray(int minimum,
                                    int maximum)
This method creates a new ByteArray with the same bytes but the given indices.
ATTENTION:
If the implementation is immutable and the given minimum and maximum index are both equal to the current indices of this ByteArray this method may return the instance itself ( this) rather than creating a new one.

Specified by:
createSubArray in interface ByteArray
Overrides:
createSubArray in class ByteArrayImpl
Parameters:
minimum - is the minimumIndex and the currentIndex for the new ByteArray. It has to be greater or equal to the minimumIndex of this ByteArray.
maximum - is the maximumIndex for the new ByteArray.
Returns:
a new ByteArray with the given indices.

release

public boolean release()
This method marks this array to be released.

Returns:
true if this array can be released, false if there are references left that have to be released before.


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