Java Code Examples for org.jxmpp.util.XmppStringUtils

The following examples show how to use org.jxmpp.util.XmppStringUtils. These examples are extracted from open source projects. 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 Project: jmeter-bzm-plugins   Source File: SendMessage.java    License: Apache License 2.0 6 votes vote down vote up
private SampleResult waitResponse(SampleResult res, String recipient) throws InterruptedException, SmackException {
    long time = 0;
    do {
        Iterator<Message> packets = responseMessages.iterator();
        Thread.sleep(conn.getPacketReplyTimeout() / 100); // optimistic
        while (packets.hasNext()) {
            Packet packet = packets.next();
            Message response = (Message) packet;
            if (XmppStringUtils.parseBareAddress(response.getFrom()).equals(recipient)) {
                packets.remove();
                res.setResponseData(response.toXML().toString().getBytes());
                if (response.getError() != null) {
                    res.setSuccessful(false);
                    res.setResponseCode("500");
                    res.setResponseMessage(response.getError().toString());
                }
                return res;
            }
        }
        time += conn.getPacketReplyTimeout() / 10;
        Thread.sleep(conn.getPacketReplyTimeout() / 10);
    } while (time < conn.getPacketReplyTimeout());
    throw new SmackException.NoResponseException();
}
 
Example 2
Source Project: jxmpp   Source File: JidUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Check if the given CharSequence is a valid entity bare JID. That
 * is, it must consists exactly of a local- and a domainpart
 * (&lt;[email protected]&gt;).
 * <p>
 * This is a convenience method meant to validate user entered bare JIDs. If
 * the given {@code jid} is not a valid bare JID, then this method will
 * throw either {@link NotAEntityBareJidStringException} or
 * {@link XmppStringprepException}. The NotABareJidStringException will
 * contain a meaningful message explaining why the given CharSequence is not a
 * valid bare JID (e.g. "does not contain a '@' character").
 * </p>
 * 
 * @param jidcs the JID CharSequence
 * @return a BareJid instance representing the given JID CharSequence
 * @throws NotAEntityBareJidStringException if the given CharSequence is not a bare JID.
 * @throws XmppStringprepException if an error happens.
 */
public static EntityBareJid validateEntityBareJid(CharSequence jidcs) throws NotAEntityBareJidStringException, XmppStringprepException {
	String jid = jidcs.toString();
	final int atIndex = jid.indexOf('@');
	if (atIndex == -1) {
		throw new NotAEntityBareJidStringException("'" + jid + "' does not contain a '@' character");
	} else if (jid.indexOf('@', atIndex + 1) != -1) {
		throw new NotAEntityBareJidStringException("'" + jid + "' contains multiple '@' characters");
	}
	final String localpart = XmppStringUtils.parseLocalpart(jid);
	if (localpart.length() == 0) {
		throw new NotAEntityBareJidStringException("'" + jid + "' has empty localpart");
	}
	final String domainpart = XmppStringUtils.parseDomain(jid);
	if (domainpart.length() == 0) {
		throw new NotAEntityBareJidStringException("'" + jid + "' has empty domainpart");
	}
	return JidCreate.entityBareFromUnescaped(jid);
}
 
Example 3
Source Project: jxmpp   Source File: JidCreate.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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 4
Source Project: jxmpp   Source File: JidCreate.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Get a {@link EntityBareJid} representing the given String.
 *
 * @param jid the input String.
 * @param context the JXMPP context.
 * @return a bare JID representing the given String.
 * @throws XmppStringprepException if an error occurs.
 */
public static EntityBareJid entityBareFrom(String jid, JxmppContext context) throws XmppStringprepException {
	EntityBareJid bareJid;
	if (context.isCachingEnabled()) {
		bareJid = ENTITY_BAREJID_CACHE.lookup(jid);
		if (bareJid != null) {
			return bareJid;
		}
	}

	String localpart = XmppStringUtils.parseLocalpart(jid);
	String domainpart = XmppStringUtils.parseDomain(jid);
	try {
		bareJid = new LocalAndDomainpartJid(localpart, domainpart, context);
	} catch (XmppStringprepException e) {
		throw new XmppStringprepException(jid, e);
	}

	if (context.isCachingEnabled()) {
		ENTITY_BAREJID_CACHE.put(jid, bareJid);
	}
	return bareJid;
}
 
Example 5
Source Project: jxmpp   Source File: JidCreate.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Get a {@link EntityBareJid} representing the given unescaped String.
 *
 * @param unescapedJidString the input String.
 * @param context the JXMPP context.
 * @return a bare JID representing the given String.
 * @throws XmppStringprepException if an error occurs.
 */
