Package com.sun.rpc
Class Xdr
java.lang.Object
com.sun.rpc.Xdr
This class handles the marshalling/unmarshalling of
primitive data types into and out of a buffer.
The XDR buffer is a field within this class and its
size is determined when the class is instantiated.
Other than this buffer, there are just two pointers:
"off" is the current XDR offset into the buffer and
moves up the buffer by an integral number of XDRUNITs
as data are encoded/decoded. The other pointer is
"size" which is the number of valid data bytes in
the buffer and is set only for received buffers.
XXX we should perhaps check that off <= size
whenever an item is decoded so that we can raise
an exception if the received data is underlength.
- Author:
- Brent Callaghan
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
xdr_bool()
Get a boolean from the buffervoid
xdr_bool
(boolean b) Put a boolean into the bufferbyte[]
xdr_buf()
Return the entire Xdr bufferbyte[]
Get a counted array of bytes from the buffervoid
xdr_bytes
(byte[] b) Put a counted array of bytes into the buffer.void
xdr_bytes
(byte[] b, int len) Put a counted array of bytes into the buffervoid
xdr_bytes
(byte[] b, int boff, int len) Put a counted array of bytes into the buffervoid
Put an Xdr buffer into the buffer
This is used to encode the RPC credentialsfloat
Get a floating point number from the buffervoid
xdr_float
(float f) Put a floating point number into the bufferlong
Get a long from the buffervoid
xdr_hyper
(long i) Put a long into the bufferint
xdr_int()
Get an integer from the buffervoid
xdr_int
(int i) Put an integer into the bufferint
Return the current offsetvoid
xdr_offset
(int off) Set the current offsetvoid
xdr_raw
(byte[] b) Put a fixed number of bytes into the buffer The length is not encoded.void
xdr_raw
(byte[] b, int off) Put a fixed number of bytes into the buffer at offset off.void
xdr_raw
(byte[] b, int boff, int len) Put a counted array of bytes into the buffer.byte[]
xdr_raw
(int len) Get a fixed number of bytes from the buffer e.g.byte[]
xdr_raw
(int off, int len) Get a fixed number (len) of bytes from the buffer at offset off.int
xdr_size()
Return the current size of the XDR buffervoid
xdr_size
(int size) Set the current size of the XDR buffervoid
xdr_skip
(int count) Skip a number of bytes.Get a string from the buffervoid
xdr_string
(String s) Put a string into the bufferlong
Get an unsigned integer from the buffer
Note that Java has no unsigned integer type so we must return it as a long.void
xdr_u_int
(long i) Put an unsigned integer into the buffer Note that Java has no unsigned integer type so we must submit it as a long.int
Return the starting point of the bytes that will be encrypted.void
xdr_wrap_offset
(int off) Set the starting point of the bytes that will be encrypted.
-
Constructor Details
-
Xdr
public Xdr(int size) Build a new Xdr object with a buffer of given size- Parameters:
size
- of the buffer in bytes
-
-
Method Details
-
xdr_skip
public void xdr_skip(int count) Skip a number of bytes.
Note that the count is rounded up to the next XDRUNIT.- Parameters:
count
- of the buffer in bytes
-
xdr_buf
public byte[] xdr_buf()Return the entire Xdr buffer- Returns:
- Xdr buffer
-
xdr_offset
public int xdr_offset()Return the current offset- Returns:
- offset
-
xdr_offset
public void xdr_offset(int off) Set the current offset- Parameters:
off
- offset into XDR buffer
-
xdr_wrap_offset
public int xdr_wrap_offset()Return the starting point of the bytes that will be encrypted.- Returns:
- offset for bytes to be encrypted
-
xdr_wrap_offset
public void xdr_wrap_offset(int off) Set the starting point of the bytes that will be encrypted. -
xdr_size
public int xdr_size()Return the current size of the XDR buffer- Returns:
- size
-
xdr_size
public void xdr_size(int size) Set the current size of the XDR buffer- Parameters:
size
- of buffer
-
xdr_int
public int xdr_int()Get an integer from the buffer- Returns:
- integer
-
xdr_int
public void xdr_int(int i) Put an integer into the buffer- Parameters:
i
- Integer to store in XDR buffer.
-
xdr_u_int
public long xdr_u_int()Get an unsigned integer from the buffer
Note that Java has no unsigned integer type so we must return it as a long.- Returns:
- long
-
xdr_u_int
public void xdr_u_int(long i) Put an unsigned integer into the buffer Note that Java has no unsigned integer type so we must submit it as a long.- Parameters:
i
- unsigned integer to store in XDR buffer.
-
xdr_hyper
public long xdr_hyper()Get a long from the buffer- Returns:
- long
-
xdr_hyper
public void xdr_hyper(long i) Put a long into the buffer- Parameters:
i
- long to store in XDR buffer
-
xdr_bool
public boolean xdr_bool()Get a boolean from the buffer- Returns:
- boolean
-
xdr_bool
public void xdr_bool(boolean b) Put a boolean into the buffer- Parameters:
b
- boolean
-
xdr_float
public float xdr_float()Get a floating point number from the buffer- Returns:
- float
-
xdr_float
public void xdr_float(float f) Put a floating point number into the buffer- Parameters:
f
- float
-
xdr_string
Get a string from the buffer- Returns:
- string
-
xdr_string
Put a string into the buffer- Parameters:
s
- string
-
xdr_bytes
public byte[] xdr_bytes()Get a counted array of bytes from the buffer- Returns:
- bytes
-
xdr_bytes
public void xdr_bytes(byte[] b) Put a counted array of bytes into the buffer. Note that the entire byte array is encoded.- Parameters:
b
- byte array
-
xdr_bytes
public void xdr_bytes(byte[] b, int len) Put a counted array of bytes into the buffer- Parameters:
b
- byte arraylen
- number of bytes to encode
-
xdr_bytes
public void xdr_bytes(byte[] b, int boff, int len) Put a counted array of bytes into the buffer- Parameters:
b
- byte arrayboff
- offset into byte arraylen
- number of bytes to encode
-
xdr_bytes
Put an Xdr buffer into the buffer
This is used to encode the RPC credentials- Parameters:
x
- XDR buffer
-
xdr_raw
public byte[] xdr_raw(int len) Get a fixed number of bytes from the buffer e.g. an NFS v2 filehandle- Parameters:
len
- Number of bytes to get- Returns:
- byte array
-
xdr_raw
public byte[] xdr_raw(int off, int len) Get a fixed number (len) of bytes from the buffer at offset off. Do not change any buffer indicators.- Parameters:
off
- Offset of bytes to get fromlen
- Number of bytes to copy- Returns:
- byte array
-
xdr_raw
public void xdr_raw(byte[] b) Put a fixed number of bytes into the buffer The length is not encoded. e.g. an NFS v2 filehandle- Parameters:
b
- byte array
-
xdr_raw
public void xdr_raw(byte[] b, int off) Put a fixed number of bytes into the buffer at offset off. The length is not encoded.- Parameters:
b
- byte arrayoff
- where to put the byte array
-
xdr_raw
public void xdr_raw(byte[] b, int boff, int len) Put a counted array of bytes into the buffer. The length is not encoded.- Parameters:
b
- byte arrayboff
- offset into byte arraylen
- number of bytes to encode
-