/** * Get a {@link EntityJid} representing the given String. * * @param jid the JID. * @return an entity JID representing the given input.. * @throws XmppStringprepException if an error occurs. */ public static EntityJid entityFromUnescaped(CharSequence jid) throws XmppStringprepException { return entityFromUnescaped(jid.toString()); }
/** * Get a {@link EntityJid} from a given {@link CharSequence} or {@code null} if the input does not represent a JID. * * @param cs the input {@link CharSequence} * @return a JID or {@code null} */ public static EntityJid entityFromUnesacpedOrNull(CharSequence cs) { try { return entityFromUnescaped(cs.toString()); } catch (XmppStringprepException e) { return null; } }
/** * Like {@link #entityFromUnescaped(CharSequence)} but does throw an unchecked {@link IllegalArgumentException} instead of a * {@link XmppStringprepException}. * * @param cs the character sequence which should be transformed to a {@link EntityJid} * @return the {@link EntityJid} if no exception occurs * @throws IllegalArgumentException if the given input is not a valid JID * @see #entityFromUnescaped(CharSequence) * @since 0.6.2 */ public static EntityJid entityFromUnescapedOrThrowUnchecked(CharSequence cs) { try { return entityFromUnescaped(cs); } catch (XmppStringprepException e) { throw new IllegalArgumentException(e); } }