asByteBuffer for Buidlers

This commit is contained in:
David Renshaw 2014-10-13 20:20:51 -04:00
parent 4adb78bb89
commit 9e0bd28c60
2 changed files with 18 additions and 2 deletions

View file

@ -82,7 +82,7 @@ public final class Data {
return this.size;
}
public ByteBuffer toByteBuffer() {
public ByteBuffer asByteBuffer() {
ByteBuffer dup = this.buffer.asReadOnlyBuffer();
dup.position(this.offset);
ByteBuffer result = dup.slice();
@ -110,6 +110,14 @@ public final class Data {
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() {
ByteBuffer dup = this.buffer.duplicate();
byte result[] = new byte[this.size];

View file

@ -91,7 +91,7 @@ public final class Text {
return this.size;
}
public ByteBuffer toByteBuffer() {
public ByteBuffer asByteBuffer() {
ByteBuffer dup = this.buffer.asReadOnlyBuffer();
dup.position(this.offset);
ByteBuffer result = dup.slice();
@ -127,6 +127,14 @@ public final class Text {
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
public final String toString() {
byte[] bytes = new byte[this.size];