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

Class ArrayCharBuffer

classpath/java/nio/ArrayCharBuffer.java:13–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11package java.nio;
12
13class ArrayCharBuffer extends CharBuffer {
14 private final char[] array;
15 private final int arrayOffset;
16
17 ArrayCharBuffer(char[] array, int offset, int length, boolean readOnly) {
18 super(readOnly);
19
20 this.array = array;
21 this.arrayOffset = offset;
22 this.capacity = length;
23 this.limit = length;
24 this.position = 0;
25 }
26
27 public CharBuffer asReadOnlyBuffer() {
28 CharBuffer b = new ArrayCharBuffer(array, arrayOffset, capacity, true);
29 b.position(position());
30 b.limit(limit());
31 return b;
32 }
33
34 public boolean hasArray() {
35 return true;
36 }
37
38 public char[] array() {
39 return array;
40 }
41
42 public CharBuffer slice() {
43 return new ArrayCharBuffer
44 (array, arrayOffset + position, remaining(), true);
45 }
46
47 public int arrayOffset() {
48 return arrayOffset;
49 }
50
51 protected void doPut(int position, char val) {
52 array[arrayOffset + position] = val;
53 }
54
55 public CharBuffer put(CharBuffer src) {
56 int length = src.remaining();
57 checkPut(position, length, false);
58 src.get(array, arrayOffset + position, length);
59 position += length;
60 return this;
61 }
62
63 public CharBuffer put(char[] src, int offset, int length) {
64 checkPut(position, length, false);
65
66 System.arraycopy(src, offset, array, arrayOffset + position, length);
67 position += length;
68
69 return this;
70 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected