|
|
@ -296,12 +296,12 @@ public final class serverByteBuffer extends OutputStream {
|
|
|
|
return getBytes(start, length);
|
|
|
|
return getBytes(start, length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public byte[] getBytes(int start, int end) {
|
|
|
|
public byte[] getBytes(int start, int len) {
|
|
|
|
// start is inclusive, end is exclusive
|
|
|
|
// start is inclusive, end is exclusive
|
|
|
|
if (end > length) throw new IndexOutOfBoundsException("getBytes: end > length");
|
|
|
|
if (len > length) throw new IndexOutOfBoundsException("getBytes: len > length");
|
|
|
|
if (start > length) throw new IndexOutOfBoundsException("getBytes: start > length");
|
|
|
|
if (start > length) throw new IndexOutOfBoundsException("getBytes: start > length");
|
|
|
|
byte[] tmp = new byte[end - start];
|
|
|
|
byte[] tmp = new byte[len];
|
|
|
|
System.arraycopy(buffer, offset + start, tmp, 0, end - start);
|
|
|
|
System.arraycopy(buffer, offset + start, tmp, 0, len);
|
|
|
|
return tmp;
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -313,13 +313,12 @@ public final class serverByteBuffer extends OutputStream {
|
|
|
|
return this;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public serverByteBuffer trim(int start, int end) {
|
|
|
|
public serverByteBuffer trim(int start, int len) {
|
|
|
|
// the end value is outside (+1) of the wanted target array
|
|
|
|
// the end value is outside (+1) of the wanted target array
|
|
|
|
if (start > length) throw new IndexOutOfBoundsException("trim: start > length");
|
|
|
|
if (start > length) throw new IndexOutOfBoundsException("trim: start > length");
|
|
|
|
if (end > length) throw new IndexOutOfBoundsException("trim: end > length");
|
|
|
|
if (start + len > length) throw new IndexOutOfBoundsException("trim: start + len > length");
|
|
|
|
if (start > end) throw new IndexOutOfBoundsException("trim: start > end");
|
|
|
|
|
|
|
|
offset = offset + start;
|
|
|
|
offset = offset + start;
|
|
|
|
length = end - start;
|
|
|
|
length = len;
|
|
|
|
return this;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -337,7 +336,7 @@ public final class serverByteBuffer extends OutputStream {
|
|
|
|
r--;
|
|
|
|
r--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (l > r) r = l;
|
|
|
|
if (l > r) r = l;
|
|
|
|
return trim(l, r);
|
|
|
|
return trim(l, r - l);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int isUTF8char(int start) {
|
|
|
|
public int isUTF8char(int start) {
|
|
|
|