asByteBuffer for Buidlers
This commit is contained in:
parent
4adb78bb89
commit
9e0bd28c60
2 changed files with 18 additions and 2 deletions
|
@ -82,7 +82,7 @@ public final class Data {
|
||||||
return this.size;
|
return this.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ByteBuffer toByteBuffer() {
|
public ByteBuffer asByteBuffer() {
|
||||||
ByteBuffer dup = this.buffer.asReadOnlyBuffer();
|
ByteBuffer dup = this.buffer.asReadOnlyBuffer();
|
||||||
dup.position(this.offset);
|
dup.position(this.offset);
|
||||||
ByteBuffer result = dup.slice();
|
ByteBuffer result = dup.slice();
|
||||||
|
@ -110,6 +110,14 @@ public final class Data {
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ByteBuffer asByteBuffer() {
|
||||||
|
ByteBuffer dup = this.buffer.duplicate();
|
||||||
|
dup.position(this.offset);
|
||||||
|
ByteBuffer result = dup.slice();
|
||||||
|
result.limit(this.size);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public byte[] toArray() {
|
public byte[] toArray() {
|
||||||
ByteBuffer dup = this.buffer.duplicate();
|
ByteBuffer dup = this.buffer.duplicate();
|
||||||
byte result[] = new byte[this.size];
|
byte result[] = new byte[this.size];
|
||||||
|
|
|
@ -91,7 +91,7 @@ public final class Text {
|
||||||
return this.size;
|
return this.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ByteBuffer toByteBuffer() {
|
public ByteBuffer asByteBuffer() {
|
||||||
ByteBuffer dup = this.buffer.asReadOnlyBuffer();
|
ByteBuffer dup = this.buffer.asReadOnlyBuffer();
|
||||||
dup.position(this.offset);
|
dup.position(this.offset);
|
||||||
ByteBuffer result = dup.slice();
|
ByteBuffer result = dup.slice();
|
||||||
|
@ -127,6 +127,14 @@ public final class Text {
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ByteBuffer asByteBuffer() {
|
||||||
|
ByteBuffer dup = this.buffer.duplicate();
|
||||||
|
dup.position(this.offset);
|
||||||
|
ByteBuffer result = dup.slice();
|
||||||
|
result.limit(this.size);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
byte[] bytes = new byte[this.size];
|
byte[] bytes = new byte[this.size];
|
||||||
|
|
Loading…
Reference in a new issue