當前位置: 首頁>>代碼示例>>Java>>正文


Java StringUtils.escapeForXML方法代碼示例

本文整理匯總了Java中org.jivesoftware.smack.util.StringUtils.escapeForXML方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.escapeForXML方法的具體用法?Java StringUtils.escapeForXML怎麽用?Java StringUtils.escapeForXML使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jivesoftware.smack.util.StringUtils的用法示例。


在下文中一共展示了StringUtils.escapeForXML方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setNote

import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
/**
 * Creates a ChatNote that will be mapped to the given chat session.
 *
 * @param sessionID the session id of a Chat Session.
 * @param note      the chat note to add.
 * @throws XMPPException is thrown if an error occurs while adding the note.
 */
public void setNote(String sessionID, String note) throws XMPPException {
    note = ChatNotes.replace(note, "\n", "\\n");
    note = StringUtils.escapeForXML(note);

    ChatNotes notes = new ChatNotes();
    notes.setType(IQ.Type.SET);
    notes.setTo(workgroupJID);
    notes.setSessionID(sessionID);
    notes.setNotes(note);
    PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(notes.getPacketID()));
    // Send the request
    connection.sendPacket(notes);

    IQ response = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

    // Cancel the collector.
    collector.cancel();
    if (response == null) {
        throw new XMPPException("No response from server on status set.");
    }
    if (response.getError() != null) {
        throw new XMPPException(response.getError());
    }
}
 
開發者ID:ice-coffee,項目名稱:EIM,代碼行數:32,代碼來源:AgentSession.java

示例2: joinQueue

import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
/**
 * <p>Joins the workgroup queue to wait to be routed to an agent. After joining
 * the queue, queue status events will be sent to indicate the user's position and
 * estimated time left in the queue. Once joining the queue, there are three ways
 * the user can leave the queue: <ul>
 * <p/>
 * <li>The user is routed to an agent, which triggers a GroupChat invitation.
 * <li>The user asks to leave the queue by calling the {@link #departQueue} method.
 * <li>A server error occurs, or an administrator explicitly removes the user
 * from the queue.
 * </ul>
 * <p/>
 * A user cannot request to join the queue again if already in the queue. Therefore,
 * this method will throw an IllegalStateException if the user is already in the queue.<p>
 * <p/>
 * Some servers may be configured to require certain meta-data in order to
 * join the queue.<p>
 * <p/>
 * The server tracks the conversations that a user has with agents over time. By
 * default, that tracking is done using the user's JID. However, this is not always
 * possible. For example, when the user is logged in anonymously using a web client.
 * In that case the user ID might be a randomly generated value put into a persistent
 * cookie or a username obtained via the session. When specified, that userID will
 * be used instead of the user's JID to track conversations. The server will ignore a
 * manually specified userID if the user's connection to the server is not anonymous.
 *
 * @param metadata metadata to create a dataform from.
 * @param userID   String that represents the ID of the user when using anonymous sessions
 *                 or <tt>null</tt> if a userID should not be used.
 * @throws XMPPException if an error occured joining the queue. An error may indicate
 *                       that a connection failure occured or that the server explicitly rejected the
 *                       request to join the queue.
 */
public void joinQueue(Map metadata, String userID) throws XMPPException {
    // If already in the queue ignore the join request.
    if (inQueue) {
        throw new IllegalStateException("Already in queue " + workgroupJID);
    }

    // Build dataform from metadata
    Form form = new Form(Form.TYPE_SUBMIT);
    Iterator iter = metadata.keySet().iterator();
    while (iter.hasNext()) {
        String name = (String)iter.next();
        String value = (String)metadata.get(name).toString();

        String escapedName = StringUtils.escapeForXML(name);
        String escapedValue = StringUtils.escapeForXML(value);

        FormField field = new FormField(escapedName);
        field.setType(FormField.TYPE_TEXT_SINGLE);
        form.addField(field);
        form.setAnswer(escapedName, escapedValue);
    }
    joinQueue(form, userID);
}
 
開發者ID:ice-coffee,項目名稱:EIM,代碼行數:57,代碼來源:Workgroup.java

示例3: joinQueue

import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
/**
 * <p>Joins the workgroup queue to wait to be routed to an agent. After joining
 * the queue, queue status events will be sent to indicate the user's position and
 * estimated time left in the queue. Once joining the queue, there are three ways
 * the user can leave the queue: <ul>
 * <p/>
 * <li>The user is routed to an agent, which triggers a GroupChat invitation.
 * <li>The user asks to leave the queue by calling the {@link #departQueue} method.
 * <li>A server error occurs, or an administrator explicitly removes the user
 * from the queue.
 * </ul>
 * <p/>
 * A user cannot request to join the queue again if already in the queue. Therefore,
 * this method will throw an IllegalStateException if the user is already in the queue.<p>
 * <p/>
 * Some servers may be configured to require certain meta-data in order to
 * join the queue.<p>
 * <p/>
 * The server tracks the conversations that a user has with agents over time. By
 * default, that tracking is done using the user's JID. However, this is not always
 * possible. For example, when the user is logged in anonymously using a web client.
 * In that case the user ID might be a randomly generated value put into a persistent
 * cookie or a username obtained via the session. When specified, that userID will
 * be used instead of the user's JID to track conversations. The server will ignore a
 * manually specified userID if the user's connection to the server is not anonymous.
 *
 * @param metadata metadata to create a dataform from.
 * @param userID   String that represents the ID of the user when using anonymous sessions
 *                 or <tt>null</tt> if a userID should not be used.
 * @throws XMPPException if an error occured joining the queue. An error may indicate
 *                       that a connection failure occured or that the server explicitly rejected the
 *                       request to join the queue.
 */
public void joinQueue(Map<String,Object> metadata, String userID) throws XMPPException {
    // If already in the queue ignore the join request.
    if (inQueue) {
        throw new IllegalStateException("Already in queue " + workgroupJID);
    }

    // Build dataform from metadata
    Form form = new Form(Form.TYPE_SUBMIT);
    Iterator<String> iter = metadata.keySet().iterator();
    while (iter.hasNext()) {
        String name = iter.next();
        String value = metadata.get(name).toString();

        String escapedName = StringUtils.escapeForXML(name);
        String escapedValue = StringUtils.escapeForXML(value);

        FormField field = new FormField(escapedName);
        field.setType(FormField.TYPE_TEXT_SINGLE);
        form.addField(field);
        form.setAnswer(escapedName, escapedValue);
    }
    joinQueue(form, userID);
}
 
開發者ID:CJC-ivotten,項目名稱:androidPN-client.,代碼行數:57,代碼來源:Workgroup.java


注:本文中的org.jivesoftware.smack.util.StringUtils.escapeForXML方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。