Class ByteArrayPortability

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected ByteArrayPortability()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] decode​(java.nio.ByteBuffer buffer)
      Decodes a ByteBuffer to an object of type T.
      java.nio.ByteBuffer encode​(byte[] object)
      Encodes an object of type T as a ByteBuffer.
      boolean equals​(java.lang.Object value, java.nio.ByteBuffer readBuffer)
      Byte arrays do not have a content-based equals method so this throws UnsupportedOperationException.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ByteArrayPortability

        protected ByteArrayPortability()
    • Method Detail

      • encode

        public java.nio.ByteBuffer encode​(byte[] object)
        Description copied from interface: Portability
        Encodes an object of type T as a ByteBuffer.
        Specified by:
        encode in interface Portability<byte[]>
        Parameters:
        object - object to be encoded
        Returns:
        the encoded object
      • decode

        public byte[] decode​(java.nio.ByteBuffer buffer)
        Description copied from interface: Portability
        Decodes a ByteBuffer to an object of type T.
        Specified by:
        decode in interface Portability<byte[]>
        Parameters:
        buffer - bytes to decode
        Returns:
        the decoded object
      • equals

        public boolean equals​(java.lang.Object value,
                              java.nio.ByteBuffer readBuffer)
                       throws java.lang.UnsupportedOperationException
        Byte arrays do not have a content-based equals method so this throws UnsupportedOperationException.

        The lack of any implementation only prevents this portability being used as a key portability. Using byte arrays as keys in map would be extremely questionable in any case. If necessary this portability could be sub-classed to do deep array comparison.

        Specified by:
        equals in interface Portability<byte[]>
        Parameters:
        value - object to compare to
        readBuffer - buffer containing encoded object
        Returns:
        true if the two parameters are "equal"
        Throws:
        java.lang.UnsupportedOperationException