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