|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jibx.runtime.impl.InByteBuffer
public class InByteBuffer
Byte buffer wrapping an input stream. Clients need to obey the interface access rules.
Field Summary | |
---|---|
static int |
DEFAULT_BUFFER_SIZE
Default input buffer size. |
private byte[] |
m_buffer
Buffer for input bytes. |
private boolean |
m_isEnd
Flag for end of stream reached. |
private int |
m_limit
Offset past end of bytes in buffer. |
private int |
m_offset
Current offset for removing bytes from buffer. |
private java.io.InputStream |
m_stream
Stream for byte input. |
Constructor Summary | |
---|---|
InByteBuffer()
Constructor using default buffer size. |
|
InByteBuffer(int size)
Constructor with size specified. |
Method Summary | |
---|---|
private boolean |
fillBuffer(int size)
Read data into the buffer to assure at least a minimum number of bytes are available. |
void |
finish()
Complete usage of the current stream. |
byte[] |
getBuffer()
Get the byte array buffer. |
int |
getLimit()
Get offset past the end of data in buffer. |
int |
getOffset()
Get the index of the next byte to be read. |
boolean |
require(int size)
Require some number of bytes of data. |
void |
reset()
Reset to initial state for reuse. |
void |
setInput(java.io.InputStream is)
Set the actual input stream to be used for this buffer. |
void |
setOffset(int offset)
Set the current offset. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_BUFFER_SIZE
private java.io.InputStream m_stream
private boolean m_isEnd
private byte[] m_buffer
private int m_limit
private int m_offset
Constructor Detail |
---|
public InByteBuffer(int size)
size
- initial buffer size in bytespublic InByteBuffer()
Method Detail |
---|
private boolean fillBuffer(int size) throws java.io.IOException
size
- minimum number of bytes required
true
if data has been read into buffer,
false
if not
java.io.IOException
- on error reading from wrapped streampublic void reset()
public void setInput(java.io.InputStream is)
is
- streampublic byte[] getBuffer()
getBuffer
in interface IByteBuffer
public int getOffset()
setOffset(int)
method must be used to update the current offset before
any other operations are performed on the buffer.
getOffset
in interface IByteBuffer
public void setOffset(int offset)
setOffset
in interface IByteBuffer
offset
- public int getLimit()
getLimit
in interface IInByteBuffer
public boolean require(int size) throws java.io.IOException
getBuffer()
, getLimit()
, and getOffset()
must
all be called again before any further use of the buffer.
require
in interface IInByteBuffer
size
- desired number of bytes
true
if request satisfied, false
if not
java.io.IOException
public void finish() throws java.io.IOException
setInput(InputStream)
is
required before the buffer can again be used.
finish
in interface IByteBuffer
java.io.IOException
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |