Class Xdr

java.lang.Object
com.emc.ecs.nfsclient.rpc.Xdr

public class Xdr extends Object
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
    Constructor
    Description
    Xdr(byte[] data)
    Build an Xdr object for deserialization.
    Xdr(int size)
    Build an Xdr object for serialization.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Get a boolean from the buffer
    byte[]
    Return the entire Xdr buffer
    byte[]
    Get a counted array of bytes from the buffer
    void
    getBytes(int lengthToCopy, byte[] copyArray, int copyOffset)
    Get bytes from the xdr buffer to the input buffer
    float
    Get a floating point number from the buffer
    int
    Get an integer from the buffer
    long
    Get a long from the buffer
    int
    Return the current offset
    Returns the terminated list of payloads, properly padded and ready for sending.
    int
    Return the current size of the XDR buffer
    Get a string from the buffer
    long
    Get an unsigned integer from the buffer Note that Java has no unsigned integer type so we must return it as a long.
    int
    Returns the xid.
    void
    putBoolean(boolean b)
    Put a boolean into the buffer
    void
    putByteArray(byte[] b)
    Put a counted array of bytes into the buffer.
    void
    putByteArray(byte[] b, int len)
    Put a counted array of bytes into the buffer
    void
    putByteArray(byte[] b, int boff, int len)
    Put a counted array of bytes into the buffer
    void
    Put an Xdr buffer into the buffer This is used to encode the RPC credentials
    void
    putBytes(byte[] b, int boff, int len)
    Put a counted array of bytes into the buffer.
    void
    putFloat(float f)
    Put a floating point number into the buffer
    void
    putInt(int i)
    Put an integer into the buffer
    void
    putLong(long i)
    Put a long into the buffer
    void
    putPayloads(List<ByteBuffer> payloads, int size)
    add payloads, more than one can be added.
    void
    Put a string into the buffer
    void
    Put an unsigned integer into the buffer Note that Java has no unsigned integer type so we must pass it as a long.
    void
    setOffset(int offset)
    Set the current offset
    void
    setSize(int size)
    Set the current size of the XDR buffer
    void
    setXid(int xid)
    Set xid
    void
    skip(int count)
    Skip a number of bytes.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public String getString()
      Get a string from the buffer
      Returns:
      string
    • putString

      public void putString(String s)
      Put a string into the buffer
      Parameters:
      s - string
    • 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 array
      len - 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 array
      boff - offset into byte array
      len - number of bytes to encode
    • putByteArray

      public void putByteArray(Xdr x)
      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 array
      boff - offset into byte array
      len - number of bytes to encode
    • getXid

      public int getXid()
      Returns the xid.
    • setXid

      public void setXid(int xid)
      Set xid
    • putPayloads

      public void putPayloads(List<ByteBuffer> payloads, int size)
      add payloads, more than one can be added.
    • getPayloads

      public List<ByteBuffer> getPayloads()
      Returns the terminated list of payloads, properly padded and ready for sending.