Package org.jivesoftware.smackx.packet

Examples of org.jivesoftware.smackx.packet.XHTMLExtension


     *
     * @param message an XHTML message
     * @return an Iterator for the bodies in the message or null if none.
     */
    public static Iterator getBodies(Message message) {
        XHTMLExtension xhtmlExtension = (XHTMLExtension) message.getExtension("html", namespace);
        if (xhtmlExtension != null)
            return xhtmlExtension.getBodies();
        else
            return null;
    }
View Full Code Here


     *
     * @param message the message that will receive the XHTML body
     * @param body the string to add as an XHTML body to the message
     */
    public static void addBody(Message message, String body) {
        XHTMLExtension xhtmlExtension = (XHTMLExtension) message.getExtension("html", namespace);
        if (xhtmlExtension == null) {
            // Create an XHTMLExtension and add it to the message
            xhtmlExtension = new XHTMLExtension();
            message.addExtension(xhtmlExtension);
        }
        // Add the required bodies to the message
        xhtmlExtension.addBody(body);
    }
View Full Code Here

                    String reason,
                    String password,
                    Message message) {
                    // Indicate that the invitation was received
                    answer[0] = reason;
                    XHTMLExtension extension = (XHTMLExtension) message.getExtension("html",
                            "http://jabber.org/protocol/xhtml-im");
                    assertNotNull("An extension was not found in the invitation", extension);
                    answer[1] = (String) extension.getBodies().next();
                }
            });

            // User2 invites user3 to join to the room
            Message msg = new Message();
            XHTMLExtension xhtmlExtension = new XHTMLExtension();
            xhtmlExtension.addBody("<body>Meet me in this excellent room</body>");
            msg.addExtension(xhtmlExtension);
            muc2.invite(msg , getFullJID(2), "Meet me in this excellent room");
            Thread.sleep(350);

            assertEquals(
View Full Code Here

     * @return a PacketExtension.
     * @throws Exception if a parsing error occurs.
     */
    public PacketExtension parseExtension(XmlPullParser parser)
        throws Exception {
        XHTMLExtension xhtmlExtension = new XHTMLExtension();
        boolean done = false;
        StringBuilder buffer = new StringBuilder();
        int startDepth = parser.getDepth();
        int depth = parser.getDepth();
        String lastTag = "";
        while (!done) {
            int eventType = parser.next();
            if (eventType == XmlPullParser.START_TAG) {
                if (parser.getName().equals("body")) {
                    buffer = new StringBuilder();
                    depth = parser.getDepth();
                }
                lastTag = parser.getText();
                buffer.append(parser.getText());
            } else if (eventType == XmlPullParser.TEXT) {
                if (buffer != null) {
                    // We need to return valid XML so any inner text needs to be re-escaped
                    buffer.append(StringUtils.escapeForXML(parser.getText()));
                }
            } else if (eventType == XmlPullParser.END_TAG) {
                if (parser.getName().equals("body") && parser.getDepth() <= depth) {
                    buffer.append(parser.getText());
                    xhtmlExtension.addBody(buffer.toString());
                }
                else if (parser.getName().equals(xhtmlExtension.getElementName())
                        && parser.getDepth() <= startDepth) {
                    done = true;
                }
                else {
                    // This is a check for tags that are both a start and end tag like <br/>
View Full Code Here

     * @return a PacketExtension.
     * @throws Exception if a parsing error occurs.
     */
    public PacketExtension parseExtension(XmlPullParser parser)
        throws Exception {
        XHTMLExtension xhtmlExtension = new XHTMLExtension();
        boolean done = false;
        StringBuilder buffer = new StringBuilder();
        int startDepth = parser.getDepth();
        int depth = parser.getDepth();
        String lastTag = "";
        while (!done) {
            int eventType = parser.next();
            if (eventType == XmlPullParser.START_TAG) {
                if (parser.getName().equals("body")) {
                    buffer = new StringBuilder();
                    depth = parser.getDepth();
                }
                lastTag = parser.getText();
                buffer.append(parser.getText());
            } else if (eventType == XmlPullParser.TEXT) {
                if (buffer != null) {
                    // We need to return valid XML so any inner text needs to be re-escaped
                    buffer.append(StringUtils.escapeForXML(parser.getText()));
                }
            } else if (eventType == XmlPullParser.END_TAG) {
                if (parser.getName().equals("body") && parser.getDepth() <= depth) {
                    buffer.append(parser.getText());
                    xhtmlExtension.addBody(buffer.toString());
                }
                else if (parser.getName().equals(xhtmlExtension.getElementName())
                        && parser.getDepth() <= startDepth) {
                    done = true;
                }
                else {
                    // This is a check for tags that are both a start and end tag like <br/>
View Full Code Here

     *
     * @param message an XHTML message
     * @return an Iterator for the bodies in the message or null if none.
     */
    public static Iterator getBodies(Message message) {
        XHTMLExtension xhtmlExtension = (XHTMLExtension) message.getExtension("html", namespace);
        if (xhtmlExtension != null)
            return xhtmlExtension.getBodies();
        else
            return null;
    }
View Full Code Here

     *
     * @param message the message that will receive the XHTML body
     * @param body the string to add as an XHTML body to the message
     */
    public static void addBody(Message message, String body) {
        XHTMLExtension xhtmlExtension = (XHTMLExtension) message.getExtension("html", namespace);
        if (xhtmlExtension == null) {
            // Create an XHTMLExtension and add it to the message
            xhtmlExtension = new XHTMLExtension();
            message.addExtension(xhtmlExtension);
        }
        // Add the required bodies to the message
        xhtmlExtension.addBody(body);
    }
View Full Code Here

     * @return a PacketExtension.
     * @throws Exception if a parsing error occurs.
     */
    public PacketExtension parseExtension(XmlPullParser parser)
        throws Exception {
        XHTMLExtension xhtmlExtension = new XHTMLExtension();
        boolean done = false;
        StringBuilder buffer = new StringBuilder();
        int startDepth = parser.getDepth();
        int depth = parser.getDepth();
        String lastTag = "";
        while (!done) {
            int eventType = parser.next();
            if (eventType == XmlPullParser.START_TAG) {
                if (parser.getName().equals("body")) {
                    buffer = new StringBuilder();
                    depth = parser.getDepth();
                }
                lastTag = parser.getText();
                buffer.append(parser.getText());
            } else if (eventType == XmlPullParser.TEXT) {
                if (buffer != null) {
                    // We need to return valid XML so any inner text needs to be re-escaped
                    buffer.append(StringUtils.escapeForXML(parser.getText()));
                }
            } else if (eventType == XmlPullParser.END_TAG) {
                if (parser.getName().equals("body") && parser.getDepth() <= depth) {
                    buffer.append(parser.getText());
                    xhtmlExtension.addBody(buffer.toString());
                }
                else if (parser.getName().equals(xhtmlExtension.getElementName())
                        && parser.getDepth() <= startDepth) {
                    done = true;
                }
                else {
                    // This is a check for tags that are both a start and end tag like <br/>
View Full Code Here

                    String reason,
                    String password,
                    Message message) {
                    // Indicate that the invitation was received
                    answer[0] = reason;
                    XHTMLExtension extension = (XHTMLExtension) message.getExtension("html",
                            "http://jabber.org/protocol/xhtml-im");
                    assertNotNull("An extension was not found in the invitation", extension);
                    answer[1] = (String) extension.getBodies().next();
                }
            });

            // User2 invites user3 to join to the room
            Message msg = new Message();
            XHTMLExtension xhtmlExtension = new XHTMLExtension();
            xhtmlExtension.addBody("<body>Meet me in this excellent room</body>");
            msg.addExtension(xhtmlExtension);
            muc2.invite(msg , getFullJID(2), "Meet me in this excellent room");
            Thread.sleep(350);

            assertEquals(
View Full Code Here

     *
     * @param message an XHTML message
     * @return an Iterator for the bodies in the message or null if none.
     */
    public static Iterator<String> getBodies(Message message) {
        XHTMLExtension xhtmlExtension = (XHTMLExtension) message.getExtension("html", namespace);
        if (xhtmlExtension != null)
            return xhtmlExtension.getBodies();
        else
            return null;
    }
View Full Code Here

TOP

Related Classes of org.jivesoftware.smackx.packet.XHTMLExtension

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.