@@ -409,65 +409,41 @@ public MessagePacker packMapHeader(int mapSize) throws IOException {
409409 return this ;
410410 }
411411
412- public MessagePacker pack (Value v ) throws IOException {
412+ public MessagePacker packValue (Value v ) throws IOException {
413413 v .writeTo (this );
414414 return this ;
415415 }
416416
417- public MessagePacker packExtendedType (int extType , byte [] src , int offset , int len ) throws IOException {
418- return packExtendedTypeHeader (extType , len ).writePayload (src , offset , len );
419- }
420-
421- public MessagePacker packExtendedType (int extType , byte [] src ) throws IOException {
422- return packExtendedType (extType , src , 0 , src .length );
423- }
424-
425- public MessagePacker packExtendedType (int extType , ByteBuffer src ) throws IOException {
426- return packExtendedTypeHeader (extType , src .remaining ()).writePayload (src );
427- }
428-
429- public MessagePacker packExtendedTypeHeader (int extType , int dataLen ) throws IOException {
430- if (dataLen < (1 << 8 )) {
431- if (dataLen > 0 && (dataLen & (dataLen - 1 )) == 0 ) { // check whether dataLen == 2^x
432- if (dataLen == 1 ) {
417+ public MessagePacker packExtendedTypeHeader (int extType , int payloadLen ) throws IOException {
418+ if (payloadLen < (1 << 8 )) {
419+ if (payloadLen > 0 && (payloadLen & (payloadLen - 1 )) == 0 ) { // check whether dataLen == 2^x
420+ if (payloadLen == 1 ) {
433421 writeByteAndByte (FIXEXT1 , (byte ) extType );
434- } else if (dataLen == 2 ){
422+ } else if (payloadLen == 2 ){
435423 writeByteAndByte (FIXEXT2 , (byte ) extType );
436- } else if (dataLen == 4 ) {
424+ } else if (payloadLen == 4 ) {
437425 writeByteAndByte (FIXEXT4 , (byte ) extType );
438- } else if (dataLen == 8 ) {
426+ } else if (payloadLen == 8 ) {
439427 writeByteAndByte (FIXEXT8 , (byte ) extType );
440428 } else {
441429 writeByteAndByte (FIXEXT16 , (byte ) extType );
442430 }
443431 } else {
444- writeByteAndByte (EXT8 , (byte ) dataLen );
432+ writeByteAndByte (EXT8 , (byte ) payloadLen );
445433 writeByte ((byte ) extType );
446434 }
447- } else if (dataLen < (1 << 16 )) {
448- writeByteAndShort (EXT16 , (short ) dataLen );
435+ } else if (payloadLen < (1 << 16 )) {
436+ writeByteAndShort (EXT16 , (short ) payloadLen );
449437 writeByte ((byte ) extType );
450438 } else {
451- writeByteAndInt (EXT32 , dataLen );
439+ writeByteAndInt (EXT32 , payloadLen );
452440 writeByte ((byte ) extType );
453441
454442 // TODO support dataLen > 2^31 - 1
455443 }
456444 return this ;
457445 }
458446
459- public MessagePacker packBinary (byte [] src ) throws IOException {
460- return packBinary (src , 0 , src .length );
461- }
462-
463- public MessagePacker packBinary (byte [] src , int offset , int len ) throws IOException {
464- return packBinaryHeader (len ).writePayload (src , offset , len );
465- }
466-
467- public MessagePacker packBinary (ByteBuffer src ) throws IOException {
468- return packBinaryHeader (src .remaining ()).writePayload (src );
469- }
470-
471447 public MessagePacker packBinaryHeader (int len ) throws IOException {
472448 if (len < (1 << 8 )) {
473449 writeByteAndByte (BIN8 , (byte ) len );
@@ -479,10 +455,6 @@ public MessagePacker packBinaryHeader(int len) throws IOException {
479455 return this ;
480456 }
481457
482- public MessagePacker packRawString (ByteBuffer src ) throws IOException {
483- return packRawStringHeader (src .remaining ()).writePayload (src );
484- }
485-
486458 public MessagePacker packRawStringHeader (int len ) throws IOException {
487459 if (len < (1 << 5 )) {
488460 writeByte ((byte ) (FIXSTR_PREFIX | len ));
0 commit comments