protobuf
This commit is contained in:
@@ -33,14 +33,6 @@ public class ProtobufByteBufferReader extends ProtobufReader {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected int remaining() {
|
||||
int count = 0;
|
||||
for (int i = currentIndex; i < buffers.length; i++) {
|
||||
count += buffers[i].remaining();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
protected byte nextByte() {
|
||||
if (this.currentBuffer.hasRemaining()) {
|
||||
this.position++;
|
||||
@@ -84,6 +76,9 @@ public class ProtobufByteBufferReader extends ProtobufReader {
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
if (this.limit > 0 && (this.position + 1) >= this.limit) {
|
||||
return false;
|
||||
}
|
||||
if (currentBuffer.hasRemaining()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -18,14 +18,14 @@ public class ProtobufReader extends Reader {
|
||||
|
||||
protected int position = -1;
|
||||
|
||||
protected byte[] content;
|
||||
|
||||
protected int limit;
|
||||
protected int limit = -1;
|
||||
|
||||
protected int cacheTag = Integer.MIN_VALUE;
|
||||
|
||||
protected boolean enumtostring;
|
||||
|
||||
private byte[] content;
|
||||
|
||||
public ProtobufReader() {
|
||||
// do nothing
|
||||
}
|
||||
@@ -284,6 +284,7 @@ public class ProtobufReader extends Reader {
|
||||
|
||||
public final int[] readInts() {
|
||||
int len = readRawVarint32();
|
||||
System.out.println("等到长度: " + len);
|
||||
List<Integer> list = new ArrayList<>(len);
|
||||
while (len > 0) {
|
||||
int val = readInt();
|
||||
|
||||
@@ -33,12 +33,6 @@ class ProtobufStreamReader extends ProtobufByteBufferReader {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int remaining() {
|
||||
int count = 0;
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected byte nextByte() {
|
||||
if (backByte != null) {
|
||||
|
||||
Reference in New Issue
Block a user