|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuk.ac.rdg.resc.jstyx.messages.StyxBuffer
public class StyxBuffer
Wrapper class for a ByteBuffer that allows Styx primitives to be easily read from and written to the buffer. Reads and writes unsigned bytes, shorts and integers, in addition to other Styx types. Before using the methods in this class, you should check that the required number of bytes are available in the ByteBuffer. The easiest way to do this is to read the message length (the first four bytes in the Styx message) and check that this number of bytes are available in the buffer.
| Constructor Summary | |
|---|---|
StyxBuffer(org.apache.mina.common.ByteBuffer buf)
Creates a new instance of StyxBuffer |
|
| Method Summary | |
|---|---|
void |
flip()
Flip the underlying buffer |
org.apache.mina.common.ByteBuffer |
getBuffer()
Gets the underlying ByteBuffer |
byte[] |
getData(int size)
Gets a chunk of data from the buffer. |
DirEntry |
getDirEntry()
|
Qid |
getQid()
|
java.lang.String |
getString()
|
int |
getUByte()
|
long |
getUInt()
|
ULong |
getULong()
|
int |
getUShort()
|
StyxBuffer |
put(byte[] bytes)
|
StyxBuffer |
put(byte[] bytes,
int offset,
int length)
|
StyxBuffer |
putData(org.apache.mina.common.ByteBuffer data)
Puts a chunk of data to the buffer. |
StyxBuffer |
putData(org.apache.mina.common.ByteBuffer data,
long size)
Puts a chunk of data to the buffer. |
StyxBuffer |
putDirEntry(DirEntry dir)
Puts the given DirEntry to the buffer at the current position |
StyxBuffer |
putQid(Qid qid)
Puts the given Qid to the buffer at the current position |
StyxBuffer |
putString(java.lang.String s)
Puts a string into the buffer at the current position. |
StyxBuffer |
putUByte(int b)
Puts an unsigned byte into the buffer at the current position |
StyxBuffer |
putUInt(int index,
long l)
Puts an unsigned int (4 bytes) into the buffer at the given position |
StyxBuffer |
putUInt(long l)
Puts an unsigned int (4 bytes) into the buffer at the current position |
StyxBuffer |
putULong(ULong ulong)
Puts the given ULong to the buffer at the current position |
StyxBuffer |
putUShort(int s)
Puts an unsigned short (2 bytes) into the buffer at the current position |
StyxBuffer |
putUShort(int index,
int s)
Puts an unsigned short (2 bytes) into the buffer at the given position |
int |
remaining()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StyxBuffer(org.apache.mina.common.ByteBuffer buf)
buf - The ByteBuffer to wrap
java.lang.IllegalArgumentException - if the ByteBuffer is null| Method Detail |
|---|
public int getUByte()
public StyxBuffer putUByte(int b)
b - The value of the byte as an integer between 0 and 255
java.lang.IllegalArgumentException - if the parameter is out of rangepublic int getUShort()
public StyxBuffer putUShort(int s)
s - The value of the short as an integer between 0 and 65535
java.lang.IllegalArgumentException - if the parameter is out of range
public StyxBuffer putUShort(int index,
int s)
index - The place in the buffer at which to put the datas - The value of the short as an integer between 0 and 65535
java.lang.IllegalArgumentException - if the parameter is out of rangepublic long getUInt()
public StyxBuffer putUInt(long l)
l - The value of the int as a long integer between 0 and 4,294,967,295
java.lang.IllegalArgumentException - if the parameter is out of range
public StyxBuffer putUInt(int index,
long l)
index - The place in the buffer at which to put the datal - The value of the int as a long integer between 0 and 4,294,967,295
java.lang.IllegalArgumentException - if the parameter is out of rangepublic ULong getULong()
public StyxBuffer putULong(ULong ulong)
ulong - The ulong to write
public java.lang.String getString()
public StyxBuffer putString(java.lang.String s)
s - The string to write to the buffer
public Qid getQid()
public StyxBuffer putQid(Qid qid)
qid - The Qid to write
public DirEntry getDirEntry()
public StyxBuffer putDirEntry(DirEntry dir)
dir - The DirEntry to write
public byte[] getData(int size)
size.
size - the number of bytes to get
java.lang.IllegalArgumentException - if there aren't enough bytes left in the bufferpublic StyxBuffer put(byte[] bytes)
public StyxBuffer put(byte[] bytes,
int offset,
int length)
public StyxBuffer putData(org.apache.mina.common.ByteBuffer data,
long size)
data - The data to write. The position and limit of this buffer will
be unaffected by this method.size - The number of bytes to write
java.lang.IllegalArgumentException - if the buffer does not contain at least
size bytes, or if there is not enough space in the output
buffer for the data.public StyxBuffer putData(org.apache.mina.common.ByteBuffer data)
data - The data to write. The position and limit of this buffer will
be unaffected by this method. All the remaining data in the buffer will
be written.
public org.apache.mina.common.ByteBuffer getBuffer()
public int remaining()
public void flip()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||