public static int encode ( Byte value , byte [ ] dst , int dstOffset ) { if ( value == null ) { dst [ dstOffset ] = NULL_BYTE_HIGH ; return 1 ; } else { dst [ dstOffset ] = NOT_NULL_BYTE_HIGH ; dst [ dstOffset + 1 ] = ( byte ) ( value ^ 0x80 ) ; return 2 ; } }
Encodes the given signed Byte object into exactly 1 or 2 bytes . If the Byte object is never expected to be null consider encoding as a byte primitive .