All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class distinct.rpc.XDRStream

java.lang.Object
   |
   +----distinct.rpc.XDRStream

public class XDRStream
extends Object
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)).

See Also:
XDRInputStream

Variable Index

 o alloc_size
 o buffer
 o in
 o out

Constructor Index

 o XDRStream()
Creates a new XDRStream with default allocation size.
 o XDRStream(byte[], int)
Creates a new XDRStream initialized from a byte array.
 o XDRStream(int)
Creates a new XDRStream with a given allocation size.

Method Index

 o dump()
Writes the contents of the XDRStream to System.out.
 o get_byte()
Reads one byte from the XDRStream.
 o get_bytes(int)
Reads a number of bytes from the XDRStream.
 o get_data()
Returns all bytes available in the XDRStream.
 o get_length()
Reports the number of bytes available in the XDRStream.
 o put_byte(byte)
Writes one byte to the XDRStream.
 o put_bytes(byte[], int)
Writes a number of bytes to the XDRStream.
 o reset()
Clears the XDRStream.
 o xdr_decode_boolean()
Decodes a boolean in compliance to RFC 1832 (XDR).
 o xdr_decode_char()
Decodes a character in compliance to RFC 1832 (XDR).
 o xdr_decode_double()
Decodes a double in compliance to RFC 1832 (XDR).
 o xdr_decode_float()
Decodes a float in compliance to RFC 1832 (XDR).
 o xdr_decode_int()
Decodes an integer in compliance to RFC 1832 (XDR).
 o xdr_decode_long()
Decodes a long in compliance to RFC 1832 (XDR).
 o xdr_decode_opaque()
Decodes an opaque byte array in compliance to RFC 1832 (XDR).
 o xdr_decode_opaque(int)
Decodes an opaque byte array in compliance to RFC 1832 (XDR).
 o xdr_decode_short()
Decodes a short in compliance to RFC 1832 (XDR).
 o xdr_decode_string()
Decodes a string in compliance to RFC 1832 (XDR).
 o xdr_decode_string(int)
Decodes a string in compliance to RFC 1832 (XDR).
 o xdr_encode_boolean(boolean)
Encodes a boolean in compliance to RFC 1832 (XDR).
 o xdr_encode_char(char)
Encodes a character in compliance to RFC 1832 (XDR).
 o xdr_encode_double(double)
Encodes a double in compliance to RFC 1832 (XDR).
 o xdr_encode_float(float)
Encodes a float in compliance to RFC 1832 (XDR).
 o xdr_encode_int(int)
Encodes an integer in compliance to RFC 1832 (XDR).
 o xdr_encode_long(long)
Encodes a long in compliance to RFC 1832 (XDR).
 o xdr_encode_opaque(byte[])
Encodes an opaque array in compliance to RFC 1832 (XDR).
 o xdr_encode_opaque(byte[], int)
Encodes an opaque array in compliance to RFC 1832 (XDR).
 o xdr_encode_short(short)
Encodes a short in compliance to RFC 1832 (XDR).
 o xdr_encode_string(String)
Encodes a string in compliance to RFC 1832 (XDR).
 o xdr_encode_string(String, int)
Encodes a string in compliance to RFC 1832 (XDR).

Variables

 o buffer
 protected byte buffer[]
 o alloc_size
 protected int alloc_size
 o in
 protected int in
 o out
 protected int out

Constructors

 o XDRStream
 public XDRStream()
Creates a new XDRStream with default allocation size.

 o XDRStream
 public XDRStream(byte b[],
                  int length)
Creates a new XDRStream initialized from a byte array.

Parameters:
b - The byte array with the initialization data.
length - The length of the byte array.
 o XDRStream
 public XDRStream(int alloc)
Creates a new XDRStream with a given allocation size.

Parameters:
alloc - The allocation size of the XDRStream.

Methods

 o put_byte
 public void put_byte(byte b)
Writes one byte to the XDRStream. Used by the "encode" methods.

Parameters:
b - The byte to be written.
 o put_bytes
 public void put_bytes(byte b[],
                       int n)
Writes a number of bytes to the XDRStream. Used by the "decode" methods.

Parameters:
b - The bytes to be written.
n - The number of bytes to be written.
 o get_byte
 public byte get_byte() throws RPCError
Reads one byte from the XDRStream. Used by the "decode" methods.

Returns:
Byte read.
Throws: RPCError
When the calls fails because of timeout, empty stream or other input error.
 o get_bytes
 public byte[] get_bytes(int n) throws RPCError
Reads a number of bytes from the XDRStream. Used by the "decode" methods.

Parameters:
n - The number of bytes to be read.
Returns:
Bytes read.
Throws: RPCError
When the calls fails because of timeout, empty stream or other input error.
 o get_length
 public int get_length()
Reports the number of bytes available in the XDRStream.

Returns:
Number of bytes available.
 o get_data
 public byte[] get_data()
Returns all bytes available in the XDRStream.

