当前位置: 首页>>代码示例>>Java>>正文


Java XmppStringUtils类代码示例

本文整理汇总了Java中org.jxmpp.util.XmppStringUtils的典型用法代码示例。如果您正苦于以下问题:Java XmppStringUtils类的具体用法?Java XmppStringUtils怎么用?Java XmppStringUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


XmppStringUtils类属于org.jxmpp.util包,在下文中一共展示了XmppStringUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: waitResponse

import org.jxmpp.util.XmppStringUtils; //导入依赖的package包/类
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();
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:25,代码来源:SendMessage.java

示例2: onPostExecute

import org.jxmpp.util.XmppStringUtils; //导入依赖的package包/类
protected void onPostExecute(Boolean result) {
    CollectionViewActivity myActivity = CollectionViewActivity.this ;
    if ( result ) {
        Log.d(LOGTAG , "Now we have a working connection" );

        // TODO: Do this in a safe way
        // Anyway if the connection is configured it should be already a current entity
        if ( myActivity.currentEntity == null ) {
            myActivity.currentEntity = new Entity(XmppStringUtils.parseDomain(user), null, null);
        }

        myActivity.setTitle( myActivity.currentEntity.getDisplayName() );

        myActivity.childLoader = new LoadChildEntitiesTask() ;
        myActivity.childLoader.execute( myActivity );
    } else {
        Log.d(LOGTAG , "No connection" );
        //Call the settings activity
        Intent intent = new Intent( myActivity, SettingsActivity.class);
        startActivityForResult(intent , 1 );
        Log.d(LOGTAG , "Subactivity launched" );
    }
}
 
开发者ID:marevalo,项目名称:FlowsManager,代码行数:24,代码来源:CollectionViewActivity.java

示例3: openStream

import org.jxmpp.util.XmppStringUtils; //导入依赖的package包/类
/**
 * Resets the parser using the latest connection's reader. Reseting the parser is necessary
 * when the plain connection has been secured or when a new opening stream element is going
 * to be sent by the server.
 *
 * @throws SmackException if the parser could not be reset.
 */
