Class BinaryData

  • All Implemented Interfaces:
    Data

    public class BinaryData
    extends java.lang.Object
    implements Data
    The BinaryData object represents a binary payload for a WebScoket frame. This can be used to send any type of data. If however it is used to send text data then it is decoded as UTF-8.
    See Also:
    DataFrame
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private DataConverter converter
      This is used to convert the binary payload to text.
      private byte[] data
      This is the byte array that represents the binary payload.
    • Constructor Summary

      Constructors 
      Constructor Description
      BinaryData​(byte[] data)
      Constructor for the BinaryData object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] getBinary()
      This returns the binary payload that is to be sent with a frame.
      java.lang.String getText()
      This returns the text payload that is to be sent with a frame.
      • Methods inherited from class java.lang.Object

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

      • converter

        private final DataConverter converter
        This is used to convert the binary payload to text.
      • data

        private final byte[] data
        This is the byte array that represents the binary payload.
    • Constructor Detail

      • BinaryData

        public BinaryData​(byte[] data)
        Constructor for the BinaryData object. It requires an array of binary data that will be send within a frame.
        Parameters:
        data - the byte array representing the frame payload
    • Method Detail

      • getBinary

        public byte[] getBinary()
        This returns the binary payload that is to be sent with a frame. It contains no headers or other meta data. If the original data was text this converts it to UTF-8.
        Specified by:
        getBinary in interface Data
        Returns:
        the binary payload to be sent with the frame
      • getText

        public java.lang.String getText()
        This returns the text payload that is to be sent with a frame. It contains no header information or meta data. Caution should be used with this method as binary payloads will encode to garbage when decoded as UTF-8.
        Specified by:
        getText in interface Data
        Returns:
        the text payload to be sent with the frame