Package org.apache.james.mime4j.util
Class RecycledByteArrayBuffer
- java.lang.Object
-
- org.apache.james.mime4j.util.RecycledByteArrayBuffer
-
- All Implemented Interfaces:
ByteSequence
public final class RecycledByteArrayBuffer extends java.lang.Object implements ByteSequence
A resizable byte array.
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]bufferprivate BufferRecyclerbufferRecyclerprivate intlen-
Fields inherited from interface org.apache.james.mime4j.util.ByteSequence
EMPTY
-
-
Constructor Summary
Constructors Constructor Description RecycledByteArrayBuffer(BufferRecycler bufferRecycler, byte[] bytes, boolean dontCopy)RecycledByteArrayBuffer(BufferRecycler bufferRecycler, byte[] bytes, int len, boolean dontCopy)RecycledByteArrayBuffer(BufferRecycler bufferRecycler, int capacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappend(byte[] b, int off, int len)voidappend(int b)byte[]buffer()bytebyteAt(int i)Returns thebytevalue at the specified index.intcapacity()voidclear()private voidexpand(int newlen)intindexOf(byte b)intindexOf(byte b, int beginIndex, int endIndex)booleanisEmpty()booleanisFull()intlength()Returns the length of this byte sequence.voidrelease()voidremove(int off, int len)voidsetLength(int len)byte[]toByteArray()Copies the contents of this byte sequence into a newly allocated byte array and returns that array.java.lang.StringtoString()
-
-
-
Field Detail
-
bufferRecycler
private final BufferRecycler bufferRecycler
-
buffer
private byte[] buffer
-
len
private int len
-
-
Constructor Detail
-
RecycledByteArrayBuffer
public RecycledByteArrayBuffer(BufferRecycler bufferRecycler, int capacity)
-
RecycledByteArrayBuffer
public RecycledByteArrayBuffer(BufferRecycler bufferRecycler, byte[] bytes, boolean dontCopy)
-
RecycledByteArrayBuffer
public RecycledByteArrayBuffer(BufferRecycler bufferRecycler, byte[] bytes, int len, boolean dontCopy)
-
-
Method Detail
-
expand
private void expand(int newlen)
-
append
public void append(byte[] b, int off, int len)
-
append
public void append(int b)
-
clear
public void clear()
-
toByteArray
public byte[] toByteArray()
Description copied from interface:ByteSequenceCopies the contents of this byte sequence into a newly allocated byte array and returns that array.- Specified by:
toByteArrayin interfaceByteSequence- Returns:
- a byte array holding a copy of this byte sequence.
-
byteAt
public byte byteAt(int i)
Description copied from interface:ByteSequenceReturns thebytevalue at the specified index.- Specified by:
byteAtin interfaceByteSequence- Parameters:
i- the index of thebytevalue to be returned.- Returns:
- the corresponding
bytevalue
-
capacity
public int capacity()
-
length
public int length()
Description copied from interface:ByteSequenceReturns the length of this byte sequence.- Specified by:
lengthin interfaceByteSequence- Returns:
- the number of
bytes in this sequence.
-
buffer
public byte[] buffer()
-
indexOf
public int indexOf(byte b)
-
indexOf
public int indexOf(byte b, int beginIndex, int endIndex)
-
setLength
public void setLength(int len)
-
remove
public void remove(int off, int len)
-
isEmpty
public boolean isEmpty()
-
isFull
public boolean isFull()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
release
public void release()
-
-