MCPcopy Create free account
hub / github.com/ReadyTalk/avian / ByteBuffer

Class ByteBuffer

classpath/java/nio/ByteBuffer.java:13–304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11package java.nio;
12
13public abstract class ByteBuffer
14 extends Buffer
15 implements Comparable<ByteBuffer>
16{
17 private final boolean readOnly;
18
19 protected ByteBuffer(boolean readOnly) {
20 this.readOnly = readOnly;
21 }
22
23 public static ByteBuffer allocate(int capacity) {
24 return new ArrayByteBuffer(new byte[capacity], 0, capacity, false);
25 }
26
27 public static ByteBuffer allocateDirect(int capacity) {
28 return FixedArrayByteBuffer.make(capacity);
29 }
30
31 public static ByteBuffer wrap(byte[] array) {
32 return wrap(array, 0, array.length);
33 }
34
35 public static ByteBuffer wrap(byte[] array, int offset, int length) {
36 return new ArrayByteBuffer(array, offset, length, false);
37 }
38
39 public abstract ByteBuffer asReadOnlyBuffer();
40
41 public abstract ByteBuffer slice();
42
43 protected abstract void doPut(int offset, byte val);
44
45 public abstract ByteBuffer put(byte[] arr, int offset, int len);
46
47 protected abstract byte doGet(int offset);
48
49 public abstract ByteBuffer get(byte[] dst, int offset, int length);
50
51 public boolean hasArray() {
52 return false;
53 }
54
55 public ByteBuffer compact() {
56 int remaining = remaining();
57
58 if (position != 0) {
59 ByteBuffer b = slice();
60 position = 0;
61 put(b);
62 }
63
64 position = remaining;
65 limit(capacity());
66
67 return this;
68 }
69
70 public ByteBuffer put(ByteBuffer src) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected