*/
public static void encode( ByteBuffer buffer, BitString bitString ) throws EncoderException
{
if ( buffer == null )
{
throw new EncoderException( I18n.err( I18n.ERR_00003_CANNOT_PUT_PDU_IN_NULL_BUFFER ) );
}
try
{
buffer.put( UniversalTag.BIT_STRING.getValue() );
// The BitString length. We add one byte for the unused number
// of bits
byte[] bytes = bitString.getData();
int length = bytes.length;
buffer.put( TLV.getBytes( length ) );
buffer.put( bytes );
}
catch ( BufferOverflowException boe )
{
throw new EncoderException( I18n.err( I18n.ERR_00004_PDU_BUFFER_SIZE_TOO_SMALL ) );
}
}