Fix inconsistent code in the doc
This commit is contained in:
parent
8869f6d5c1
commit
d062500ca0
@ -40,21 +40,21 @@ import java.util.List;
|
||||
*
|
||||
* {@code @Override}
|
||||
* protected void decode({@link ChannelHandlerContext} ctx,
|
||||
* {@link ByteBuf} in, List<Object> out) throws Exception {
|
||||
* {@link ByteBuf} buf, List<Object> out) throws Exception {
|
||||
*
|
||||
* if (in.readableBytes() < 4) {
|
||||
* if (buf.readableBytes() < 4) {
|
||||
* return;
|
||||
* }
|
||||
*
|
||||
* in.markReaderIndex();
|
||||
* int length = in.readInt();
|
||||
* buf.markReaderIndex();
|
||||
* int length = buf.readInt();
|
||||
*
|
||||
* if (in.readableBytes() < length) {
|
||||
* in.resetReaderIndex();
|
||||
* if (buf.readableBytes() < length) {
|
||||
* buf.resetReaderIndex();
|
||||
* return;
|
||||
* }
|
||||
*
|
||||
* out.add(in.readBytes(length));
|
||||
* out.add(buf.readBytes(length));
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
@ -108,11 +108,11 @@ import java.util.List;
|
||||
* private final Queue<Integer> values = new LinkedList<Integer>();
|
||||
*
|
||||
* {@code @Override}
|
||||
* public void decode(.., {@link ByteBuf} in, List<Object> out) throws Exception {
|
||||
* public void decode(.., {@link ByteBuf} buf, List<Object> out) throws Exception {
|
||||
*
|
||||
* // A message contains 2 integers.
|
||||
* values.offer(buffer.readInt());
|
||||
* values.offer(buffer.readInt());
|
||||
* values.offer(buf.readInt());
|
||||
* values.offer(buf.readInt());
|
||||
*
|
||||
* // This assertion will fail intermittently since values.offer()
|
||||
* // can be called more than two times!
|
||||
@ -128,15 +128,15 @@ import java.util.List;
|
||||
* private final Queue<Integer> values = new LinkedList<Integer>();
|
||||
*
|
||||
* {@code @Override}
|
||||
* public void decode(.., {@link ByteBuf} buffer, List<Object> out) throws Exception {
|
||||
* public void decode(.., {@link ByteBuf} buf, List<Object> out) throws Exception {
|
||||
*
|
||||
* // Revert the state of the variable that might have been changed
|
||||
* // since the last partial decode.
|
||||
* values.clear();
|
||||
*
|
||||
* // A message contains 2 integers.
|
||||
* values.offer(buffer.readInt());
|
||||
* values.offer(buffer.readInt());
|
||||
* values.offer(buf.readInt());
|
||||
* values.offer(buf.readInt());
|
||||
*
|
||||
* // Now we know this assertion will never fail.
|
||||
* assert values.size() == 2;
|
||||
@ -181,7 +181,7 @@ import java.util.List;
|
||||
*
|
||||
* {@code @Override}
|
||||
* protected void decode({@link ChannelHandlerContext} ctx,
|
||||
* {@link ByteBuf} in, List<Object> out) throws Exception {
|
||||
* {@link ByteBuf} buf, List<Object> out) throws Exception {
|
||||
* switch (state()) {
|
||||
* case READ_LENGTH:
|
||||
* length = buf.readInt();
|
||||
@ -209,7 +209,7 @@ import java.util.List;
|
||||
*
|
||||
* {@code @Override}
|
||||
* protected void decode({@link ChannelHandlerContext} ctx,
|
||||
* {@link ByteBuf} in, List<Object> out) throws Exception {
|
||||
* {@link ByteBuf} buf, List<Object> out) throws Exception {
|
||||
* if (!readLength) {
|
||||
* length = buf.readInt();
|
||||
* <strong>readLength = true;</strong>
|
||||
@ -240,7 +240,7 @@ import java.util.List;
|
||||
*
|
||||
* {@code @Override}
|
||||
* protected Object decode({@link ChannelHandlerContext} ctx,
|
||||
* {@link ByteBuf} in, List<Object> out) {
|
||||
* {@link ByteBuf} buf, List<Object> out) {
|
||||
* ...
|
||||
* // Decode the first message
|
||||
* Object firstMessage = ...;
|
||||
|
Loading…
Reference in New Issue
Block a user