Search in sources :

Example 1 with MamElementFactory

use of org.jivesoftware.smackx.mam.element.MamElementFactory in project Smack by igniterealtime.

the class MamResultProvider method parse.

@Override
public MamResultExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException, ParseException {
    MamElementFactory elementFactory = MamElementFactory.forParser(parser);
    Forwarded<Message> forwarded = null;
    String queryId = parser.getAttributeValue("", "queryid");
    String id = parser.getAttributeValue("", "id");
    outerloop: while (true) {
        final XmlPullParser.Event eventType = parser.next();
        switch(eventType) {
            case START_ELEMENT:
                final String name = parser.getName();
                switch(name) {
                    case Forwarded.ELEMENT:
                        forwarded = ForwardedProvider.parseForwardedMessage(parser, xmlEnvironment);
                        break;
                }
                break;
            case END_ELEMENT:
                if (parser.getDepth() == initialDepth) {
                    break outerloop;
                }
                break;
            default:
                // Catch all for incomplete switch (MissingCasesInEnumSwitch) statement.
                break;
        }
    }
    return elementFactory.newResultExtension(queryId, id, forwarded);
}
Also used : Message(org.jivesoftware.smack.packet.Message) MamElementFactory(org.jivesoftware.smackx.mam.element.MamElementFactory)

Example 2 with MamElementFactory

use of org.jivesoftware.smackx.mam.element.MamElementFactory in project Smack by igniterealtime.

the class MamFinIQProvider method parse.

@Override
public MamFinIQ parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
    MamElementFactory elementFactory = MamElementFactory.forParser(parser);
    String queryId = parser.getAttributeValue("", "queryid");
    boolean complete = ParserUtils.getBooleanAttribute(parser, "complete", false);
    boolean stable = ParserUtils.getBooleanAttribute(parser, "stable", true);
    RSMSet rsmSet = null;
    outerloop: while (true) {
        XmlPullParser.Event eventType = parser.next();
        switch(eventType) {
            case START_ELEMENT:
                if (parser.getName().equals(RSMSet.ELEMENT)) {
                    rsmSet = RSMSetProvider.INSTANCE.parse(parser);
                }
                break;
            case END_ELEMENT:
                if (parser.getDepth() == initialDepth) {
                    break outerloop;
                }
                break;
            default:
                // Catch all for incomplete switch (MissingCasesInEnumSwitch) statement.
                break;
        }
    }
    return elementFactory.newFinIQ(queryId, rsmSet, complete, stable);
}
Also used : RSMSet(org.jivesoftware.smackx.rsm.packet.RSMSet) MamElementFactory(org.jivesoftware.smackx.mam.element.MamElementFactory)

Example 3 with MamElementFactory

use of org.jivesoftware.smackx.mam.element.MamElementFactory in project Smack by igniterealtime.

the class MamPrefsIQProvider method parse.

@Override
public MamPrefsIQ parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException {
    MamElementFactory elementFactory = MamElementFactory.forParser(parser);
    String defaultBehaviorString = parser.getAttributeValue("", "default");
    DefaultBehavior defaultBehavior = null;
    if (defaultBehaviorString != null) {
        defaultBehavior = DefaultBehavior.valueOf(defaultBehaviorString);
    }
    List<Jid> alwaysJids = null;
    List<Jid> neverJids = null;
    outerloop: while (true) {
        final XmlPullParser.Event eventType = parser.next();
        switch(eventType) {
            case START_ELEMENT:
                final String name = parser.getName();
                switch(name) {
                    case "always":
                        alwaysJids = iterateJids(parser);
                        break;
                    case "never":
                        neverJids = iterateJids(parser);
                        break;
                }
                break;
            case END_ELEMENT:
                if (parser.getDepth() == initialDepth) {
                    break outerloop;
                }
                break;
            default:
                // Catch all for incomplete switch (MissingCasesInEnumSwitch) statement.
                break;
        }
    }
    return elementFactory.newPrefsIQ(alwaysJids, neverJids, defaultBehavior);
}
Also used : Jid(org.jxmpp.jid.Jid) DefaultBehavior(org.jivesoftware.smackx.mam.element.MamPrefsIQ.DefaultBehavior) MamElementFactory(org.jivesoftware.smackx.mam.element.MamElementFactory)

Example 4 with MamElementFactory

use of org.jivesoftware.smackx.mam.element.MamElementFactory in project Smack by igniterealtime.

the class MamQueryIQProvider method parse.

@Override
public MamQueryIQ parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
    MamElementFactory elementFactory = MamElementFactory.forParser(parser);
    DataForm dataForm = null;
    String queryId = parser.getAttributeValue("", "queryid");
    String node = parser.getAttributeValue("", "node");
    outerloop: while (true) {
        final XmlPullParser.Event eventType = parser.next();
        switch(eventType) {
            case START_ELEMENT:
                final String name = parser.getName();
                switch(name) {
                    case DataForm.ELEMENT:
                        dataForm = DataFormProvider.INSTANCE.parse(parser);
                        break;
                }
                break;
            case END_ELEMENT:
                if (parser.getDepth() == initialDepth) {
                    break outerloop;
                }
                break;
            default:
                // Catch all for incomplete switch (MissingCasesInEnumSwitch) statement.
                break;
        }
    }
    return elementFactory.newQueryIQ(queryId, node, dataForm);
}
Also used : DataForm(org.jivesoftware.smackx.xdata.packet.DataForm) MamElementFactory(org.jivesoftware.smackx.mam.element.MamElementFactory)

Aggregations

MamElementFactory (org.jivesoftware.smackx.mam.element.MamElementFactory)4 Message (org.jivesoftware.smack.packet.Message)1 DefaultBehavior (org.jivesoftware.smackx.mam.element.MamPrefsIQ.DefaultBehavior)1 RSMSet (org.jivesoftware.smackx.rsm.packet.RSMSet)1 DataForm (org.jivesoftware.smackx.xdata.packet.DataForm)1 Jid (org.jxmpp.jid.Jid)1