public static byte [ ] encodeSingleNullable ( byte [ ] value , int prefixPadding , int suffixPadding ) { if ( prefixPadding <= 0 && suffixPadding <= 0 ) { if ( value == null ) { return new byte [ ] { NULL_BYTE_HIGH } ; } int length = value . length ; if ( length == 0 ) { return new byte [ ] { NOT_NULL_BYTE_HIGH } ; } byte [ ] dst = new byte [ 1 + length ] ; dst [ 0 ] = NOT_NULL_BYTE_HIGH ; System . arraycopy ( value , 0 , dst , 1 , length ) ; return dst ; } if ( value == null ) { byte [ ] dst = new byte [ prefixPadding + 1 + suffixPadding ] ; dst [ prefixPadding ] = NULL_BYTE_HIGH ; return dst ; } int length = value . length ; byte [ ] dst = new byte [ prefixPadding + 1 + length + suffixPadding ] ; dst [ prefixPadding ] = NOT_NULL_BYTE_HIGH ; System . arraycopy ( value , 0 , dst , prefixPadding + 1 , length ) ; return dst ; }
Encodes the given byte array for use when there is only a single nullable property whose type is a byte array .