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