Class FrameBuilder
java.lang.Object
org.simpleframework.http.socket.service.FrameBuilder
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
FieldsModifier and TypeFieldDescriptionprivate 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 -
Method Summary
Modifier and TypeMethodDescriptioncreate
(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.
-
Field Details
-
converter
This converts binary data to a UTF-8 string for text frames. -
header
This is used to determine the type of frames to create.
-
-
Constructor Details
-
FrameBuilder
Constructor for theFrameBuilder
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
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
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 framecount
- this is the number of bytes in the frame- Returns:
- a new frame containing the text
-
createBinary
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 framecount
- this is the number of bytes in the frame- Returns:
- a new frame containing a copy of the provided data
-