Class FrameBuilder

java.lang.Object
org.simpleframework.http.socket.service.FrameBuilder

class FrameBuilder extends Object
The FrameBuilder object is used to create an object that interprets a frame header to produce frame objects. For efficiency this converts binary data to the native frame data type, which avoids memory churn.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final DataConverter
    This converts binary data to a UTF-8 string for text frames.
    private final FrameHeader
    This is used to determine the type of frames to create.
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    create(byte[] data, int count)
    This is used to create a frame object to represent the data that has been consumed.
    private Frame
    createBinary(byte[] data, int count)
    This is used to create a frame object from the provided data.
    private Frame
    createText(byte[] data, int count)
    This is used to create a frame object from the provided data.

    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 converts binary data to a UTF-8 string for text frames.
  • Constructor Details

    • FrameBuilder

      public FrameBuilder(FrameHeader header)
      Constructor for the FrameBuilder object. This acts as a factory for frame objects by using the provided header to determine the frame type to be created.
      Parameters:
      header - the header used to determine the frame type
  • Method Details

    • create

      public Frame create(byte[] data, int count)
      This is used to create a frame object to represent the data that has been consumed. The frame created will contain either a copy of the provided byte buffer or a text string encoded in UTF-8. To avoid memory churn this method should be used sparingly.
      Returns:
      this returns a frame created from the consumed bytes
    • createText

      private Frame createText(byte[] data, int count)
      This is used to create a frame object from the provided data. The resulting frame will contain a UTF-8 encoding of the data to ensure that data conversion needs to be performed only once.
      Parameters:
      data - this is the data to convert to a new frame
      count - this is the number of bytes in the frame
      Returns:
      a new frame containing the text
    • createBinary

      private Frame createBinary(byte[] data, int count)
      This is used to create a frame object from the provided data. The resulting frame will contain a copy of the data to ensure that the frame is immutable.
      Parameters:
      data - this is the data to convert to a new frame
      count - this is the number of bytes in the frame
      Returns:
      a new frame containing a copy of the provided data