LimitingByteInput Class — netty Architecture
Architecture documentation for the LimitingByteInput class in LimitingByteInput.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD c5c36d29_ecd9_7704_2f67_15ca8292c82e["LimitingByteInput"] 291670ca_6e0a_12e7_8363_206751830e69["LimitingByteInput.java"] c5c36d29_ecd9_7704_2f67_15ca8292c82e -->|defined in| 291670ca_6e0a_12e7_8363_206751830e69 acacd848_de35_d71a_9adf_ee20b3518746["LimitingByteInput()"] c5c36d29_ecd9_7704_2f67_15ca8292c82e -->|method| acacd848_de35_d71a_9adf_ee20b3518746 138fa31a_7a93_cc70_65bd_329ebd75daff["close()"] c5c36d29_ecd9_7704_2f67_15ca8292c82e -->|method| 138fa31a_7a93_cc70_65bd_329ebd75daff 3b3797ed_417a_acd6_f95e_95753e878cba["available()"] c5c36d29_ecd9_7704_2f67_15ca8292c82e -->|method| 3b3797ed_417a_acd6_f95e_95753e878cba 1019e723_9db7_b296_4ef1_8d016a42b837["read()"] c5c36d29_ecd9_7704_2f67_15ca8292c82e -->|method| 1019e723_9db7_b296_4ef1_8d016a42b837 e26fa2aa_8891_169f_9e19_570e00faa453["skip()"] c5c36d29_ecd9_7704_2f67_15ca8292c82e -->|method| e26fa2aa_8891_169f_9e19_570e00faa453 f09b7189_d7e1_d0fd_7d5d_feea5a427b8b["readable()"] c5c36d29_ecd9_7704_2f67_15ca8292c82e -->|method| f09b7189_d7e1_d0fd_7d5d_feea5a427b8b
Relationship Graph
Source Code
codec-marshalling/src/main/java/io/netty/handler/codec/marshalling/LimitingByteInput.java lines 28–104
class LimitingByteInput implements ByteInput {
// Use a static instance here to remove the overhead of fillStacktrace
private static final TooBigObjectException EXCEPTION = new TooBigObjectException();
private final ByteInput input;
private final long limit;
private long read;
LimitingByteInput(ByteInput input, long limit) {
this.input = input;
this.limit = checkPositive(limit, "limit");
}
@Override
public void close() throws IOException {
// Nothing to do
}
@Override
public int available() throws IOException {
return readable(input.available());
}
@Override
public int read() throws IOException {
int readable = readable(1);
if (readable > 0) {
int b = input.read();
read++;
return b;
} else {
throw EXCEPTION;
}
}
@Override
public int read(byte[] array) throws IOException {
return read(array, 0, array.length);
}
@Override
public int read(byte[] array, int offset, int length) throws IOException {
int readable = readable(length);
if (readable > 0) {
int i = input.read(array, offset, readable);
read += i;
return i;
} else {
throw EXCEPTION;
}
}
@Override
public long skip(long bytes) throws IOException {
int readable = readable((int) bytes);
if (readable > 0) {
long i = input.skip(readable);
read += i;
return i;
} else {
throw EXCEPTION;
}
}
private int readable(int length) {
return (int) Math.min(length, limit - read);
}
/**
* Exception that will get thrown if the {@link Object} is too big to unmarshall
*
*/
static final class TooBigObjectException extends IOException {
private static final long serialVersionUID = 1L;
}
}
Defined In
Source
Frequently Asked Questions
What is the LimitingByteInput class?
LimitingByteInput is a class in the netty codebase, defined in codec-marshalling/src/main/java/io/netty/handler/codec/marshalling/LimitingByteInput.java.
Where is LimitingByteInput defined?
LimitingByteInput is defined in codec-marshalling/src/main/java/io/netty/handler/codec/marshalling/LimitingByteInput.java at line 28.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free