Home / Class/ BigIntegerDecoder Class — netty Architecture

BigIntegerDecoder Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  504c5c2a_3622_b0bf_68a9_ed7dfc9a7947["BigIntegerDecoder"]
  ae3106d8_e153_1ab3_f1c7_7a27ca73cf96["BigIntegerDecoder.java"]
  504c5c2a_3622_b0bf_68a9_ed7dfc9a7947 -->|defined in| ae3106d8_e153_1ab3_f1c7_7a27ca73cf96
  8428cfda_9bf1_560c_37ae_96a6787a071c["decode()"]
  504c5c2a_3622_b0bf_68a9_ed7dfc9a7947 -->|method| 8428cfda_9bf1_560c_37ae_96a6787a071c

Relationship Graph

Source Code

example/src/main/java/io/netty/example/factorial/BigIntegerDecoder.java lines 32–63

public class BigIntegerDecoder extends ByteToMessageDecoder {

    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) {
        // Wait until the length prefix is available.
        if (in.readableBytes() < 5) {
            return;
        }

        in.markReaderIndex();

        // Check the magic number.
        int magicNumber = in.readUnsignedByte();
        if (magicNumber != 'F') {
            in.resetReaderIndex();
            throw new CorruptedFrameException("Invalid magic number: " + magicNumber);
        }

        // Wait until the whole data is available.
        int dataLength = in.readInt();
        if (in.readableBytes() < dataLength) {
            in.resetReaderIndex();
            return;
        }

        // Convert the received data into a new BigInteger.
        byte[] decoded = new byte[dataLength];
        in.readBytes(decoded);

        out.add(new BigInteger(decoded));
    }
}

Frequently Asked Questions

What is the BigIntegerDecoder class?
BigIntegerDecoder is a class in the netty codebase, defined in example/src/main/java/io/netty/example/factorial/BigIntegerDecoder.java.
Where is BigIntegerDecoder defined?
BigIntegerDecoder is defined in example/src/main/java/io/netty/example/factorial/BigIntegerDecoder.java at line 32.

Analyze Your Own Codebase

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

Try Supermodel Free