Class Xdr
java.lang.Object
com.emc.ecs.nfsclient.rpc.Xdr
This class handles the serialization and deserialization of primitive types into and out of a
buffer, as specified in RFC 1014 (https://tools.ietf.org/html/rfc1014).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanGet a boolean from the bufferbyte[]Return the entire Xdr bufferbyte[]Get a counted array of bytes from the buffervoidgetBytes(int lengthToCopy, byte[] copyArray, int copyOffset) Get bytes from the xdr buffer to the input bufferfloatgetFloat()Get a floating point number from the bufferintgetInt()Get an integer from the bufferlonggetLong()Get a long from the bufferintReturn the current offsetReturns the terminated list of payloads, properly padded and ready for sending.intgetSize()Return the current size of the XDR bufferGet a string from the bufferlongGet an unsigned integer from the buffer Note that Java has no unsigned integer type so we must return it as a long.intgetXid()Returns the xid.voidputBoolean(boolean b) Put a boolean into the buffervoidputByteArray(byte[] b) Put a counted array of bytes into the buffer.voidputByteArray(byte[] b, int len) Put a counted array of bytes into the buffervoidputByteArray(byte[] b, int boff, int len) Put a counted array of bytes into the buffervoidputByteArray(Xdr x) Put an Xdr buffer into the buffer This is used to encode the RPC credentialsvoidputBytes(byte[] b, int boff, int len) Put a counted array of bytes into the buffer.voidputFloat(float f) Put a floating point number into the buffervoidputInt(int i) Put an integer into the buffervoidputLong(long i) Put a long into the buffervoidputPayloads(List<ByteBuffer> payloads, int size) add payloads, more than one can be added.voidPut a string into the buffervoidputUnsignedInt(long i) Put an unsigned integer into the buffer Note that Java has no unsigned integer type so we must pass it as a long.voidsetOffset(int offset) Set the current offsetvoidsetSize(int size) Set the current size of the XDR buffervoidsetXid(int xid) Set xidvoidskip(int count) Skip a number of bytes.
-
Constructor Details
-
Xdr
public Xdr(int size) Build an Xdr object for serialization.- Parameters:
size- Size of the buffer in bytes.
-
Xdr
public Xdr(byte[] data) Build an Xdr object for deserialization.- Parameters:
data- The data for the buffer.
-
-
Method Details
-
skip
public void skip(int count) Skip a number of bytes. Note that the count is rounded up to the next BLOCK_SIZE.- Parameters:
count- of the buffer in bytes
-
getBuffer
public byte[] getBuffer()Return the entire Xdr buffer- Returns:
- The Xdr buffer
-
getOffset
public int getOffset()Return the current offset- Returns:
- offset into XDR buffer
-
setOffset
public void setOffset(int offset) Set the current offset- Parameters:
offset- offset into XDR buffer
-
getSize
public int getSize()Return the current size of the XDR buffer- Returns:
- size in bytes
-
setSize
public void setSize(int size) Set the current size of the XDR buffer- Parameters:
size- Size of the buffer in bytes
-
getInt
public int getInt()Get an integer from the buffer- Returns:
- integer
-
putInt
public void putInt(int i) Put an integer into the buffer- Parameters:
i- Integer to store in XDR buffer.
-
getUnsignedInt
public long getUnsignedInt()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
-
putUnsignedInt
public void putUnsignedInt(long i) Put an unsigned integer into the buffer Note that Java has no unsigned integer type so we must pass it as a long.- Parameters:
i- unsigned integer to store in XDR buffer.
-
getLong
public long getLong()Get a long from the buffer- Returns:
- long
-
putLong
public void putLong(long i) Put a long into the buffer- Parameters:
i- long to store in XDR buffer
-
getBoolean
public boolean getBoolean()Get a boolean from the buffer- Returns:
- boolean
-
putBoolean
public void putBoolean(boolean b) Put a boolean into the buffer- Parameters:
b- boolean
-
getFloat
public float getFloat()Get a floating point number from the buffer- Returns:
- float
-
putFloat
public void putFloat(float f) Put a floating point number into the buffer- Parameters:
f- float
-
getString
-
putString
-
getByteArray
public byte[] getByteArray()Get a counted array of bytes from the buffer- Returns:
- bytes
-
getBytes
public void getBytes(int lengthToCopy, byte[] copyArray, int copyOffset) Get bytes from the xdr buffer to the input buffer- Parameters:
lengthToCopy- Number of bytes to copy.copyArray- Array to hold the copied data.copyOffset- Where to start the copy.
-
putByteArray
public void putByteArray(byte[] b) Put a counted array of bytes into the buffer. Note that the entire byte array is encoded.- Parameters:
b- byte array
-
putByteArray
public void putByteArray(byte[] b, int len) Put a counted array of bytes into the buffer- Parameters:
b- byte arraylen- number of bytes to encode
-
putByteArray
public void putByteArray(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
-
putByteArray
Put an Xdr buffer into the buffer This is used to encode the RPC credentials- Parameters:
x- XDR buffer
-
putBytes
public void putBytes(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
-
getXid
public int getXid()Returns the xid. -
setXid
public void setXid(int xid) Set xid -
putPayloads
add payloads, more than one can be added. -
getPayloads
Returns the terminated list of payloads, properly padded and ready for sending.
-