Class TextData

java.lang.Object
org.simpleframework.http.socket.TextData
All Implemented Interfaces:
Data

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

    Fields
    Modifier and Type
    Field
    Description
    private final DataConverter
    This is used to convert the text payload to a byte array.
    private final String
    This is the text string representing a frame payload.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for the TextData object.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    This returns the binary payload that is to be sent with a frame.
    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 Details

    • converter

      private final DataConverter converter
      This is used to convert the text payload to a byte array.
    • data

      private final String data
      This is the text string representing a frame payload.
  • Constructor Details

    • TextData

      public TextData(String data)
      Constructor for the TextData object. It requires an text string that will be sent as UTF-8 within a frame.
      Parameters:
      data - the text string representing the frame payload
  • Method Details

    • 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 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