|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectau.com.zip.cs.ByteBuffer
public class ByteBuffer
A self managed byte[] buffer after the fashion of StringBuffer,
plus a few utility functions for byte arrays.
| Field Summary | |
|---|---|
byte[] |
buf
|
int |
off
|
int |
used
|
| Constructor Summary | |
|---|---|
ByteBuffer()
Constructs an empty ByteBuffer. |
|
ByteBuffer(byte[] data)
Constructs a ByteBuffer initially containing the bytes in the array data |
|
ByteBuffer(byte[] data,
int doff,
int dsize,
int palloc,
int ialloc)
Constructs a ByteBuffer with initial content takens from the portion of data
denoted by the offset doff and size dsize,
with initial internal allocation of palloc bytes
and incremental reallocation size of ialloc bytes. |
|
| Method Summary | |
|---|---|
static ByteBuffer |
allocate()
Allocate a buffer from the pool. |
void |
append(byte b)
Append a single byte to the buffer. |
void |
append(byte[] data)
Append a byte[] to the buffer. |
void |
append(byte[] data,
int aoff,
int asize)
Append an arbitrary chunk of a byte[] to the buffer. |
static void |
copyDown(byte[] dest,
byte[] src,
int soff,
int ssize)
Copy an arbitrary chunk of src
to the start of the array dest. |
static void |
deallocate(ByteBuffer buf)
Return a buffer to the pool. |
void |
delete(int doff,
int dsize)
Delete the specified data from the buffer. |
void |
empty()
Discard the data in the buffer. |
InputStream |
getBinaryStream()
|
byte[] |
getBytes(long pos,
int len)
|
void |
insert(byte[] data,
int srcoff,
int isize,
int dstoff)
Insert new data into the buffer. |
long |
length()
|
static void |
move(byte[] buf,
int off1,
int off2,
int size)
Move an chunk of buf from one location to another. |
void |
needsize(int nsize)
Ensure the buffer is at least as big as nsize. |
long |
position(Blob pattern,
long start)
|
long |
position(byte[] pattern,
long start)
|
OutputStream |
setBinaryStream(long pos)
|
int |
setBytes(long pos,
byte[] bytes)
|
int |
setBytes(long pos,
byte[] bytes,
int offset,
int len)
|
byte[] |
toArray()
Return an array of bytes holding the current content. |
void |
truncate(long len)
|
void |
write(OutputStream s)
Write the contents of the buffer to the specified OutputStream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public byte[] buf
public int used
public int off
| Constructor Detail |
|---|
public ByteBuffer()
public ByteBuffer(byte[] data)
data
data - the initial content for the buffer
public ByteBuffer(byte[] data,
int doff,
int dsize,
int palloc,
int ialloc)
data
denoted by the offset doff and size dsize,
with initial internal allocation of palloc bytes
and incremental reallocation size of ialloc bytes.
For no initial data pass null for data
and zero for the offset and size.
For the default allocation settings
pass zero for palloc and ialloc.
data - the array holding the initial content for the bufferdoff - the start of the initial datadsize - the size of the initial datapalloc - the initial internal buffer allocationialloc - the incremental internal buffer reallocation| Method Detail |
|---|
public static final ByteBuffer allocate()
public static final void deallocate(ByteBuffer buf)
buf - The ByteBuffer to release.public void empty()
public final byte[] toArray()
public final void needsize(int nsize)
nsize.
nsize - the requisite new size
public static final void copyDown(byte[] dest,
byte[] src,
int soff,
int ssize)
src
to the start of the array dest.
dest - the target arraysrc - the source arraysoff - the offset into the source arrayssize - the number of bytes to copy
public static final void move(byte[] buf,
int off1,
int off2,
int size)
buf from one location to another.
The old and new regions may overlap.
buf - the buffer to manipulateoff1 - the current start of the dataoff2 - the new start of the datasize - the amount of data to move
public final void insert(byte[] data,
int srcoff,
int isize,
int dstoff)
data - a byte[] holding the new data to insertsrcoff - the start of the new data in dataisize - the amount of data to insertdstoff - the location in the buffer at which to insert the new data
public final void delete(int doff,
int dsize)
doff - the start of the data to deletedsize - the amount of data to delete
public final void append(byte[] data,
int aoff,
int asize)
byte[] to the buffer.
data - the new data to append to the bufferaoff - the start of the new dataasize - the size of the new datapublic final void append(byte[] data)
byte[] to the buffer.
data - the new data to appendpublic final void append(byte b)
byte to the buffer.
b - the new byte to append
public final void write(OutputStream s)
throws IOException
OutputStream.
s - the stream to which to write the buffer
IOExceptionpublic final InputStream getBinaryStream()
getBinaryStream in interface Blob
public final byte[] getBytes(long pos,
int len)
getBytes in interface Blobpublic final long length()
length in interface Blob
public final long position(Blob pattern,
long start)
throws SQLException
position in interface BlobSQLException
public final long position(byte[] pattern,
long start)
throws SQLException
position in interface BlobSQLException
public final OutputStream setBinaryStream(long pos)
throws SQLException
setBinaryStream in interface BlobSQLException
public final int setBytes(long pos,
byte[] bytes)
throws SQLException
setBytes in interface BlobSQLException
public final int setBytes(long pos,
byte[] bytes,
int offset,
int len)
throws SQLException
setBytes in interface BlobSQLExceptionpublic final void truncate(long len)
truncate in interface Blob
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||