Package com.sun.rpc
Class Xdr
- java.lang.Object
-
- com.sun.rpc.Xdr
-
public class Xdr extends java.lang.ObjectThis 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:
Rpc
-
-
Constructor Summary
Constructors Constructor Description Xdr(int size)Build a new Xdr object with a buffer of given size
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanxdr_bool()Get a boolean from the buffervoidxdr_bool(boolean b)Put a boolean into the bufferbyte[]xdr_buf()Return the entire Xdr bufferbyte[]xdr_bytes()Get a counted array of bytes from the buffervoidxdr_bytes(byte[] b)Put a counted array of bytes into the buffer.voidxdr_bytes(byte[] b, int len)Put a counted array of bytes into the buffervoidxdr_bytes(byte[] b, int boff, int len)Put a counted array of bytes into the buffervoidxdr_bytes(Xdr x)Put an Xdr buffer into the buffer
This is used to encode the RPC credentialsfloatxdr_float()Get a floating point number from the buffervoidxdr_float(float f)Put a floating point number into the bufferlongxdr_hyper()Get a long from the buffervoidxdr_hyper(long i)Put a long into the bufferintxdr_int()Get an integer from the buffervoidxdr_int(int i)Put an integer into the bufferintxdr_offset()Return the current offsetvoidxdr_offset(int off)Set the current offsetvoidxdr_raw(byte[] b)Put a fixed number of bytes into the buffer The length is not encoded.voidxdr_raw(byte[] b, int off)Put a fixed number of bytes into the buffer at offset off.voidxdr_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.intxdr_size()Return the current size of the XDR buffervoidxdr_size(int size)Set the current size of the XDR buffervoidxdr_skip(int count)Skip a number of bytes.java.lang.Stringxdr_string()Get a string from the buffervoidxdr_string(java.lang.String s)Put a string into the bufferlongxdr_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.voidxdr_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.intxdr_wrap_offset()Return the starting point of the bytes that will be encrypted.voidxdr_wrap_offset(int off)Set the starting point of the bytes that will be encrypted.
-
-
-
Method Detail
-
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
public java.lang.String xdr_string()
Get a string from the buffer- Returns:
- string
-
xdr_string
public void xdr_string(java.lang.String s)
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
public void xdr_bytes(Xdr x)
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
-
-