public static EntityBareJid entityBareFromUnescaped(String unescapedJidString, JxmppContext context) throws XmppStringprepException {
	EntityBareJid bareJid;
	if (context.isCachingEnabled()) {
		bareJid = ENTITY_BAREJID_CACHE.lookup(unescapedJidString);
		if (bareJid != null) {
			return bareJid;
		}
	}

	String localpart = XmppStringUtils.parseLocalpart(unescapedJidString);
	// Some as from(String), but we escape the localpart
	localpart = XmppStringUtils.escapeLocalpart(localpart);

	String domainpart = XmppStringUtils.parseDomain(unescapedJidString);
	try {
		bareJid = new LocalAndDomainpartJid(localpart, domainpart, context);
	} catch (XmppStringprepException e) {
		throw new XmppStringprepException(unescapedJidString, e);
	}

	if (context.isCachingEnabled()) {
		ENTITY_BAREJID_CACHE.put(unescapedJidString, bareJid);
	}
	return bareJid;
}
 
Example 6
Source Project: jxmpp   Source File: JidCreate.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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 7
Source Project: jxmpp   Source File: JidCreate.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Get a domain bare JID.
 *
 * @param jid the JID String.
 * @param context the JXMPP context.
 * @return a domain bare JID.
 * @throws XmppStringprepException if an error occurs.
 */
public static DomainBareJid domainBareFrom(String jid, JxmppContext context) throws XmppStringprepException {
	DomainBareJid domainJid;
	if (context.isCachingEnabled()) {
		domainJid = DOMAINJID_CACHE.lookup(jid);
		if (domainJid != null) {
			return domainJid;
		}
	}

	String domain = XmppStringUtils.parseDomain(jid);
	try {
		domainJid = new DomainpartJid(domain, context);
	} catch (XmppStringprepException e) {
		throw new XmppStringprepException(jid, e);
	}

	if (context.isCachingEnabled()) {
		DOMAINJID_CACHE.put(jid, domainJid);
	}
	return domainJid;
}
 
Example 8
Source Project: jxmpp   Source File: JidCreate.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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 9
Source Project: Smack   Source File: AbstractXMPPConnection.java    License: Apache License 2.0 6 votes vote down vote up
protected void sendStreamOpen() throws NotConnectedException, InterruptedException {
    // If possible, provide the receiving entity of the stream open tag, i.e. the server, as much information as
    // possible. The 'to' attribute is *always* available. The 'from' attribute if set by the user and no external
    // mechanism is used to determine the local entity (user). And the 'id' attribute is available after the first
    // response from the server (see e.g. RFC 6120 § 9.1.1 Step 2.)
    CharSequence to = getXMPPServiceDomain();
    CharSequence from = null;
    CharSequence localpart = config.getUsername();
    if (localpart != null) {
        from = XmppStringUtils.completeJidFrom(localpart, to);
    }
    String id = getStreamId();

    StreamOpen streamOpen = new StreamOpen(to, from, id, config.getXmlLang(), StreamOpen.StreamContentNamespace.client);
    sendNonza(streamOpen);

    XmlEnvironment.Builder xmlEnvironmentBuilder = XmlEnvironment.builder();
    xmlEnvironmentBuilder.with(streamOpen);
    outgoingStreamXmlEnvironment = xmlEnvironmentBuilder.build();
}
 
Example 10
Source Project: Spark   Source File: UserManager.java    License: Apache License 2.0 6 votes vote down vote up
public String getNickname() {
    final VCardManager vCardManager = SparkManager.getVCardManager();
    VCard vcard = vCardManager.getVCard();
    if (vcard == null) {
        return SparkManager.getSessionManager().getUsername();
    }
    else {
        String nickname = vcard.getNickName();
        if (ModelUtil.hasLength(nickname)) {
            return nickname;
        }
        else {
            String firstName = vcard.getFirstName();
            if (ModelUtil.hasLength(firstName)) {
                return firstName;
            }
        }
    }

    // Default to node if nothing.
    String username = SparkManager.getSessionManager().getUsername();
    username = XmppStringUtils.unescapeLocalpart(username);

    return username;
}
 
Example 11
Source Project: Spark   Source File: RoarPopupHelper.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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 12
Source Project: Spark   Source File: IncomingCall.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Accepts a <code>JingleSessionRequest</code>.
 *
 * @param request the request.
 */
private void acceptSession(JingleSessionRequest request) {
    toasterManager.close();

    if (ringing != null) {
        ringing.stop();
    }

    // Start the call
    session.startIncoming();

    if (chatRoom == null) {
        chatRoom = SparkManager.getChatManager().getChatRoom( XmppStringUtils.parseBareJid(request.getFrom()) );
        SparkManager.getChatManager().getChatContainer().activateChatRoom(chatRoom);
        SparkManager.getChatManager().getChatContainer().getChatFrame().toFront();
        notifyRoom();
    }
}
 
