org.neo.swarm.util.io
Class ByteBufferInputStream
java.lang.Object
java.io.InputStream
org.neo.swarm.util.io.ByteBufferInputStream
- public class ByteBufferInputStream
- extends java.io.InputStream
Provides an interface between ByteBuffers and StreamCallback to use nbio and
fill an internal user buffer.
- Author:
- navery
|
Constructor Summary |
ByteBufferInputStream(int headerSize,
int footerSize,
java.nio.ByteBuffer buffer,
StreamCallback callback)
We expect the header and footer value to match packet formation, i.e. |
| Methods inherited from class java.io.InputStream |
close, mark, markSupported, read, reset, skip |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ByteBufferInputStream
public ByteBufferInputStream(int headerSize,
int footerSize,
java.nio.ByteBuffer buffer,
StreamCallback callback)
throws java.io.IOException
- We expect the header and footer value to match packet formation, i.e.
header size = 7 bytes + 4 bytes datasize buffer is of arbitrary size and
used to multiread into a known user buffer
- Parameters:
buffer - callback -
read
public int read()
throws java.io.IOException
- Throws:
java.io.IOException
getContent
public byte[] getContent()
- Reuses buffer to fill the users databuffer
- Returns:
- byte[]
read
public int read(byte[] bytes,
int off,
int len)
throws java.io.IOException
- Throws:
java.io.IOException
getHeaderBuffer
public byte[] getHeaderBuffer()
- Returns:
- Returns the headerBuffer.
getFooterBuffer
public byte[] getFooterBuffer()
- Returns:
- Returns the footerBuffer.
available
public int available()
throws java.io.IOException
- Returns:
- number of bytes available
- Throws:
java.io.IOException
Copyright © 2001-2004 SWARM-ONE -First Generation (S)calable(W)ide(AR)ea(M)esh. All Rights Reserved.