|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.distinct.rpc.XDRStream
XDRStream implements a dynamically growing buffer of bytes (in fact a queue). The constructors allow for creating an empty XDRStream (with default allocation size 1024), an empty XDRStream with user defined allocation size (just a possible optimization), or an XDRStream initialized with the content of an existing byte-array (usually the start of the decoding procedure). The put_byte(), put_bytes() and all xdr_encode_xxx() methods add bytes to the head of the queue, while the get_byte(), get_bytes() and all xdr_decode_xxx() methods consume bytes from the tail. With get_length() and get_data() you can request the current length and content of the queue without changing its status. The reset() method resets the XDRStream to an empty queue. dump() just prints the content of the queue in hex and ASCII to System.out (typically used for debugging).
All xdr_decode and xdr_encode methods for the basic types (and therefore also the methods created by Jrpcgen for constructed XDR types) finally use the put_byte/s and get_byte/s methods for writing to and reading from the buffer. So you can derive your own XDRStream class and overwrite just these methods for building an XDRStream that reads and/or writes from/to any data source you like (like XDRInputStream which reads from a standard Java InputStream (writing is undefined in this class)).
XDRInputStream| Field Summary | |
protected int |
alloc_size
|
protected byte[] |
buffer
|
protected int |
in
|
protected int |
out
|
| Constructor Summary | |
XDRStream()
Creates a new XDRStream with default allocation size. |
|
XDRStream(byte[] b,
int length)
Creates a new XDRStream initialized from a byte array. |
|
XDRStream(int alloc)
Creates a new XDRStream with a given allocation size. |
|
| Method Summary | |
void |
dump()
Writes the contents of the XDRStream to System.out. |
byte |
get_byte()
Reads one byte from the XDRStream. |
byte[] |
get_bytes(int n)
Reads a number of bytes from the XDRStream. |
byte[] |
get_data()
Returns all bytes available in the XDRStream. |
int |
get_length()
Reports the number of bytes available in the XDRStream. |
void |
put_byte(byte b)
Writes one byte to the XDRStream. |
void |
put_bytes(byte[] b,
int n)
Writes a number of bytes to the XDRStream. |
void |
reset()
Clears the XDRStream. |
boolean |
xdr_decode_boolean()
Decodes a boolean in compliance to RFC 1832 (XDR). |
char |
xdr_decode_char()
Decodes a character in compliance to RFC 1832 (XDR). |
double |
xdr_decode_double()
Decodes a double in compliance to RFC 1832 (XDR). |
float |
xdr_decode_float()
Decodes a float in compliance to RFC 1832 (XDR). |
int |
xdr_decode_int()
Decodes an integer in compliance to RFC 1832 (XDR). |
long |
xdr_decode_long()
Decodes a long in compliance to RFC 1832 (XDR). |
byte[] |
xdr_decode_opaque()
Decodes an opaque byte array in compliance to RFC 1832 (XDR). |
byte[] |
xdr_decode_opaque(int n)
Decodes an opaque byte array in compliance to RFC 1832 (XDR). |
short |
xdr_decode_short()
Decodes a short in compliance to RFC 1832 (XDR). |
java.lang.String |
xdr_decode_string()
Decodes a string in compliance to RFC 1832 (XDR). |
java.lang.String |
xdr_decode_string(int n)
Decodes a string in compliance to RFC 1832 (XDR). |
void |
xdr_encode_boolean(boolean x)
Encodes a boolean in compliance to RFC 1832 (XDR). |
void |
xdr_encode_char(char x)
Encodes a character in compliance to RFC 1832 (XDR). |
void |
xdr_encode_double(double data)
Encodes a double in compliance to RFC 1832 (XDR). |
void |
xdr_encode_float(float data)
Encodes a float in compliance to RFC 1832 (XDR). |
void |
xdr_encode_int(int x)
Encodes an integer in compliance to RFC 1832 (XDR). |
void |
xdr_encode_long(long x)
Encodes a long in compliance to RFC 1832 (XDR). |
void |
xdr_encode_opaque(byte[] data)
Encodes an opaque array in compliance to RFC 1832 (XDR). |
void |
xdr_encode_opaque(byte[] data,
int n)
Encodes an opaque array in compliance to RFC 1832 (XDR). |
void |
xdr_encode_short(short x)
Encodes a short in compliance to RFC 1832 (XDR). |
void |
xdr_encode_string(java.lang.String s)
Encodes a string in compliance to RFC 1832 (XDR). |
void |
xdr_encode_string(java.lang.String s,
int n)
Encodes a string in compliance to RFC 1832 (XDR). |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected byte[] buffer
protected int alloc_size
protected int in
protected int out
| Constructor Detail |
public XDRStream()
public XDRStream(byte[] b,
int length)
b - The byte array with the initialization data.length - The length of the byte array.public XDRStream(int alloc)
alloc - The allocation size of the XDRStream.| Method Detail |
public void put_byte(byte b)
b - The byte to be written.
public void put_bytes(byte[] b,
int n)
b - The bytes to be written.n - The number of bytes to be written.
public byte get_byte()
throws RPCError
RPCError - When the calls fails because of timeout, empty stream or other input error.
public byte[] get_bytes(int n)
throws RPCError
n - The number of bytes to be read.
RPCError - When the calls fails because of timeout, empty stream or other input error.public int get_length()
public byte[] get_data()
public void reset()
public void dump()
public void xdr_encode_int(int x)
x - The integer to be encoded.
public int xdr_decode_int()
throws RPCError
RPCError - When the calls fails for any reason.public void xdr_encode_long(long x)
x - The long to be encoded.
public long xdr_decode_long()
throws RPCError
RPCError - When the calls fails for any reason.public void xdr_encode_short(short x)
x - The short to be encoded.
public short xdr_decode_short()
throws RPCError
RPCError - When the calls fails for any reason.public void xdr_encode_char(char x)
x - The character to be encoded.
public char xdr_decode_char()
throws RPCError
RPCError - When the calls fails for any reason.public void xdr_encode_boolean(boolean x)
x - The boolean to be encoded.
public boolean xdr_decode_boolean()
throws RPCError
RPCError - When the calls fails for any reason.
public void xdr_encode_opaque(byte[] data,
int n)
data - The array of bytes to be encoded.n - The length of the array.
public byte[] xdr_decode_opaque(int n)
throws RPCError
n - The length of the opaque byte array.
RPCError - When the calls fails for any reason.public void xdr_encode_opaque(byte[] data)
data - The array of bytes to be encoded.
public byte[] xdr_decode_opaque()
throws RPCError
RPCError - When the calls fails for any reason.public void xdr_encode_float(float data)
data - The float to be encoded.
public float xdr_decode_float()
throws RPCError
RPCError - When the calls fails for any reason.public void xdr_encode_double(double data)
data - The double to be encoded.
public double xdr_decode_double()
throws RPCError
RPCError - When the calls fails for any reason.
public void xdr_encode_string(java.lang.String s,
int n)
s - The string of bytes to be encoded.n - The length of the string.
public java.lang.String xdr_decode_string(int n)
throws RPCError
n - The length of the string.
RPCError - When the calls fails for any reason.public void xdr_encode_string(java.lang.String s)
s - The string to be encoded.
public java.lang.String xdr_decode_string()
throws RPCError
RPCError - When the calls fails for any reason.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||