|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.labs.minion.util.buffer.StdReadableImpl
com.sun.labs.minion.util.buffer.ChannelReadableBuffer
public class ChannelReadableBuffer
A readable buffer that's backed by a channel and an in-memory buffer.
| Field Summary | |
|---|---|
protected long |
be
The offset in the file of the end of the buffer that we represent. |
protected long |
bs
The offset in the file of the buffer that we represent. |
protected java.nio.ByteBuffer |
buff
The in-memory buffer. |
protected java.nio.channels.FileChannel |
chan
The channel containing the buffer. |
protected static int |
DEFAULT_BUFF_SIZE
The default buffer size, 1KB. |
protected static java.lang.String |
logTag
A tag for our log entries. |
protected long |
me
The offset in the file of the end of our in-memory buffer. |
protected long |
ms
The offset in the file of the start of our in-memory buffer. |
protected long |
pos
The offset of the current position in the buffer we're representing. |
| Constructor Summary | |
|---|---|
ChannelReadableBuffer(java.nio.channels.FileChannel chan,
long offset,
int limit,
int buffSize)
Creates a buffer backed by a channel. |
|
ChannelReadableBuffer(java.io.RandomAccessFile raf,
long offset,
int limit)
Creates a buffer backed by a channel. |
|
ChannelReadableBuffer(java.io.RandomAccessFile raf,
long offset,
int limit,
int buffSize)
Creates a buffer backed by a channel. |
|
| Method Summary | |
|---|---|
protected int |
checkBounds(long p)
Checks whether the given position is within the bounds of our in memory buffer. |
ReadableBuffer |
duplicate()
Duplicates this buffer, so that it can be used safely by other readers. |
byte |
get()
Gets the next byte in the buffer. |
byte |
get(int i)
Gets the byte at the given position in the buffer. |
int |
limit()
Gets the limit of this buffer, i.e., the last readable position. |
void |
limit(int l)
Sets the limit of this buffer, i.e., the last readable position. |
int |
position()
Gets the position of the buffer. |
void |
position(int i)
Positions the buffer. |
protected int |
read(long off)
Reads a given number of bytes from the channel. |
int |
remaining()
Gets the number of bytes remaining to be read. |
ReadableBuffer |
slice(int p,
int s)
Slices this buffer so that a sub-buffer can be used. |
java.lang.String |
toString()
Gets a string representation of the buffer. |
| Methods inherited from class com.sun.labs.minion.util.buffer.StdReadableImpl |
|---|
byteDecode, byteDecode, byteDecode, byteDecodeLong, byteDecodeLong, byteDecodeLong, countBits, decodeFloat, getString, skipByteEncoded, test, toString, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected java.nio.channels.FileChannel chan
protected long ms
protected long me
protected long bs
protected long be
protected long pos
protected java.nio.ByteBuffer buff
protected static java.lang.String logTag
protected static final int DEFAULT_BUFF_SIZE
| Constructor Detail |
|---|
public ChannelReadableBuffer(java.io.RandomAccessFile raf,
long offset,
int limit)
raf - The file that will provide the channel backing this buffer.offset - The offset in the file where our buffer is located.limit - The number of bytes in our buffer.
public ChannelReadableBuffer(java.io.RandomAccessFile raf,
long offset,
int limit,
int buffSize)
buffSize - The size of the in-memory buffer to use.raf - The file that will provide the channel backing this buffer.offset - The offset in the file where our buffer is located.limit - The number of bytes in our buffer.
public ChannelReadableBuffer(java.nio.channels.FileChannel chan,
long offset,
int limit,
int buffSize)
chan - The channel backing our buffer.buffSize - The size of the in-memory buffer to use.offset - The offset in the file where our buffer is located.limit - The number of bytes in our buffer.| Method Detail |
|---|
protected int read(long off)
off - The offset in the file from which the bytes should be
read.
protected int checkBounds(long p)
p - The position that we want to check
public int remaining()
public ReadableBuffer duplicate()
public ReadableBuffer slice(int p,
int s)
p - The position at which the buffer should be sliced.s - The number of bytes that should be in the sliced buffer.
public int limit()
public void limit(int l)
l - The limit to set.public byte get(int i)
i - The position from which we want to get a byte.
public byte get()
public int position()
public void position(int i)
i - The position to which we want to set the buffer.public java.lang.String toString()
toString in class StdReadableImpl
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||