Example 13
Source Project: Spark   Source File: SoftPhoneManager.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Calls an individual user by their VCard information.
 *
 * @param jid the users JID.
 */
public void callByJID(String jid) {
    if (getStatus() == SipRegisterStatus.Registered) {
        final VCard vcard = SparkManager.getVCardManager().getVCard(XmppStringUtils.parseBareJid(jid));

        if (vcard != null) {
            String number = vcard.getPhoneWork("VOICE");
            if (!ModelUtil.hasLength(number)) {
                number = vcard.getPhoneHome("VOICE");
            }

            if (ModelUtil.hasLength(number)) {
                getDefaultGuiManager().dial(number);
            }
        }
    }
}
 
Example 14
Source Project: desktopclient-java   Source File: JID.java    License: GNU General Public License v3.0 5 votes vote down vote up
private JID(String local, String domain, String resource) {
    mLocal = local;
    mDomain = domain;
    mResource = resource;

    mValid = !mLocal.isEmpty() && !mDomain.isEmpty()
            // NOTE: domain check could be stronger - compliant with RFC 6122, but
            // server does not accept most special characters
            // NOTE: resource not checked
            && JidUtil.isTypicalValidEntityBareJid(
                    XmppStringUtils.completeJidFrom(mLocal, mDomain));
}
 
Example 15
Source Project: jxmpp   Source File: JidCreate.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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 16
Source Project: jxmpp   Source File: JidCreate.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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 17
Source Project: jxmpp   Source File: JidCreate.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get a {@link BareJid} representing the given String.
 *
 * @param jid the input String.
 * @param context the JXMPP context.
 * @return a bare JID representing the given String.
 * @throws XmppStringprepException if an error occurs.
 */
public static BareJid bareFrom(String jid, JxmppContext context) throws XmppStringprepException {
	BareJid bareJid;
	if (context.isCachingEnabled()) {
		bareJid = BAREJID_CACHE.lookup(jid);
		if (bareJid != null) {
			return bareJid;
		}
	}

	String localpart = XmppStringUtils.parseLocalpart(jid);
	String domainpart = XmppStringUtils.parseDomain(jid);
	try {
		if (localpart.length() != 0) {
			bareJid = new LocalAndDomainpartJid(localpart, domainpart, context);
		} else {
			bareJid = new DomainpartJid(domainpart, context);
		}
	} catch (XmppStringprepException e) {
		throw new XmppStringprepException(jid, e);
	}

	if (context.isCachingEnabled()) {
		BAREJID_CACHE.put(jid, bareJid);
	}
	return bareJid;
}
 
Example 18
Source Project: jxmpp   Source File: JidCreate.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 19
Source Project: Smack   Source File: SASLExternalMechanism.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected byte[] getAuthenticationText() {
    if (authorizationId != null) {
      return toBytes(authorizationId.toString());
    }

    if (StringUtils.isNullOrEmpty(authenticationId)) {
        return null;
    }

    return toBytes(XmppStringUtils.completeJidFrom(authenticationId, serviceName));
}
 
Example 20
Source Project: Spark   Source File: UserManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Escapes a complete JID by examing the Node itself and escaping
 * when neccessary.
 *
 * @param jid the users JID
 * @return the escaped JID.
 */
public static String escapeJID(String jid) {
    if (jid == null) {
        return null;
    }

    final StringBuilder builder = new StringBuilder();
    String node = XmppStringUtils.parseLocalpart(jid);
    String restOfJID = jid.substring(node.length());
    builder.append(XmppStringUtils.escapeLocalpart(node));
    builder.append(restOfJID);
    return builder.toString();
}
 
Example 21
Source Project: Spark   Source File: UserManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Unescapes a complete JID by examing the node itself and unescaping when necessary.
 *
 * @param jid the users jid.
 * @return the unescaped JID.
 */
public static String unescapeJID(BareJid jid) {
    if (jid == null) {
        return null;
    }

    final StringBuilder builder = new StringBuilder();
    Localpart node = jid.getLocalpartOrNull();
    Domainpart restOfJID = jid.getDomain();
    if (node != null) {
        builder.append(XmppStringUtils.unescapeLocalpart(node.toString()));
    }
    builder.append(restOfJID);
    return builder.toString();
}
 
