Class AbstractXdrType<T>

java.lang.Object
org.apache.kerby.xdr.type.AbstractXdrType<T>
Type Parameters:
T - the type of the value encoded/decoded or wrapped by this
All Implemented Interfaces:
XdrType
Direct Known Subclasses:
XdrSimple, XdrStructType, XdrUnion

public abstract class AbstractXdrType<T> extends Object implements XdrType
The abstract XDR type for all the XDR types. It provides basic encoding and decoding utilities.
  • Constructor Details

    • AbstractXdrType

      public AbstractXdrType(XdrDataType dataType, T value)
      Default constructor.
      Parameters:
      dataType - the dataType
      value - the value
    • AbstractXdrType

      public AbstractXdrType(XdrDataType dataType)
      Default constructor.
      Parameters:
      dataType - the dataType
  • Method Details

    • encode

      public byte[] encode() throws IOException
      Description copied from interface: XdrType
      Encode the type, by recursively.
      Specified by:
      encode in interface XdrType
      Returns:
      encoded bytes
      Throws:
      IOException - e
    • encode

      public void encode(ByteBuffer buffer) throws IOException
      Description copied from interface: XdrType
      Encode the type, by recursively, using the provided buffer.
      Specified by:
      encode in interface XdrType
      Parameters:
      buffer - The byte buffer
      Throws:
      IOException - e
    • encodeBody

      protected abstract void encodeBody(ByteBuffer buffer) throws IOException
      Throws:
      IOException
    • decode

      public void decode(byte[] content) throws IOException
      Description copied from interface: XdrType
      Decode the content bytes into this type.
      Specified by:
      decode in interface XdrType
      Parameters:
      content - The content bytes
      Throws:
      IOException - e
    • encodingLength

      public int encodingLength() throws IOException
      Description copied from interface: XdrType
      Get length of encoding bytes by just calculating without real encoding. Generally it's called to prepare for the encoding buffer.
      Specified by:
      encodingLength in interface XdrType
      Returns:
      length of encoding bytes
      Throws:
      IOException - e
    • encodingBodyLength

      protected abstract int encodingBodyLength() throws IOException
      Throws:
      IOException
    • decode

      public void decode(ByteBuffer content) throws IOException
      Description copied from interface: XdrType
      Decode the content bytes into this type.
      Specified by:
      decode in interface XdrType
      Parameters:
      content - The content bytes
      Throws:
      IOException - e
    • getValue

      public T getValue()
    • setValue

      public void setValue(T value)
    • getDataType

      public XdrDataType getDataType()