|
Novell exteNd Director 5.0 API |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sssw.fw.util.EboByteBuffer
EboByteBuffer is a wrapper class around a byte array. A ByteBuffer API allows reads and writes without worrying about underlying byte array. This class is intended to be used as the underlying storage mechanism for pair(s) of Input/Output Stream classes that can attach/detach its underlying storage facility.. Please note, this class is not synchronized. It is up to the user of this storage facility to handle synchronization. This is a com.sssw.test.test reimplementation that uses a linked list of byte array chunks, rather than a single buffer that is copied. This is an attempt to get a couple of orders of magnitude performance improvement.
Constructor Summary | |
EboByteBuffer()
Creates a EboByteBuffer with the default byte array size and chunk count |
|
EboByteBuffer(byte[] buf)
Creates a EboByteBuffer from the specified array of bytes. |
|
EboByteBuffer(InputStream in)
No information available |
|
EboByteBuffer(InputStream in,
int incr)
Creates a EboByteBuffer from the contents of the specified InputStream. |
|
EboByteBuffer(int size)
Creates a EboByteBuffer with the specified byte array size Will also grow by this size. |
|
EboByteBuffer(String str)
No information available |
Method Summary | |
int |
available()
Get the size of the available buffer space. |
protected byte[] |
getBuffer()
Get the actual storage array N.B. |
int |
getPosition()
Return the current position. |
int |
read()
Read the next byte from the buffer. |
int |
read(byte[] buf,
int offset,
int len)
Read a stream of bytes until the specified output array is full. |
void |
reset()
Re-set the buffer to the empty state. |
void |
resetPos()
Reset the cursor to start of buffer for reading |
boolean |
seek(int desiredPosition)
Move the cursor position. |
int |
size()
Get the current size of the buffer that is in use. |
long |
skip(long skipCnt)
Move the cursor position forward by specified number of bytes. |
byte[] |
toByteArray()
Get a copy of the in use portion of the buffer as a byte array |
String |
toString()
Get the byte array as a String, using the default platform encoding. |
String |
toString(String enc)
Get the byte array as a String, using the specified encoding. |
void |
write(byte[] bytes,
int offset,
int len)
Write the specified number of bytes to the buffer. |
void |
write(int b)
Write the specified byte to the buffer. |
void |
writeTo(OutputStream out)
Writes the complete contents of this byte buffer to the specified output stream argument. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public EboByteBuffer()
public EboByteBuffer(int size)
size
- the initial buffer sizepublic EboByteBuffer(byte[] buf)
buf
- the input buffer (not copied)public EboByteBuffer(String str)
public EboByteBuffer(InputStream in, int incr) throws com.sssw.fw.util.IOException
in
- The InputStream used to initialize the ByteBufferincr
- An int increment size to grow buffer when neededpublic EboByteBuffer(InputStream in) throws com.sssw.fw.util.IOException
Method Detail |
public void resetPos()
public byte[] toByteArray()
public String toString()
public String toString(String enc) throws UnsupportedEncodingException
enc
- The encoding name of the encoding to use.public int available()
public int size()
public void reset()
protected byte[] getBuffer()
public int read()
public int read(byte[] buf, int offset, int len)
buf
- output byte arrayoffset
- starting index to use in the output arraylen
- the number of bytes to readpublic long skip(long skipCnt)
skipCnt
- requested number of bytes to skippublic final boolean seek(int desiredPosition)
position
- requested position.public final int getPosition()
public void write(int b)
b
- the byte to write to bufferpublic void write(byte[] bytes, int offset, int len)
b
- byte array containing bytes to be written to bufferoffset
- starting offset in the input byte array to uselen
- number of bytes to be writtenpublic void writeTo(OutputStream out) throws com.sssw.fw.util.IOException
out
- the output stream byte to write to.
|
Novell exteNd Director 5.0 API |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |