Home / Class/ LengthFieldBasedFrameDecoder Class — netty Architecture

LengthFieldBasedFrameDecoder Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  687df7d8_4057_fca4_6694_3143553abf69["LengthFieldBasedFrameDecoder"]
  26622ae9_a99c_200b_c603_0be1e52b0858["LengthFieldBasedFrameDecoder.java"]
  687df7d8_4057_fca4_6694_3143553abf69 -->|defined in| 26622ae9_a99c_200b_c603_0be1e52b0858
  acbeb75a_bfd3_d7c0_b63f_6356be2ea2f3["LengthFieldBasedFrameDecoder()"]
  687df7d8_4057_fca4_6694_3143553abf69 -->|method| acbeb75a_bfd3_d7c0_b63f_6356be2ea2f3
  9f9e29d6_6751_0f27_80ee_3be809f035b2["decode()"]
  687df7d8_4057_fca4_6694_3143553abf69 -->|method| 9f9e29d6_6751_0f27_80ee_3be809f035b2
  eccb157b_d7cc_e4ef_8e1a_92c29ab6d4cd["discardingTooLongFrame()"]
  687df7d8_4057_fca4_6694_3143553abf69 -->|method| eccb157b_d7cc_e4ef_8e1a_92c29ab6d4cd
  f6ba9ada_525e_59d1_6bae_ee1cf2fcdbc1["failOnNegativeLengthField()"]
  687df7d8_4057_fca4_6694_3143553abf69 -->|method| f6ba9ada_525e_59d1_6bae_ee1cf2fcdbc1
  5bfbea73_f4e3_51f7_a58c_8e17cd79f25e["failOnFrameLengthLessThanLengthFieldEndOffset()"]
  687df7d8_4057_fca4_6694_3143553abf69 -->|method| 5bfbea73_f4e3_51f7_a58c_8e17cd79f25e
  afaf5979_a43d_e80f_807f_08d92b1bd469["exceededFrameLength()"]
  687df7d8_4057_fca4_6694_3143553abf69 -->|method| afaf5979_a43d_e80f_807f_08d92b1bd469
  53ffab28_8315_e224_a761_791b1d83f641["failOnFrameLengthLessThanInitialBytesToStrip()"]
  687df7d8_4057_fca4_6694_3143553abf69 -->|method| 53ffab28_8315_e224_a761_791b1d83f641
  f122928e_f2b2_90a0_b78d_5ee053f14758["Object()"]
  687df7d8_4057_fca4_6694_3143553abf69 -->|method| f122928e_f2b2_90a0_b78d_5ee053f14758
  4bacf009_3a37_156a_47bf_7115c7075810["getUnadjustedFrameLength()"]
  687df7d8_4057_fca4_6694_3143553abf69 -->|method| 4bacf009_3a37_156a_47bf_7115c7075810
  85c6af4f_525c_0286_9d46_f6cb70186ae3["failIfNecessary()"]
  687df7d8_4057_fca4_6694_3143553abf69 -->|method| 85c6af4f_525c_0286_9d46_f6cb70186ae3
  8523449d_6ae9_e6d2_c434_761999742442["ByteBuf()"]
  687df7d8_4057_fca4_6694_3143553abf69 -->|method| 8523449d_6ae9_e6d2_c434_761999742442
  377d60e8_ded7_845a_5e05_1f5044b18794["fail()"]
  687df7d8_4057_fca4_6694_3143553abf69 -->|method| 377d60e8_ded7_845a_5e05_1f5044b18794

Relationship Graph

Source Code

codec-base/src/main/java/io/netty/handler/codec/LengthFieldBasedFrameDecoder.java lines 187–516

public class LengthFieldBasedFrameDecoder extends ByteToMessageDecoder {

    private final ByteOrder byteOrder;
    private final int maxFrameLength;
    private final int lengthFieldOffset;
    private final int lengthFieldLength;
    private final int lengthFieldEndOffset;
    private final int lengthAdjustment;
    private final int initialBytesToStrip;
    private final boolean failFast;
    private boolean discardingTooLongFrame;
    private long tooLongFrameLength;
    private long bytesToDiscard;
    private int frameLengthInt = -1;

    /**
     * Creates a new instance.
     *
     * @param maxFrameLength
     *        the maximum length of the frame.  If the length of the frame is
     *        greater than this value, {@link TooLongFrameException} will be
     *        thrown.
     * @param lengthFieldOffset
     *        the offset of the length field
     * @param lengthFieldLength
     *        the length of the length field
     */
    public LengthFieldBasedFrameDecoder(
            int maxFrameLength,
            int lengthFieldOffset, int lengthFieldLength) {
        this(maxFrameLength, lengthFieldOffset, lengthFieldLength, 0, 0);
    }

    /**
     * Creates a new instance.
     *
     * @param maxFrameLength
     *        the maximum length of the frame.  If the length of the frame is
     *        greater than this value, {@link TooLongFrameException} will be
     *        thrown.
     * @param lengthFieldOffset
     *        the offset of the length field
     * @param lengthFieldLength
     *        the length of the length field
     * @param lengthAdjustment
     *        the compensation value to add to the value of the length field
     * @param initialBytesToStrip
     *        the number of first bytes to strip out from the decoded frame
     */
    public LengthFieldBasedFrameDecoder(
            int maxFrameLength,
            int lengthFieldOffset, int lengthFieldLength,
            int lengthAdjustment, int initialBytesToStrip) {
        this(
                maxFrameLength,
                lengthFieldOffset, lengthFieldLength, lengthAdjustment,
                initialBytesToStrip, true);
    }

    /**
     * Creates a new instance.
     *
     * @param maxFrameLength
     *        the maximum length of the frame.  If the length of the frame is
     *        greater than this value, {@link TooLongFrameException} will be
     *        thrown.
     * @param lengthFieldOffset
     *        the offset of the length field
     * @param lengthFieldLength
     *        the length of the length field
     * @param lengthAdjustment
     *        the compensation value to add to the value of the length field
     * @param initialBytesToStrip
     *        the number of first bytes to strip out from the decoded frame
     * @param failFast
     *        If <tt>true</tt>, a {@link TooLongFrameException} is thrown as
     *        soon as the decoder notices the length of the frame will exceed
     *        <tt>maxFrameLength</tt> regardless of whether the entire frame
     *        has been read.  If <tt>false</tt>, a {@link TooLongFrameException}
     *        is thrown after the entire frame that exceeds <tt>maxFrameLength</tt>
     *        has been read.

Frequently Asked Questions

What is the LengthFieldBasedFrameDecoder class?
LengthFieldBasedFrameDecoder is a class in the netty codebase, defined in codec-base/src/main/java/io/netty/handler/codec/LengthFieldBasedFrameDecoder.java.
Where is LengthFieldBasedFrameDecoder defined?
LengthFieldBasedFrameDecoder is defined in codec-base/src/main/java/io/netty/handler/codec/LengthFieldBasedFrameDecoder.java at line 187.

Analyze Your Own Codebase

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

Try Supermodel Free