void openStream() throws SmackException {
    // 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 = getServiceName();
    CharSequence from = null;
    CharSequence localpart = config.getUsername();
    if (localpart != null) {
        from = XmppStringUtils.completeJidFrom(localpart, to);
    }
    String id = getStreamId();
    // 发送一个SteamOpen
    send(new StreamOpen(to, from, id));
    try {
        packetReader.parser = PacketParserUtils.newXmppParser(reader);
    }
    catch (XmlPullParserException e) {
        throw new SmackException(e);
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:29,代码来源:XMPPTCPConnection.java

示例4: userHasLogged

import org.jxmpp.util.XmppStringUtils; //导入依赖的package包/类
public void userHasLogged(String user) {
    String localpart = XmppStringUtils.parseLocalpart(user);
    boolean isAnonymous = "".equals(localpart);
    String title =
            "User logged (" + connection.getConnectionCounter() + "): "
            + (isAnonymous ? "" : localpart)
            + "@"
            + connection.getServiceName()
            + ":"
            + connection.getPort();
    title += "/" + XmppStringUtils.parseResource(user);
    log(title);
    // Add the connection listener to the connection so that the debugger can be notified
    // whenever the connection is closed.
    connection.addConnectionListener(connListener);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:17,代码来源:AbstractDebugger.java

示例5: registerIQRequestHandler

import org.jxmpp.util.XmppStringUtils; //导入依赖的package包/类
@Override
public IQRequestHandler registerIQRequestHandler(final IQRequestHandler iqRequestHandler) {
    final String key = XmppStringUtils.generateKey(iqRequestHandler.getElement(), iqRequestHandler.getNamespace());
    switch (iqRequestHandler.getType()) {
    case set:
        synchronized (setIqRequestHandler) {
            return setIqRequestHandler.put(key, iqRequestHandler);
        }
    case get:
        synchronized (getIqRequestHandler) {
            return getIqRequestHandler.put(key, iqRequestHandler);
        }
    default:
        throw new IllegalArgumentException("Only IQ type of 'get' and 'set' allowed");
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:17,代码来源:AbstractXMPPConnection.java

示例6: unregisterIQRequestHandler

import org.jxmpp.util.XmppStringUtils; //导入依赖的package包/类
@Override
public IQRequestHandler unregisterIQRequestHandler(String element, String namespace, IQ.Type type) {
    final String key = XmppStringUtils.generateKey(element, namespace);
    switch (type) {
    case set:
        synchronized (setIqRequestHandler) {
            return setIqRequestHandler.remove(key);
        }
    case get:
        synchronized (getIqRequestHandler) {
            return getIqRequestHandler.remove(key);
        }
    default:
        throw new IllegalArgumentException("Only IQ type of 'get' and 'set' allowed");
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:17,代码来源:AbstractXMPPConnection.java

示例7: getExtension

import org.jxmpp.util.XmppStringUtils; //导入依赖的package包/类
/**
 * Returns the first extension that matches the specified element name and
 * namespace, or <tt>null</tt> if it doesn't exist. If the provided elementName is null,
 * only the namespace is matched. Extensions are
 * are arbitrary XML sub-documents in standard XMPP packets. By default, a 
 * {@link DefaultExtensionElement} instance will be returned for each extension. However, 
 * ExtensionElementProvider instances can be registered with the 
 * {@link org.jivesoftware.smack.provider.ProviderManager ProviderManager}
 * class to handle custom parsing. In that case, the type of the Object
 * will be determined by the provider.
 *
 * @param elementName the XML element name of the extension. (May be null)
 * @param namespace the XML element namespace of the extension.
 * @return the extension, or <tt>null</tt> if it doesn't exist.
 */
@SuppressWarnings("unchecked")
public <PE extends ExtensionElement> PE getExtension(String elementName, String namespace) {
    if (namespace == null) {
        return null;
    }
    String key = XmppStringUtils.generateKey(elementName, namespace);
    ExtensionElement packetExtension;
    synchronized (packetExtensions) {
        packetExtension = packetExtensions.getFirst(key);
    }
    if (packetExtension == null) {
        return null;
    }
    return (PE) packetExtension;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:31,代码来源:Stanza.java

示例8: getEntry

import org.jxmpp.util.XmppStringUtils; //导入依赖的package包/类
/**
 * Returns the roster entry associated with the given XMPP address or
 * <tt>null</tt> if the user is not an entry in the group.
 *
 * @param user the XMPP address of the user (eg "[email protected]").
 * @return the roster entry or <tt>null</tt> if it does not exist in the group.
 */
public RosterEntry getEntry(String user) {
    if (user == null) {
        return null;
    }
    // Roster entries never include a resource so remove the resource
    // if it's a part of the XMPP address.
    user = XmppStringUtils.parseBareJid(user);
    String userLowerCase = user.toLowerCase(Locale.US);
    synchronized (entries) {
        for (RosterEntry entry : entries) {
            if (entry.getUser().equals(userLowerCase)) {
                return entry;
            }
        }
    }
    return null;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:25,代码来源:RosterGroup.java

示例9: getUserChat

import org.jxmpp.util.XmppStringUtils; //导入依赖的package包/类
/**
 * Try to get a matching chat for the given user JID, based on the {@link MatchMode}.
 * <li>NONE - return null
 * <li>SUPPLIED_JID - match the jid in the from field of the message exactly.
 * <li>BARE_JID - if not match for from field, try the bare jid. 
 * 
 * @param userJID jid in the from field of message.
 * @return Matching chat, or null if no match found.
 */
private Chat getUserChat(String userJID) {
    if (matchMode == MatchMode.NONE) {
        return null;
    }
    // According to RFC6120 8.1.2.1 4. messages without a 'from' attribute are valid, but they
    // are of no use in this case for ChatManager
    if (userJID == null) {
        return null;
    }
    Chat match = jidChats.get(userJID);
	
    if (match == null && (matchMode == MatchMode.BARE_JID)) {
        match = baseJidChats.get(XmppStringUtils.parseBareJid(userJID));
    }
    return match;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:26,代码来源:ChatManager.java

示例10: createOutgoingFileTransfer

import org.jxmpp.util.XmppStringUtils; //导入依赖的package包/类
/**
 * Creates an OutgoingFileTransfer to send a file to another user.
 * 
 * @param userID
 *            The fully qualified jabber ID (i.e. full JID) with resource of the user to
 *            send the file to.
 * @return The send file object on which the negotiated transfer can be run.
 * @exception IllegalArgumentException if userID is null or not a full JID
 */
public OutgoingFileTransfer createOutgoingFileTransfer(String userID) {
       if (userID == null) {
           throw new IllegalArgumentException("userID was null");
       }
       // We need to create outgoing file transfers with a full JID since this method will later
       // use XEP-0095 to negotiate the stream. This is done with IQ stanzas that need to be addressed to a full JID
       // in order to reach an client entity.
       else if (!XmppStringUtils.isFullJID(userID)) {
           throw new IllegalArgumentException("The provided user id was not a full JID (i.e. with resource part)");
       }

	return new OutgoingFileTransfer(connection().getUser(), userID,
			fileTransferNegotiator.getNextStreamID(),
			fileTransferNegotiator);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:25,代码来源:FileTransferManager.java

示例11: createRxMessage

import org.jxmpp.util.XmppStringUtils; //导入依赖的package包/类
public static XmppRxMessage createRxMessage(org.jivesoftware.smack.packet.Message xmppMessage){
    MessageContent content = new DefaultMessageContent(xmppMessage.getBody());
    Resource resource;

    if(xmppMessage.getType().equals(org.jivesoftware.smack.packet.Message.Type.groupchat)){
        resource =
                new DefaultResource(
                        XmppStringUtils.parseBareJid(xmppMessage.getFrom()),
                        XmppStringUtils.parseResource(xmppMessage.getFrom()),
                        Resource.Type.ROOM
                );
    }else{
        resource = new DefaultResource(xmppMessage.getFrom(),xmppMessage.getFrom(), Resource.Type.USER);
    }

    XmppRxMessage msg = new XmppRxMessage(resource,content);
    msg.setId(xmppMessage.getStanzaId());
    msg.setThread(xmppMessage.getThread());
    return msg;
}
 
开发者ID:midoricorp,项目名称:jabbot,代码行数:21,代码来源:MessageHelper.java

示例12: handleRosterMatch

import org.jxmpp.util.XmppStringUtils; //导入依赖的package包/类
@CommandHandler(name = ACTION_ROSTER_MATCH)
private boolean handleRosterMatch(Intent intent, boolean canConnect) {
    if (canConnect && isConnected()) {
        RosterMatch iq = new RosterMatch();
        String[] list = intent.getStringArrayExtra(EXTRA_JIDLIST);

        for (String item : list) {
            iq.addItem(item);
        }

        // directed to the probe component
        iq.setTo(XmppStringUtils.completeJidFrom("probe", mServer.getNetwork()));

        String id = intent.getStringExtra(EXTRA_PACKET_ID);
        iq.setStanzaId(id);
        // iq default type is get

        RosterMatchListener listener = new RosterMatchListener(this, iq);
        sendIqWithReply(iq, true, listener, listener);
    }
    return false;
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:23,代码来源:MessageCenterService.java

示例13: openStream

import org.jxmpp.util.XmppStringUtils; //导入依赖的package包/类
/**
 * Resets the parser using the latest connection's reader. Reseting the parser is necessary
 * when the plain connection has been secured or when a new opening stream element is going
 * to be sent by the server.
 *
 * @throws SmackException if the parser could not be reset.
 * @throws InterruptedException
 */
void openStream() throws SmackException, 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();
    sendNonza(new StreamOpen(to, from, id));
    try {
        packetReader.parser = PacketParserUtils.newXmppParser(reader);
    }
    catch (XmlPullParserException e) {
        throw new SmackException(e);
    }
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:29,代码来源:XMPPTCPConnection.java

示例14: validateEntityBareJid

import org.jxmpp.util.XmppStringUtils; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:igniterealtime,项目名称:jxmpp,代码行数:37,代码来源:JidUtil.java

示例15: from

import org.jxmpp.util.XmppStringUtils; //导入依赖的package包/类
/**
 * Get a {@link Jid} from the given parts.
 * <p>
 * Only the domainpart is required.
 * </p>
 *
 * @param localpart a optional localpart.
 * @param domainpart a required domainpart.
 * @param resource a optional resourcepart.
 * @return a JID which consists of the given parts.
 * @throws XmppStringprepException if an error occurs.
 */
public static Jid from(String localpart, String domainpart, String resource) throws XmppStringprepException {
	String jidString = XmppStringUtils.completeJidFrom(localpart, domainpart, resource);
	Jid jid = JID_CACHE.lookup(jidString);
	if (jid != null) {
		return jid;
	}
	if (localpart.length() > 0 && domainpart.length() > 0 && resource.length() > 0) {
		jid = new LocalDomainAndResourcepartJid(localpart, domainpart, resource);
	} else if (localpart.length() > 0 && domainpart.length() > 0 && resource.length() == 0) {
		jid = new LocalAndDomainpartJid(localpart, domainpart);
	} else if (localpart.length() == 0 && domainpart.length() > 0 && resource.length() == 0) {
		jid = new DomainpartJid(domainpart);
	} else if (localpart.length() == 0 && domainpart.length() > 0 && resource.length() > 0) {
		jid = new DomainAndResourcepartJid(domainpart, resource);
	} else {
		throw new IllegalArgumentException("Not a valid combination of localpart, domainpart and resource");
	}
	JID_CACHE.put(jidString, jid);
	return jid;
}
 
开发者ID:igniterealtime,项目名称:jxmpp,代码行数:33,代码来源:JidCreate.java


注:本文中的org.jxmpp.util.XmppStringUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。