All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jivesoftware.smack.bosh.MessageBodyDecoder Maven / Gradle / Ivy

Go to download

Library to connect to Cisco Enterprise Chat and Email (ECE) chat interface which is a modified version of XMPP over BOSH standard.

The newest version!
package org.jivesoftware.smack.bosh;

import org.apache.commons.text.StringEscapeUtils;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

/**
 * Decodes/unescapes special characters in ECE's message body
 */
public class MessageBodyDecoder {

    /**
     * Decodes the specified text replacing escaped characters with their unescaped representations
     *
     * @param text to decode
     * @return decoded results
     */
    public String decode(String text) throws UnsupportedEncodingException {
        text = URLDecoder.decode(text, "UTF-8");
        text = text.replaceAll("\\^([a-z0-9,2])","%$1");
        text = URLDecoder.decode(text, "UTF-8");
        text = StringEscapeUtils.unescapeXml(text);
        return text;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy