62 |
{ |
{ |
63 |
super (copy.capacity (), copy.limit (), copy.position (), 0); |
super (copy.capacity (), copy.limit (), copy.position (), 0); |
64 |
backing_buffer = copy.backing_buffer; |
backing_buffer = copy.backing_buffer; |
65 |
|
array_offset = copy.array_offset; |
66 |
readOnly = copy.isReadOnly (); |
readOnly = copy.isReadOnly (); |
67 |
} |
} |
68 |
|
|
128 |
*/ |
*/ |
129 |
public char get () |
public char get () |
130 |
{ |
{ |
131 |
checkForUnderflow(); |
if (pos >= limit) |
132 |
|
throw new BufferUnderflowException(); |
133 |
|
|
134 |
char result = backing_buffer [position ()]; |
return backing_buffer [(pos++) + array_offset]; |
|
position (position () + 1); |
|
|
return result; |
|
135 |
} |
} |
136 |
|
|
137 |
/** |
/** |
142 |
*/ |
*/ |
143 |
public CharBuffer put (char value) |
public CharBuffer put (char value) |
144 |
{ |
{ |
145 |
checkIfReadOnly(); |
if (readOnly) |
146 |
|
throw new ReadOnlyBufferException(); |
147 |
backing_buffer [position ()] = value; |
if (pos >= limit) |
148 |
position (position () + 1); |
throw new BufferOverflowException(); |
149 |
|
|
150 |
|
backing_buffer [(pos++) + array_offset] = value; |
151 |
return this; |
return this; |
152 |
} |
} |
153 |
|
|
164 |
{ |
{ |
165 |
checkIndex(index); |
checkIndex(index); |
166 |
|
|
167 |
return backing_buffer [index]; |
return backing_buffer [index + array_offset]; |
168 |
} |
} |
169 |
|
|
170 |
/** |
/** |
171 |
|
* Bulk get, overloaded for speed. |
172 |
|
*/ |
173 |
|
public CharBuffer get (char[] dst, int offset, int length) |
174 |
|
{ |
175 |
|
checkArraySize(dst.length, offset, length); |
176 |
|
checkForUnderflow(length); |
177 |
|
|
178 |
|
System.arraycopy(backing_buffer, pos + array_offset, |
179 |
|
dst, offset, length); |
180 |
|
pos += length; |
181 |
|
return this; |
182 |
|
} |
183 |
|
|
184 |
|
/** |
185 |
|
* Bulk put, overloaded for speed. |
186 |
|
*/ |
187 |
|
public CharBuffer put (char[] src, int offset, int length) |
188 |
|
{ |
189 |
|
checkArraySize(src.length, offset, length); |
190 |
|
checkForOverflow(length); |
191 |
|
|
192 |
|
System.arraycopy(src, offset, |
193 |
|
backing_buffer, pos + array_offset, length); |
194 |
|
pos += length; |
195 |
|
return this; |
196 |
|
} |
197 |
|
|
198 |
|
/** |
199 |
* Absolute put method. Writes <code>value</code> to position |
* Absolute put method. Writes <code>value</code> to position |
200 |
* <code>index</code> in the buffer. |
* <code>index</code> in the buffer. |
201 |
* |
* |
208 |
checkIndex(index); |
checkIndex(index); |
209 |
checkIfReadOnly(); |
checkIfReadOnly(); |
210 |
|
|
211 |
backing_buffer [index] = value; |
backing_buffer [index + array_offset] = value; |
212 |
return this; |
return this; |
213 |
} |
} |
214 |
|
|