1 |
package java.nio; |
package java.nio; |
2 |
|
|
3 |
|
|
4 |
abstract class Buffer |
public abstract class Buffer |
5 |
{ |
{ |
6 |
int cap, limit, pos, mark; |
int cap, limit, pos, mark; |
7 |
|
|
9 |
{ |
{ |
10 |
} |
} |
11 |
|
|
12 |
final int capacity() |
public final int capacity() |
13 |
{ |
{ |
14 |
return cap; |
return cap; |
15 |
} |
} |
16 |
|
|
17 |
final Buffer clear() |
public final int capacity(int c) |
18 |
|
{ |
19 |
|
int old = cap; |
20 |
|
cap = c; |
21 |
|
return old; |
22 |
|
} |
23 |
|
|
24 |
|
public final Buffer clear() |
25 |
{ |
{ |
26 |
limit = cap; |
limit = cap; |
27 |
mark = 0; |
mark = 0; |
29 |
return this; |
return this; |
30 |
} |
} |
31 |
|
|
32 |
final Buffer flip() |
public final Buffer flip() |
33 |
{ |
{ |
34 |
limit = pos; |
limit = pos; |
35 |
pos = 0; |
pos = 0; |
39 |
return this; |
return this; |
40 |
} |
} |
41 |
|
|
42 |
final boolean hasRemaining() |
public final boolean hasRemaining() |
43 |
{ |
{ |
44 |
return limit > pos; |
return limit > pos; |
45 |
} |
} |
46 |
|
|
47 |
abstract boolean isReadOnly(); |
public abstract boolean isReadOnly(); |
48 |
|
|
49 |
|
|
50 |
final int limit() |
public final int limit() |
51 |
{ |
{ |
52 |
return limit; |
return limit; |
53 |
} |
} |
54 |
|
|
55 |
final Buffer limit(int newLimit) |
public final Buffer limit(int newLimit) |
56 |
{ |
{ |
57 |
if (newLimit <= mark) |
if (newLimit <= mark) |
58 |
mark = 0; |
mark = 0; |
64 |
return this; |
return this; |
65 |
} |
} |
66 |
|
|
67 |
final Buffer mark() |
public final Buffer mark() |
68 |
{ |
{ |
69 |
mark = pos; |
mark = pos; |
70 |
return this; |
return this; |
71 |
} |
} |
72 |
|
|
73 |
final int position() |
public final int position() |
74 |
{ |
{ |
75 |
return pos; |
return pos; |
76 |
} |
} |
77 |
|
|
78 |
|
|
79 |
final Buffer position(int newPosition) |
public final Buffer position(int newPosition) |
80 |
{ |
{ |
81 |
/// If the mark is defined and larger than the new |
/// If the mark is defined and larger than the new |
82 |
|
|
87 |
return this; |
return this; |
88 |
} |
} |
89 |
|
|
90 |
final int remaining() |
public final int remaining() |
91 |
{ |
{ |
92 |
return limit - pos; |
return limit - pos; |
93 |
} |
} |
94 |
|
|
95 |
final Buffer reset() |
public final Buffer reset() |
96 |
{ |
{ |
97 |
pos = mark; |
pos = mark; |
98 |
return this; |
return this; |