Returns:
Bytes available.
 o reset
 public void reset()
Clears the XDRStream.

 o dump
 public void dump()
Writes the contents of the XDRStream to System.out.

 o xdr_encode_int
 public void xdr_encode_int(int x)
Encodes an integer in compliance to RFC 1832 (XDR).

Parameters:
x - The integer to be encoded.
 o xdr_decode_int
 public int xdr_decode_int() throws RPCError
Decodes an integer in compliance to RFC 1832 (XDR).

Returns:
The decoded integer.
Throws: RPCError
When the calls fails for any reason.
 o xdr_encode_long
 public void xdr_encode_long(long x)
Encodes a long in compliance to RFC 1832 (XDR).

Parameters:
x - The long to be encoded.
 o xdr_decode_long
 public long xdr_decode_long() throws RPCError
Decodes a long in compliance to RFC 1832 (XDR).

Returns:
The decoded long.
Throws: RPCError
When the calls fails for any reason.
 o xdr_encode_short
 public void xdr_encode_short(short x)
Encodes a short in compliance to RFC 1832 (XDR).

Parameters:
x - The short to be encoded.
 o xdr_decode_short
 public short xdr_decode_short() throws RPCError
Decodes a short in compliance to RFC 1832 (XDR).

Returns:
The decoded short.
Throws: RPCError
When the calls fails for any reason.
 o xdr_encode_char
 public void xdr_encode_char(char x)
Encodes a character in compliance to RFC 1832 (XDR).

Parameters:
x - The character to be encoded.
 o xdr_decode_char
 public char xdr_decode_char() throws RPCError
Decodes a character in compliance to RFC 1832 (XDR).

Returns:
The decoded character.
Throws: RPCError
When the calls fails for any reason.
 o xdr_encode_boolean
 public void xdr_encode_boolean(boolean x)
Encodes a boolean in compliance to RFC 1832 (XDR).

Parameters:
x - The boolean to be encoded.
 o xdr_decode_boolean
 public boolean xdr_decode_boolean() throws RPCError
Decodes a boolean in compliance to RFC 1832 (XDR).

Returns:
The decoded boolean.
Throws: RPCError
When the calls fails for any reason.
 o xdr_encode_opaque
 public void xdr_encode_opaque(byte data[],
                               int n)
Encodes an opaque array in compliance to RFC 1832 (XDR).

Parameters:
data - The array of bytes to be encoded.
n - The length of the array.
 o xdr_decode_opaque
 public byte[] xdr_decode_opaque(int n) throws RPCError
Decodes an opaque byte array in compliance to RFC 1832 (XDR).

Parameters:
n - The length of the opaque byte array.
Returns:
The decoded opaque byte array.
Throws: RPCError
When the calls fails for any reason.
 o xdr_encode_opaque
 public void xdr_encode_opaque(byte data[])
Encodes an opaque array in compliance to RFC 1832 (XDR).

Parameters:
data - The array of bytes to be encoded.
 o xdr_decode_opaque
 public byte[] xdr_decode_opaque() throws RPCError
Decodes an opaque byte array in compliance to RFC 1832 (XDR).

Returns:
The decoded opaque byte array.
Throws: RPCError
When the calls fails for any reason.
 o xdr_encode_float
 public void xdr_encode_float(float data)
Encodes a float in compliance to RFC 1832 (XDR).

Parameters:
data - The float to be encoded.
 o xdr_decode_float
 public float xdr_decode_float() throws RPCError
Decodes a float in compliance to RFC 1832 (XDR).

Returns:
The decoded float.
Throws: RPCError
When the calls fails for any reason.
 o xdr_encode_double
 public void xdr_encode_double(double data)
Encodes a double in compliance to RFC 1832 (XDR).

Parameters:
data - The double to be encoded.
 o xdr_decode_double
 public double xdr_decode_double() throws RPCError
Decodes a double in compliance to RFC 1832 (XDR).

Returns:
The decoded double.
Throws: RPCError
When the calls fails for any reason.
 o xdr_encode_string
 public void xdr_encode_string(String s,
                               int n)
Encodes a string in compliance to RFC 1832 (XDR).

Parameters:
s - The string of bytes to be encoded.
n - The length of the string.
 o xdr_decode_string
 public String xdr_decode_string(int n) throws RPCError
Decodes a string in compliance to RFC 1832 (XDR).

Parameters:
n - The length of the string.
Returns:
The decoded string.
Throws: RPCError
When the calls fails for any reason.
 o xdr_encode_string
 public void xdr_encode_string(String s)
Encodes a string in compliance to RFC 1832 (XDR).

Parameters:
s - The string to be encoded.
 o xdr_decode_string
 public String xdr_decode_string() throws RPCError
Decodes a string in compliance to RFC 1832 (XDR).

Returns:
The decoded string.
Throws: RPCError
When the calls fails for any reason.

All Packages  Class Hierarchy  This Package  Previous  Next  Index