/
Buffer.java
702 lines (608 loc) · 25 KB
/
Buffer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
/*
* Copyright (c) 2011-2013 The original author or authors
* ------------------------------------------------------
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.vertx.core.buffer;
import io.netty.buffer.ByteBuf;
import io.vertx.codegen.annotations.Fluent;
import io.vertx.codegen.annotations.GenIgnore;
import io.vertx.codegen.annotations.VertxGen;
import io.vertx.core.ServiceHelper;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.core.shareddata.impl.ClusterSerializable;
import io.vertx.core.spi.BufferFactory;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
/**
* Most data is shuffled around inside Vert.x using buffers.
* <p>
* A buffer is a sequence of zero or more bytes that can read from or written to and which expands automatically as
* necessary to accommodate any bytes written to it. You can perhaps think of a buffer as smart byte array.
* <p>
* Please consult the documentation for more information on buffers.
*
* @author <a href="http://tfox.org">Tim Fox</a>
*/
@VertxGen
public interface Buffer extends ClusterSerializable {
/**
* Create a new, empty buffer.
*
* @return the buffer
*/
static Buffer buffer() {
return factory.buffer();
}
/**
* Create a new buffer given the initial size hint.
* <p>
* If you know the buffer will require a certain size, providing the hint can prevent unnecessary re-allocations
* as the buffer is written to and resized.
*
* @param initialSizeHint the hint, in bytes
* @return the buffer
*/
static Buffer buffer(int initialSizeHint) {
return factory.buffer(initialSizeHint);
}
/**
* Create a new buffer from a string. The string will be UTF-8 encoded into the buffer.
*
* @param string the string
* @return the buffer
*/
static Buffer buffer(String string) {
return factory.buffer(string);
}
/**
* Create a new buffer from a string and using the specified encoding.
* The string will be encoded into the buffer using the specified encoding.
*
* @param string the string
* @return the buffer
*/
static Buffer buffer(String string, String enc) {
return factory.buffer(string, enc);
}
/**
* Create a new buffer from a byte[]. The byte[] will be copied to form the buffer.
*
* @param bytes the byte array
* @return the buffer
*/
@GenIgnore
static Buffer buffer(byte[] bytes) {
return factory.buffer(bytes);
}
/**
* <p>
* Create a new buffer from a Netty {@code ByteBuf}.
* <i>Note that</i> the returned buffer is backed by given Netty ByteBuf,
* so changes in the returned buffer are reflected in given Netty ByteBuf, and vice-versa.
* </p>
* <p>
* For example, both buffers in the code below share their data:
* </p>
* <pre>
* Buffer src = Buffer.buffer();
* Buffer clone = Buffer.buffer(src.getByteBuf());
* </pre>
*
* @param byteBuf the Netty ByteBuf
* @return the buffer
*/
@GenIgnore
static Buffer buffer(ByteBuf byteBuf) {
return factory.buffer(byteBuf);
}
/**
* Returns a {@code String} representation of the Buffer with the {@code UTF-8 }encoding
*/
String toString();
/**
* Returns a {@code String} representation of the Buffer with the encoding specified by {@code enc}
*/
String toString(String enc);
/**
* Returns a {@code String} representation of the Buffer with the encoding specified by {@code enc}
*/
@GenIgnore
String toString(Charset enc);
/**
* Returns a Json object representation of the Buffer
*/
JsonObject toJsonObject();
/**
* Returns a Json array representation of the Buffer
*/
JsonArray toJsonArray();
/**
* Returns the {@code byte} at position {@code pos} in the Buffer.
*
* @throws IndexOutOfBoundsException if the specified {@code pos} is less than {@code 0} or {@code pos + 1} is greater than the length of the Buffer.
*/
byte getByte(int pos);
/**
* Returns the unsigned {@code byte} at position {@code pos} in the Buffer, as a {@code short}.
*
* @throws IndexOutOfBoundsException if the specified {@code pos} is less than {@code 0} or {@code pos + 1} is greater than the length of the Buffer.
*/
short getUnsignedByte(int pos);
/**
* Returns the {@code int} at position {@code pos} in the Buffer.
*
* @throws IndexOutOfBoundsException if the specified {@code pos} is less than {@code 0} or {@code pos + 4} is greater than the length of the Buffer.
*/
int getInt(int pos);
/**
* Gets a 32-bit integer at the specified absolute {@code index} in this buffer with Little Endian Byte Order.
*
* @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or {@code index + 4} is greater than {@code this.capacity}
*/
int getIntLE(int pos);
/**
* Returns the unsigned {@code int} at position {@code pos} in the Buffer, as a {@code long}.
*
* @throws IndexOutOfBoundsException if the specified {@code pos} is less than {@code 0} or {@code pos + 4} is greater than the length of the Buffer.
*/
long getUnsignedInt(int pos);
/**
* Returns the unsigned {@code int} at position {@code pos} in the Buffer, as a {@code long} in Little Endian Byte Order.
*
* @throws IndexOutOfBoundsException if the specified {@code pos} is less than {@code 0} or {@code pos + 4} is greater than the length of the Buffer.
*/
long getUnsignedIntLE(int pos);
/**
* Returns the {@code long} at position {@code pos} in the Buffer.
*
* @throws IndexOutOfBoundsException if the specified {@code pos} is less than {@code 0} or {@code pos + 8} is greater than the length of the Buffer.
*/
long getLong(int pos);
/**
* Gets a 64-bit long integer at the specified absolute {@code index} in this buffer in Little Endian Byte Order.
*
* @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or {@code index + 8} is greater than the length of the Buffer.
*/
long getLongLE(int pos);
/**
* Returns the {@code double} at position {@code pos} in the Buffer.
*
* @throws IndexOutOfBoundsException if the specified {@code pos} is less than {@code 0} or {@code pos + 8} is greater than the length of the Buffer.
*/
double getDouble(int pos);
/**
* Returns the {@code float} at position {@code pos} in the Buffer.
*
* @throws IndexOutOfBoundsException if the specified {@code pos} is less than {@code 0} or {@code pos + 4} is greater than the length of the Buffer.
*/
float getFloat(int pos);
/**
* Returns the {@code short} at position {@code pos} in the Buffer.
*
* @throws IndexOutOfBoundsException if the specified {@code pos} is less than {@code 0} or {@code pos + 2} is greater than the length of the Buffer.
*/
short getShort(int pos);
/**
* Gets a 16-bit short integer at the specified absolute {@code index} in this buffer in Little Endian Byte Order.
*
* @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or {@code index + 2} is greater than the length of the Buffer.
*/
short getShortLE(int pos);
/**
* Returns the unsigned {@code short} at position {@code pos} in the Buffer, as an {@code int}.
*
* @throws IndexOutOfBoundsException if the specified {@code pos} is less than {@code 0} or {@code pos + 2} is greater than the length of the Buffer.
*/
int getUnsignedShort(int pos);
/**
* Gets an unsigned 16-bit short integer at the specified absolute {@code index} in this buffer in Little Endian Byte Order.
*
* @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or {@code index + 2} is greater than the length of the Buffer.
*/
int getUnsignedShortLE(int pos);
/**
* Gets a 24-bit medium integer at the specified absolute {@code index} in this buffer.
*
* @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or {@code index + 3} is greater than the length of the Buffer.
*/
int getMedium(int pos);
/**
* Gets a 24-bit medium integer at the specified absolute {@code index} in this buffer in the Little Endian Byte Order.
*
* @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or {@code index + 3} is greater than the length of the Buffer.
*/
int getMediumLE(int pos);
/**
* Gets an unsigned 24-bit medium integer at the specified absolute {@code index} in this buffer.
*
* @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or {@code index + 3} is greater than the length of the Buffer.
*/
int getUnsignedMedium(int pos);
/**
* Gets an unsigned 24-bit medium integer at the specified absolute {@code index} in this buffer in Little Endian Byte Order.
*
* @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or {@code index + 3} is greater than the length of the Buffer.
*/
int getUnsignedMediumLE(int pos);
/**
* Returns a copy of the entire Buffer as a {@code byte[]}
*/
@GenIgnore
byte[] getBytes();
/**
* Returns a copy of a sub-sequence the Buffer as a {@code byte[]} starting at position {@code start}
* and ending at position {@code end - 1}
*/
@GenIgnore
byte[] getBytes(int start, int end);
/**
* Transfers the content of the Buffer into a {@code byte[]}.
*
* @param dst the destination byte array
* @throws IndexOutOfBoundsException if the content of the Buffer cannot fit into the destination byte array
*/
@GenIgnore
Buffer getBytes(byte[] dst);
/**
* Transfers the content of the Buffer into a {@code byte[]} at the specific destination.
*
* @param dst the destination byte array
* @throws IndexOutOfBoundsException if the content of the Buffer cannot fit into the destination byte array
*/
@GenIgnore
Buffer getBytes(byte[] dst, int dstIndex);
/**
* Transfers the content of the Buffer starting at position {@code start} and ending at position {@code end - 1}
* into a {@code byte[]}.
*
* @param dst the destination byte array
* @throws IndexOutOfBoundsException if the content of the Buffer cannot fit into the destination byte array
*/
@GenIgnore
Buffer getBytes(int start, int end, byte[] dst);
/**
* Transfers the content of the Buffer starting at position {@code start} and ending at position {@code end - 1}
* into a {@code byte[]} at the specific destination.
*
* @param dst the destination byte array
* @throws IndexOutOfBoundsException if the content of the Buffer cannot fit into the destination byte array
*/
@GenIgnore
Buffer getBytes(int start, int end, byte[] dst, int dstIndex);
/**
* Returns a copy of a sub-sequence the Buffer as a {@link io.vertx.core.buffer.Buffer} starting at position {@code start}
* and ending at position {@code end - 1}
*/
Buffer getBuffer(int start, int end);
/**
* Returns a copy of a sub-sequence the Buffer as a {@code String} starting at position {@code start}
* and ending at position {@code end - 1} interpreted as a String in the specified encoding
*/
String getString(int start, int end, String enc);
/**
* Returns a copy of a sub-sequence the Buffer as a {@code String} starting at position {@code start}
* and ending at position {@code end - 1} interpreted as a String in UTF-8 encoding
*/
String getString(int start, int end);
/**
* Appends the specified {@code Buffer} to the end of this Buffer. The buffer will expand as necessary to accommodate
* any bytes written.<p>
* Returns a reference to {@code this} so multiple operations can be appended together.
*/
@Fluent
Buffer appendBuffer(Buffer buff);
/**
* Appends the specified {@code Buffer} starting at the {@code offset} using {@code len} to the end of this Buffer. The buffer will expand as necessary to accommodate
* any bytes written.<p>
* Returns a reference to {@code this} so multiple operations can be appended together.
*/
@Fluent
Buffer appendBuffer(Buffer buff, int offset, int len);
/**
* Appends the specified {@code byte[]} to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.<p>
* Returns a reference to {@code this} so multiple operations can be appended together.
*/
@GenIgnore
@Fluent
Buffer appendBytes(byte[] bytes);
/**
* Appends the specified number of bytes from {@code byte[]} to the end of the Buffer, starting at the given offset.
* The buffer will expand as necessary to accommodate any bytes written.<p>
* Returns a reference to {@code this} so multiple operations can be appended together.
*/
@GenIgnore
@Fluent
Buffer appendBytes(byte[] bytes, int offset, int len);
/**
* Appends the specified {@code byte} to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.<p>
* Returns a reference to {@code this} so multiple operations can be appended together.
*/
@Fluent
Buffer appendByte(byte b);
/**
* Appends the specified unsigned {@code byte} to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.<p>
* Returns a reference to {@code this} so multiple operations can be appended together.
*/
@Fluent
Buffer appendUnsignedByte(short b);
/**
* Appends the specified {@code int} to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.<p>
* Returns a reference to {@code this} so multiple operations can be appended together.
*/
@Fluent
Buffer appendInt(int i);
/**
* Appends the specified {@code int} to the end of the Buffer in the Little Endian Byte Order. The buffer will expand as necessary to accommodate any bytes written.<p>
* Returns a reference to {@code this} so multiple operations can be appended together.
*/
@Fluent
Buffer appendIntLE(int i);
/**
* Appends the specified unsigned {@code int} to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.<p>
* Returns a reference to {@code this} so multiple operations can be appended together.
*/
@Fluent
Buffer appendUnsignedInt(long i);
/**
* Appends the specified unsigned {@code int} to the end of the Buffer in the Little Endian Byte Order. The buffer will expand as necessary to accommodate any bytes written.<p>
* Returns a reference to {@code this} so multiple operations can be appended together.
*/
@Fluent
Buffer appendUnsignedIntLE(long i);
/**
* Appends the specified 24bit {@code int} to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.<p>
* Returns a reference to {@code this} so multiple operations can be appended together.
*/
@Fluent
Buffer appendMedium(int i);
/**
* Appends the specified 24bit {@code int} to the end of the Buffer in the Little Endian Byte Order. The buffer will expand as necessary to accommodate any bytes written.<p>
* Returns a reference to {@code this} so multiple operations can be appended together.
*/
@Fluent
Buffer appendMediumLE(int i);
/**
* Appends the specified {@code long} to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.<p>
* Returns a reference to {@code this} so multiple operations can be appended together.
*/
@Fluent
Buffer appendLong(long l);
/**
* Appends the specified {@code long} to the end of the Buffer in the Little Endian Byte Order. The buffer will expand as necessary to accommodate any bytes written.<p>
* Returns a reference to {@code this} so multiple operations can be appended together.
*/
@Fluent
Buffer appendLongLE(long l);
/**
* Appends the specified {@code short} to the end of the Buffer.The buffer will expand as necessary to accommodate any bytes written.<p>
* Returns a reference to {@code this} so multiple operations can be appended together.
*/
@Fluent
Buffer appendShort(short s);
/**
* Appends the specified {@code short} to the end of the Buffer in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any bytes written.<p>
* Returns a reference to {@code this} so multiple operations can be appended together.
*/
@Fluent
Buffer appendShortLE(short s);
/**
* Appends the specified unsigned {@code short} to the end of the Buffer.The buffer will expand as necessary to accommodate any bytes written.<p>
* Returns a reference to {@code this} so multiple operations can be appended together.
*/
@Fluent
Buffer appendUnsignedShort(int s);
/**
* Appends the specified unsigned {@code short} to the end of the Buffer in the Little Endian Byte Order.The buffer will expand as necessary to accommodate any bytes written.<p>
* Returns a reference to {@code this} so multiple operations can be appended together.
*/
@Fluent
Buffer appendUnsignedShortLE(int s);
/**
* Appends the specified {@code float} to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.<p>
* Returns a reference to {@code this} so multiple operations can be appended together.
*/
@Fluent
Buffer appendFloat(float f);
/**
* Appends the specified {@code double} to the end of the Buffer. The buffer will expand as necessary to accommodate any bytes written.<p>
* Returns a reference to {@code this} so multiple operations can be appended together.
*/
@Fluent
Buffer appendDouble(double d);
/**
* Appends the specified {@code String} to the end of the Buffer with the encoding as specified by {@code enc}.<p>
* The buffer will expand as necessary to accommodate any bytes written.<p>
* Returns a reference to {@code this} so multiple operations can be appended together.<p>
*/
@Fluent
Buffer appendString(String str, String enc);
/**
* Appends the specified {@code String str} to the end of the Buffer with UTF-8 encoding.<p>
* The buffer will expand as necessary to accommodate any bytes written.<p>
* Returns a reference to {@code this} so multiple operations can be appended together<p>
*/
@Fluent
Buffer appendString(String str);
/**
* Sets the {@code byte} at position {@code pos} in the Buffer to the value {@code b}.<p>
* The buffer will expand as necessary to accommodate any value written.
*/
@Fluent
Buffer setByte(int pos, byte b);
/**
* Sets the unsigned {@code byte} at position {@code pos} in the Buffer to the value {@code b}.<p>
* The buffer will expand as necessary to accommodate any value written.
*/
@Fluent
Buffer setUnsignedByte(int pos, short b);
/**
* Sets the {@code int} at position {@code pos} in the Buffer to the value {@code i}.<p>
* The buffer will expand as necessary to accommodate any value written.
*/
@Fluent
Buffer setInt(int pos, int i);
/**
* Sets the {@code int} at position {@code pos} in the Buffer to the value {@code i} in the Little Endian Byte Order.<p>
* The buffer will expand as necessary to accommodate any value written.
*/
@Fluent
Buffer setIntLE(int pos, int i);
/**
* Sets the unsigned {@code int} at position {@code pos} in the Buffer to the value {@code i}.<p>
* The buffer will expand as necessary to accommodate any value written.
*/
@Fluent
Buffer setUnsignedInt(int pos, long i);
/**
* Sets the unsigned {@code int} at position {@code pos} in the Buffer to the value {@code i} in the Little Endian Byte Order.<p>
* The buffer will expand as necessary to accommodate any value written.
*/
@Fluent
Buffer setUnsignedIntLE(int pos, long i);
/**
* Sets the 24bit {@code int} at position {@code pos} in the Buffer to the value {@code i}.<p>
* The buffer will expand as necessary to accommodate any value written.
*/
@Fluent
Buffer setMedium(int pos, int i);
/**
* Sets the 24bit {@code int} at position {@code pos} in the Buffer to the value {@code i}. in the Little Endian Byte Order<p>
* The buffer will expand as necessary to accommodate any value written.
*/
@Fluent
Buffer setMediumLE(int pos, int i);
/**
* Sets the {@code long} at position {@code pos} in the Buffer to the value {@code l}.<p>
* The buffer will expand as necessary to accommodate any value written.
*/
@Fluent
Buffer setLong(int pos, long l);
/**
* Sets the {@code long} at position {@code pos} in the Buffer to the value {@code l} in the Little Endian Byte Order.<p>
* The buffer will expand as necessary to accommodate any value written.
*/
@Fluent
Buffer setLongLE(int pos, long l);
/**
* Sets the {@code double} at position {@code pos} in the Buffer to the value {@code d}.<p>
* The buffer will expand as necessary to accommodate any value written.
*/
@Fluent
Buffer setDouble(int pos, double d);
/**
* Sets the {@code float} at position {@code pos} in the Buffer to the value {@code f}.<p>
* The buffer will expand as necessary to accommodate any value written.
*/
@Fluent
Buffer setFloat(int pos, float f);
/**
* Sets the {@code short} at position {@code pos} in the Buffer to the value {@code s}.<p>
* The buffer will expand as necessary to accommodate any value written.
*/
@Fluent
Buffer setShort(int pos, short s);
/**
* Sets the {@code short} at position {@code pos} in the Buffer to the value {@code s} in the Little Endian Byte Order.<p>
* The buffer will expand as necessary to accommodate any value written.
*/
@Fluent
Buffer setShortLE(int pos, short s);
/**
* Sets the unsigned {@code short} at position {@code pos} in the Buffer to the value {@code s}.<p>
* The buffer will expand as necessary to accommodate any value written.
*/
@Fluent
Buffer setUnsignedShort(int pos, int s);
/**
* Sets the unsigned {@code short} at position {@code pos} in the Buffer to the value {@code s} in the Little Endian Byte Order.<p>
* The buffer will expand as necessary to accommodate any value written.
*/
@Fluent
Buffer setUnsignedShortLE(int pos, int s);
/**
* Sets the bytes at position {@code pos} in the Buffer to the bytes represented by the {@code Buffer b}.<p>
* The buffer will expand as necessary to accommodate any value written.
*/
@Fluent
Buffer setBuffer(int pos, Buffer b);
/**
* Sets the bytes at position {@code pos} in the Buffer to the bytes represented by the {@code Buffer b} on the given {@code offset} and {@code len}.<p>
* The buffer will expand as necessary to accommodate any value written.
*/
@Fluent
Buffer setBuffer(int pos, Buffer b, int offset, int len);
/**
* Sets the bytes at position {@code pos} in the Buffer to the bytes represented by the {@code ByteBuffer b}.<p>
* The buffer will expand as necessary to accommodate any value written.
*/
@GenIgnore
@Fluent
Buffer setBytes(int pos, ByteBuffer b);
/**
* Sets the bytes at position {@code pos} in the Buffer to the bytes represented by the {@code byte[] b}.<p>
* The buffer will expand as necessary to accommodate any value written.
*/
@GenIgnore
@Fluent
Buffer setBytes(int pos, byte[] b);
/**
* Sets the given number of bytes at position {@code pos} in the Buffer to the bytes represented by the {@code byte[] b}.<p></p>
* The buffer will expand as necessary to accommodate any value written.
*/
@GenIgnore
@Fluent
Buffer setBytes(int pos, byte[] b, int offset, int len);
/**
* Sets the bytes at position {@code pos} in the Buffer to the value of {@code str} encoded in UTF-8.<p>
* The buffer will expand as necessary to accommodate any value written.
*/
@Fluent
Buffer setString(int pos, String str);
/**
* Sets the bytes at position {@code pos} in the Buffer to the value of {@code str} encoded in encoding {@code enc}.<p>
* The buffer will expand as necessary to accommodate any value written.
*/
@Fluent
Buffer setString(int pos, String str, String enc);
/**
* Returns the length of the buffer, measured in bytes.
* All positions are indexed from zero.
*/
int length();
/**
* Returns a copy of the entire Buffer.
*/
Buffer copy();
/**
* Returns a slice of this buffer. Modifying the content
* of the returned buffer or this buffer affects each other's content
* while they maintain separate indexes and marks.
*/
Buffer slice();
/**
* Returns a slice of this buffer. Modifying the content
* of the returned buffer or this buffer affects each other's content
* while they maintain separate indexes and marks.
*/
Buffer slice(int start, int end);
/**
* Returns the Buffer as a Netty {@code ByteBuf}.<p>
* The returned buffer is a duplicate.<p>
* This method is meant for internal use only.
*/
@GenIgnore
ByteBuf getByteBuf();
BufferFactory factory = ServiceHelper.loadFactory(BufferFactory.class);
}