decode() — netty Function Reference
Architecture documentation for the decode() function in StompSubframeDecoder.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD fd100759_15a7_86d8_adba_9357f44b5503["decode()"] 5bc4bbff_e257_f941_b64b_cc169e78395f["StompSubframeDecoder"] fd100759_15a7_86d8_adba_9357f44b5503 -->|defined in| 5bc4bbff_e257_f941_b64b_cc169e78395f d60415f7_ec81_651a_810b_72aecdd2499a["skipControlCharacters()"] fd100759_15a7_86d8_adba_9357f44b5503 -->|calls| d60415f7_ec81_651a_810b_72aecdd2499a 6e99cba7_849d_8ae6_06e4_865ce4ad4a82["skipNullCharacter()"] fd100759_15a7_86d8_adba_9357f44b5503 -->|calls| 6e99cba7_849d_8ae6_06e4_865ce4ad4a82 e3cbb665_2033_7f48_953c_4fed59025526["resetDecoder()"] fd100759_15a7_86d8_adba_9357f44b5503 -->|calls| e3cbb665_2033_7f48_953c_4fed59025526 style fd100759_15a7_86d8_adba_9357f44b5503 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-stomp/src/main/java/io/netty/handler/codec/stomp/StompSubframeDecoder.java lines 99–192
@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;
}
if (toRead > maxChunkSize) {
toRead = maxChunkSize;
}
if (contentLength >= 0) {
int remainingLength = (int) (contentLength - alreadyReadChunkSize);
if (toRead > remainingLength) {
toRead = remainingLength;
}
ByteBuf chunkBuffer = readBytes(ctx.alloc(), in, toRead);
if ((alreadyReadChunkSize += toRead) >= contentLength) {
lastContent = new DefaultLastStompContentSubframe(chunkBuffer);
checkpoint(State.FINALIZE_FRAME_READ);
} else {
out.add(new DefaultStompContentSubframe(chunkBuffer));
return;
}
} else {
int nulIndex = indexOf(in, in.readerIndex(), in.writerIndex(), StompConstants.NUL);
if (nulIndex == in.readerIndex()) {
checkpoint(State.FINALIZE_FRAME_READ);
} else {
if (nulIndex > 0) {
toRead = nulIndex - in.readerIndex();
} else {
toRead = in.writerIndex() - in.readerIndex();
}
ByteBuf chunkBuffer = readBytes(ctx.alloc(), in, toRead);
alreadyReadChunkSize += toRead;
if (nulIndex > 0) {
lastContent = new DefaultLastStompContentSubframe(chunkBuffer);
checkpoint(State.FINALIZE_FRAME_READ);
} else {
out.add(new DefaultStompContentSubframe(chunkBuffer));
return;
}
}
}
// Fall through.
case FINALIZE_FRAME_READ:
skipNullCharacter(in);
if (lastContent == null) {
lastContent = LastStompContentSubframe.EMPTY_LAST_CONTENT;
}
out.add(lastContent);
resetDecoder();
Domain
Subdomains
Source
Frequently Asked Questions
What does decode() do?
decode() is a function in the netty codebase, defined in codec-stomp/src/main/java/io/netty/handler/codec/stomp/StompSubframeDecoder.java.
Where is decode() defined?
decode() is defined in codec-stomp/src/main/java/io/netty/handler/codec/stomp/StompSubframeDecoder.java at line 99.
What does decode() call?
decode() calls 3 function(s): resetDecoder, skipControlCharacters, skipNullCharacter.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free