Example 22
Source Project: Spark   Source File: ContactItem.java    License: Apache License 2.0 5 votes vote down vote up
/**
* Updates the displayed name for the contact. This method tries to use an
* alias first. If that's not set, the nickname will be used instead. If
* that's not set either, the JID of the user will be used.
*/
  protected void setDisplayName() {
  	final String displayName = getDisplayName();

      int nickLength = displayName.length();

      LayoutSettings settings = LayoutSettingsManager.getLayoutSettings();
      int windowWidth = settings.getMainWindowBounds() != null ? settings.getMainWindowBounds().width : 50;

      if (nickLength > windowWidth) { // FIXME comparing pixel-width with character count - that can't be good.
          displayNameLabel.setText(XmppStringUtils.unescapeLocalpart(displayName).substring(0, windowWidth) + "...");
      } else {
          displayNameLabel.setText(XmppStringUtils.unescapeLocalpart(displayName));
      }
  }
 
Example 23
Source Project: Spark   Source File: GrowlTalker.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onClickCallback( GntpNotification notification )
{
    Log.debug( "Callback clicked: " + notification );
    final String jid = XmppStringUtils.parseBareJid( (String) notification.getContext() );
    final ChatRoom room = SparkManager.getChatManager().getChatRoom( jid );
    SparkManager.getChatManager().getChatContainer().activateChatRoom( room );
    SparkManager.getChatManager().getChatContainer().requestFocusInWindow();
}
 
Example 24
Source Project: Spark   Source File: FastpathPlugin.java    License: Apache License 2.0 5 votes vote down vote up
private void leaveWorkgroup() {
    workgroupLabel.setText(FpRes.getString("workgroup") + ":");
    logoutButton.setVisible(false);
    joinButton.setVisible(true);
    comboBox.setVisible(true);

    comboBox.removeAllItems();
    // Log into workgroup
    DomainBareJid workgroupService = JidCreate.domainBareFromOrThrowUnchecked("workgroup." + SparkManager.getSessionManager().getServerAddress());
    EntityFullJid jid = SparkManager.getSessionManager().getJID();

    try {
        Collection<String> col = Agent.getWorkgroups(workgroupService, jid, SparkManager.getConnection());
        // Add workgroups to combobox
        Iterator<String> workgroups = col.iterator();
        while (workgroups.hasNext()) {
            String workgroup = workgroups.next();
            String componentAddress = XmppStringUtils.parseDomain(workgroup);
            setComponentAddress(componentAddress);
            comboBox.addItem(XmppStringUtils.parseLocalpart(workgroup));
        }
    }
    catch (XMPPException | SmackException | InterruptedException ee) {
        // If the user does not belong to a workgroup, then don't initialize the rest of the plugin.
        return;
    }

    try {
        agentSession.setOnline(false);
    }
    catch (XMPPException | SmackException | InterruptedException e1) {
        Log.error(e1);
    }
    litWorkspace.unload();
    wgroup = null;

    // UnRegister tab handler
    SparkManager.getChatManager().removeSparkTabHandler(fastpathTabHandler);
}
 
Example 25
Source Project: desktopclient-java   Source File: JID.java    License: GNU General Public License v3.0 4 votes vote down vote up
/** Return unescaped local part. */
public String local() {
    return XmppStringUtils.unescapeLocalpart(mLocal);
}
 
Example 26
Source Project: desktopclient-java   Source File: JID.java    License: GNU General Public License v3.0 4 votes vote down vote up
/** Return JID as escaped string. */
public String string() {
    return XmppStringUtils.completeJidFrom(mLocal, mDomain, mResource);
}
 
Example 27
Source Project: desktopclient-java   Source File: JID.java    License: GNU General Public License v3.0 4 votes vote down vote up
public String asUnescapedString() {
    return XmppStringUtils.completeJidFrom(this.local(), mDomain, mResource);
}
 
Example 28
Source Project: desktopclient-java   Source File: JID.java    License: GNU General Public License v3.0 4 votes vote down vote up
public static JID full(String jid) {
    jid = StringUtils.defaultString(jid);
    return escape(XmppStringUtils.parseLocalpart(jid),
            XmppStringUtils.parseDomain(jid),
            XmppStringUtils.parseResource(jid));
}
 
Example 29
Source Project: desktopclient-java   Source File: JID.java    License: GNU General Public License v3.0 4 votes vote down vote up
public static JID bare(String jid) {
    jid = StringUtils.defaultString(jid);
    return escape(XmppStringUtils.parseLocalpart(jid), XmppStringUtils.parseDomain(jid), "");
}
 
Example 30
Source Project: desktopclient-java   Source File: JID.java    License: GNU General Public License v3.0 4 votes vote down vote up
private static JID escape(String local, String domain, String resource) {
    return new JID(XmppStringUtils.escapeLocalpart(local), domain, resource);
}