Java Code Examples for org.jxmpp.util.XmppStringUtils#parseResource()
The following examples show how to use
org.jxmpp.util.XmppStringUtils#parseResource() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JidCreate.java From jxmpp with Apache License 2.0 | 6 votes |
/** * Get a {@link FullJid} representing the given String. * * @param jid the JID's String. * @return a full JID representing the input String. * @throws XmppStringprepException if an error occurs. */ public static FullJid fullFrom(String jid) throws XmppStringprepException { FullJid fullJid = FULLJID_CACHE.lookup(jid); if (fullJid != null) { return fullJid; } String localpart = XmppStringUtils.parseLocalpart(jid); String domainpart = XmppStringUtils.parseDomain(jid); String resource = XmppStringUtils.parseResource(jid); try { fullJid = fullFrom(localpart, domainpart, resource); } catch (XmppStringprepException e) { throw new XmppStringprepException(jid, e); } FULLJID_CACHE.put(jid, fullJid); return fullJid; }
Example 2
Source File: JidCreate.java From jxmpp with Apache License 2.0 | 6 votes |
/** * Get a {@link EntityFullJid} representing the given String. * * @param jid the JID's String. * @return a full JID representing the input String. * @throws XmppStringprepException if an error occurs. */ public static EntityFullJid entityFullFrom(String jid) throws XmppStringprepException { EntityFullJid fullJid = ENTITY_FULLJID_CACHE.lookup(jid); if (fullJid != null) { return fullJid; } String localpart = XmppStringUtils.parseLocalpart(jid); String domainpart = XmppStringUtils.parseDomain(jid); String resource = XmppStringUtils.parseResource(jid); try { fullJid = entityFullFrom(localpart, domainpart, resource); } catch (XmppStringprepException e) { throw new XmppStringprepException(jid, e); } ENTITY_FULLJID_CACHE.put(jid, fullJid); return fullJid; }
Example 3
Source File: JidCreate.java From jxmpp with Apache License 2.0 | 6 votes |
/** * Get a domain full JID from the given String. * * @param jid the JID. * @param context the JXMPP context. * @return a DomainFullJid. * @throws XmppStringprepException if an error happens. */ public static DomainFullJid domainFullFrom(String jid, JxmppContext context) throws XmppStringprepException { DomainFullJid domainResourceJid; if (context.isCachingEnabled()) { domainResourceJid = DOMAINRESOURCEJID_CACHE.lookup(jid); if (domainResourceJid != null) { return domainResourceJid; } } String domain = XmppStringUtils.parseDomain(jid); String resource = XmppStringUtils.parseResource(jid); try { domainResourceJid = new DomainAndResourcepartJid(domain, resource, context); } catch (XmppStringprepException e) { throw new XmppStringprepException(jid, e); } if (context.isCachingEnabled()) { DOMAINRESOURCEJID_CACHE.put(jid, domainResourceJid); } return domainResourceJid; }
Example 4
Source File: RoarPopupHelper.java From Spark with Apache License 2.0 | 6 votes |
/** * Returns the Nickname of the person sending the message * * @param room * the ChatRoom the message was sent in * @param message * the actual message * @return nickname */ public static String getNickname(ChatRoom room, Message message) { String nickname = SparkManager.getUserManager().getUserNicknameFromJID(message.getFrom()); if (room.getChatType() == Message.Type.groupchat) { nickname = XmppStringUtils.parseResource(nickname); } final JivePropertiesExtension extension = ((JivePropertiesExtension) message.getExtension( JivePropertiesExtension.NAMESPACE )); final boolean broadcast = extension != null && extension.getProperty( "broadcast" ) != null; if ((broadcast || message.getType() == Message.Type.normal || message.getType() == Message.Type.headline) && message.getBody() != null) { nickname = Res.getString("broadcast") + " - " + nickname; } return nickname; }
Example 5
Source File: JidCreate.java From jxmpp with Apache License 2.0 | 5 votes |
/** * Get a {@link Jid} from the given String. * * @param jidString the input String. * @param context the JXMPP context. * @return the Jid represented by the input String. * @throws XmppStringprepException if an error occurs. * @see #from(CharSequence) */ public static Jid from(String jidString, JxmppContext context) throws XmppStringprepException { String localpart = XmppStringUtils.parseLocalpart(jidString); String domainpart = XmppStringUtils.parseDomain(jidString); String resource = XmppStringUtils.parseResource(jidString); try { return from(localpart, domainpart, resource, context); } catch (XmppStringprepException e) { throw new XmppStringprepException(jidString, e); } }
Example 6
Source File: JidCreate.java From jxmpp with Apache License 2.0 | 5 votes |
/** * Get a {@link Jid} from the given unescaped String. * * @param unescapedJidString a unescaped String representing a JID. * @return a JID. * @throws XmppStringprepException if an error occurs. */ public static Jid fromUnescaped(String unescapedJidString) throws XmppStringprepException { String localpart = XmppStringUtils.parseLocalpart(unescapedJidString); // Some as from(String), but we escape the localpart localpart = XmppStringUtils.escapeLocalpart(localpart); String domainpart = XmppStringUtils.parseDomain(unescapedJidString); String resource = XmppStringUtils.parseResource(unescapedJidString); try { return from(localpart, domainpart, resource); } catch (XmppStringprepException e) { throw new XmppStringprepException(unescapedJidString, e); } }
Example 7
Source File: JidCreate.java From jxmpp with Apache License 2.0 | 5 votes |
/** * Get a {@link EntityFullJid} representing the given unescaped String. * * @param unescapedJidString the JID's String. * @param context the JXMPP context. * @return a full JID representing the input String. * @throws XmppStringprepException if an error occurs. */ public static EntityFullJid entityFullFromUnescaped(String unescapedJidString, JxmppContext context) throws XmppStringprepException { EntityFullJid fullJid; if (context.isCachingEnabled()) { fullJid = ENTITY_FULLJID_CACHE.lookup(unescapedJidString); if (fullJid != null) { return fullJid; } } String localpart = XmppStringUtils.parseLocalpart(unescapedJidString); // Some as from(String), but we escape the localpart localpart = XmppStringUtils.escapeLocalpart(localpart); String domainpart = XmppStringUtils.parseDomain(unescapedJidString); String resource = XmppStringUtils.parseResource(unescapedJidString); try { fullJid = new LocalDomainAndResourcepartJid(localpart, domainpart, resource, context); } catch (XmppStringprepException e) { throw new XmppStringprepException(unescapedJidString, e); } if (context.isCachingEnabled()) { ENTITY_FULLJID_CACHE.put(unescapedJidString, fullJid); } return fullJid; }