Home / Class/ TextWebSocketFrame Class — netty Architecture

TextWebSocketFrame Class — netty Architecture

Architecture documentation for the TextWebSocketFrame class in TextWebSocketFrame.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  b938da79_03e0_17ed_ae96_71e6db5e6388["TextWebSocketFrame"]
  68ae46d8_bf64_33e5_55e0_4391d02b0470["TextWebSocketFrame.java"]
  b938da79_03e0_17ed_ae96_71e6db5e6388 -->|defined in| 68ae46d8_bf64_33e5_55e0_4391d02b0470
  547f0009_d9db_20ce_052c_9727c4db503f["TextWebSocketFrame()"]
  b938da79_03e0_17ed_ae96_71e6db5e6388 -->|method| 547f0009_d9db_20ce_052c_9727c4db503f
  7409c25b_6009_6ed5_5eb0_b82a0912f519["ByteBuf()"]
  b938da79_03e0_17ed_ae96_71e6db5e6388 -->|method| 7409c25b_6009_6ed5_5eb0_b82a0912f519
  a30bb922_3677_7e3a_f02d_c77afcb2d9b1["String()"]
  b938da79_03e0_17ed_ae96_71e6db5e6388 -->|method| a30bb922_3677_7e3a_f02d_c77afcb2d9b1

Relationship Graph

Source Code

codec-http/src/main/java/io/netty/handler/codec/http/websocketx/TextWebSocketFrame.java lines 25–140

public class TextWebSocketFrame extends WebSocketFrame {

    /**
     * Creates a new empty text frame.
     */
    public TextWebSocketFrame() {
        super(Unpooled.buffer(0));
    }

    /**
     * Creates a new text frame with the specified text string. The final fragment flag is set to true.
     *
     * @param text
     *            String to put in the frame.
     */
    public TextWebSocketFrame(String text) {
        super(fromText(text));
    }

    /**
     * Creates a new text frame with the specified binary data. The final fragment flag is set to true.
     *
     * @param binaryData
     *            the content of the frame.
     */
    public TextWebSocketFrame(ByteBuf binaryData) {
        super(binaryData);
    }

    /**
     * Creates a new text frame with the specified text string. The final fragment flag is set to true.
     *
     * @param finalFragment
     *            flag indicating if this frame is the final fragment
     * @param rsv
     *            reserved bits used for protocol extensions
     * @param text
     *            String to put in the frame.
     */
    public TextWebSocketFrame(boolean finalFragment, int rsv, String text) {
        super(finalFragment, rsv, fromText(text));
    }

    private static ByteBuf fromText(String text) {
        if (text == null || text.isEmpty()) {
            return Unpooled.EMPTY_BUFFER;
        } else {
            return Unpooled.copiedBuffer(text, CharsetUtil.UTF_8);
        }
    }

    /**
     * Creates a new text frame with the specified binary data and the final fragment flag.
     *
     * @param finalFragment
     *            flag indicating if this frame is the final fragment
     * @param rsv
     *            reserved bits used for protocol extensions
     * @param binaryData
     *            the content of the frame.
     */
    public TextWebSocketFrame(boolean finalFragment, int rsv, ByteBuf binaryData) {
        super(finalFragment, rsv, binaryData);
    }

    /**
     * Returns the text data in this frame.
     */
    public String text() {
        return content().toString(CharsetUtil.UTF_8);
    }

    @Override
    public TextWebSocketFrame copy() {
        return (TextWebSocketFrame) super.copy();
    }

    @Override
    public TextWebSocketFrame duplicate() {
        return (TextWebSocketFrame) super.duplicate();
    }

Frequently Asked Questions

What is the TextWebSocketFrame class?
TextWebSocketFrame is a class in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/http/websocketx/TextWebSocketFrame.java.
Where is TextWebSocketFrame defined?
TextWebSocketFrame is defined in codec-http/src/main/java/io/netty/handler/codec/http/websocketx/TextWebSocketFrame.java at line 25.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free