You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Allocates a new MessageBuffer backed by a byte array.
188
+
*
189
+
* @throws IllegalArgumentException If the capacity is a negative integer
190
+
*
191
+
*/
192
+
publicstaticMessageBufferallocate(intsize)
186
193
{
187
-
returnwrap(newbyte[length]);
194
+
if (size < 0) {
195
+
thrownewIllegalArgumentException("size must not be negative");
196
+
}
197
+
returnwrap(newbyte[size]);
188
198
}
189
199
200
+
/**
201
+
* Wraps a ByteBuffer into a MessageBuffer.
202
+
*
203
+
* The new MessageBuffer will be backed by the given byte array. Modifications to the new MessageBuffer will cause the byte array to be modified and vice versa.
204
+
*
205
+
* The new buffer's size will be array.length. hasArray() will return true.
206
+
*
207
+
* @param array the byte array that will gack this MessageBuffer
208
+
* @return
209
+
*
210
+
*/
190
211
publicstaticMessageBufferwrap(byte[] array)
191
212
{
192
213
returnnewMessageBuffer(array, 0, array.length);
193
214
}
194
215
216
+
/**
217
+
* Wraps a ByteBuffer into a MessageBuffer.
218
+
*
219
+
* The new MessageBuffer will be backed by the given byte array. Modifications to the new MessageBuffer will cause the byte array to be modified and vice versa.
220
+
*
221
+
* The new buffer's size will be length. hasArray() will return true.
222
+
*
223
+
* @param array the byte array that will gack this MessageBuffer
224
+
* @param offset The offset of the subarray to be used; must be non-negative and no larger than array.length
225
+
* @param length The length of the subarray to be used; must be non-negative and no larger than array.length - offset
* The new MessageBuffer will be backed by the given byte buffer. Modifications to the new MessageBuffer will cause the byte buffer to be modified and vice versa. However, change of position, limit, or mark of given byte buffer doesn't affect MessageBuffer.
238
+
*
239
+
* The new buffer's size will be bb.remaining(). hasArray() will return the same result with bb.hasArray().
240
+
*
241
+
* @param bb the byte buffer that will gack this MessageBuffer
242
+
* @throws IllegalArgumentException given byte buffer returns false both from hasArray() and isDirect()
243
+
* @throws UnsupportedOperationException given byte buffer is a direct buffer and this platform doesn't support Unsafe API
0 commit comments