public static void addMention(Stanza stanza, int begin, int end, BareJid jid) {
        URI uri;
        try {
            uri = new URI("xmpp:" + jid.toString());
        } catch (URISyntaxException e) {
            throw new AssertionError("Cannot create URI from bareJid.");
        }
        ReferenceElement reference = new ReferenceElement(begin, end, ReferenceElement.Type.mention, null, uri);
        stanza.addExtension(reference);
    }
public static void addMention ( Stanza stanza , int begin , int end , BareJid jid ) { URI uri ; try { uri = new URI ( "xmpp:" + jid . toString ( ) ) ; } catch ( URISyntaxException e ) { throw new AssertionError ( "Cannot create URI from bareJid." ) ; } ReferenceElement reference = new ReferenceElement ( begin , end , ReferenceElement . Type . mention , null , uri ) ; stanza . addExtension ( reference ) ; }
Add a reference to another users bare jid to a stanza.

@param stanza stanza.
@param begin start index of the mention in the messages body.
@param end end index of the mention in the messages body.
@param jid referenced jid.