Home / Class/ StompSubframeDecoder Class — netty Architecture

StompSubframeDecoder Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  5bc4bbff_e257_f941_b64b_cc169e78395f["StompSubframeDecoder"]
  0eb6c218_fd84_4ac9_b764_f0c162e318dd["StompSubframeDecoder.java"]
  5bc4bbff_e257_f941_b64b_cc169e78395f -->|defined in| 0eb6c218_fd84_4ac9_b764_f0c162e318dd
  41f18135_96ae_8745_f5d5_f4ad260aec59["StompSubframeDecoder()"]
  5bc4bbff_e257_f941_b64b_cc169e78395f -->|method| 41f18135_96ae_8745_f5d5_f4ad260aec59
  fd100759_15a7_86d8_adba_9357f44b5503["decode()"]
  5bc4bbff_e257_f941_b64b_cc169e78395f -->|method| fd100759_15a7_86d8_adba_9357f44b5503
  6cabd8c6_43a7_4222_a824_f288bc49a874["StompCommand()"]
  5bc4bbff_e257_f941_b64b_cc169e78395f -->|method| 6cabd8c6_43a7_4222_a824_f288bc49a874
  d328abca_1078_b2e2_44d8_9e62f7682f41["State()"]
  5bc4bbff_e257_f941_b64b_cc169e78395f -->|method| d328abca_1078_b2e2_44d8_9e62f7682f41
  4a639534_b853_5613_c6d3_d411105bfe77["getContentLength()"]
  5bc4bbff_e257_f941_b64b_cc169e78395f -->|method| 4a639534_b853_5613_c6d3_d411105bfe77
  6e99cba7_849d_8ae6_06e4_865ce4ad4a82["skipNullCharacter()"]
  5bc4bbff_e257_f941_b64b_cc169e78395f -->|method| 6e99cba7_849d_8ae6_06e4_865ce4ad4a82
  d60415f7_ec81_651a_810b_72aecdd2499a["skipControlCharacters()"]
  5bc4bbff_e257_f941_b64b_cc169e78395f -->|method| d60415f7_ec81_651a_810b_72aecdd2499a
  e3cbb665_2033_7f48_953c_4fed59025526["resetDecoder()"]
  5bc4bbff_e257_f941_b64b_cc169e78395f -->|method| e3cbb665_2033_7f48_953c_4fed59025526

Relationship Graph

Source Code

codec-stomp/src/main/java/io/netty/handler/codec/stomp/StompSubframeDecoder.java lines 53–441

public class StompSubframeDecoder extends ReplayingDecoder<State> {

    private static final int DEFAULT_CHUNK_SIZE = 8132;
    private static final int DEFAULT_MAX_LINE_LENGTH = 1024;

    /**
     * @deprecated this should never be used by an user!
     */
    @Deprecated
    public enum State {
        SKIP_CONTROL_CHARACTERS,
        READ_HEADERS,
        READ_CONTENT,
        FINALIZE_FRAME_READ,
        BAD_FRAME,
        INVALID_CHUNK
    }

    private final Utf8LineParser commandParser;
    private final HeaderParser headerParser;
    private final int maxChunkSize;
    private int alreadyReadChunkSize;
    private LastStompContentSubframe lastContent;
    private long contentLength = -1;

    public StompSubframeDecoder() {
        this(DEFAULT_MAX_LINE_LENGTH, DEFAULT_CHUNK_SIZE);
    }

    public StompSubframeDecoder(boolean validateHeaders) {
        this(DEFAULT_MAX_LINE_LENGTH, DEFAULT_CHUNK_SIZE, validateHeaders);
    }

    public StompSubframeDecoder(int maxLineLength, int maxChunkSize) {
        this(maxLineLength, maxChunkSize, false);
    }

    public StompSubframeDecoder(int maxLineLength, int maxChunkSize, boolean validateHeaders) {
        super(State.SKIP_CONTROL_CHARACTERS);
        checkPositive(maxLineLength, "maxLineLength");
        checkPositive(maxChunkSize, "maxChunkSize");
        this.maxChunkSize = maxChunkSize;
        commandParser = new Utf8LineParser(new AppendableCharSequence(16), maxLineLength);
        headerParser = new HeaderParser(new AppendableCharSequence(128), maxLineLength, validateHeaders);
    }

    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        switch (state()) {
            case SKIP_CONTROL_CHARACTERS:
                skipControlCharacters(in);
                checkpoint(State.READ_HEADERS);
                // Fall through.
            case READ_HEADERS:
                StompCommand command = StompCommand.UNKNOWN;
                StompHeadersSubframe frame = null;
                try {
                    command = readCommand(in);
                    frame = new DefaultStompHeadersSubframe(command);
                    checkpoint(readHeaders(in, frame));
                    out.add(frame);
                } catch (Exception e) {
                    if (frame == null) {
                        frame = new DefaultStompHeadersSubframe(command);
                    }
                    frame.setDecoderResult(DecoderResult.failure(e));
                    out.add(frame);
                    checkpoint(State.BAD_FRAME);
                    return;
                }
                break;
            case BAD_FRAME:
                in.skipBytes(actualReadableBytes());
                return;
        }
        try {
            switch (state()) {
                case READ_CONTENT:
                    int toRead = in.readableBytes();
                    if (toRead == 0) {
                        return;

Frequently Asked Questions

What is the StompSubframeDecoder class?
StompSubframeDecoder is a class in the netty codebase, defined in codec-stomp/src/main/java/io/netty/handler/codec/stomp/StompSubframeDecoder.java.
Where is StompSubframeDecoder defined?
StompSubframeDecoder is defined in codec-stomp/src/main/java/io/netty/handler/codec/stomp/StompSubframeDecoder.java at line 53.

Analyze Your Own Codebase

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

Try Supermodel Free