use of org.jivesoftware.smack.xml.XmlPullParser in project Smack by igniterealtime.
the class DataFormsXmlElementProvider method parse.
@Override
public DataFormsXmlElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws IOException, XmlPullParserException, SmackParsingException {
XmlPullParser.TagEvent tagEvent = parser.nextTag();
final StandardExtensionElement standardExtensionElement;
if (tagEvent == XmlPullParser.TagEvent.START_ELEMENT) {
standardExtensionElement = StandardExtensionElementProvider.INSTANCE.parse(parser);
} else {
standardExtensionElement = null;
}
return new DataFormsXmlElement(standardExtensionElement);
}
use of org.jivesoftware.smack.xml.XmlPullParser in project Smack by igniterealtime.
the class AcknowledgedExtensionTest method checkDisplayedProvider.
@Test
public void checkDisplayedProvider() throws Exception {
XmlPullParser parser = PacketParserUtils.getParserFor(acknowledgedExtension);
AcknowledgedExtension acknowledgedExtension1 = new AcknowledgedProvider().parse(parser);
assertEquals("message-1", acknowledgedExtension1.getId());
Message message = PacketParserUtils.parseStanza(acknowledgedMessageStanza);
AcknowledgedExtension acknowledgedExtension2 = AcknowledgedExtension.from(message);
assertEquals("message-1", acknowledgedExtension2.getId());
}
use of org.jivesoftware.smack.xml.XmlPullParser in project Smack by igniterealtime.
the class RetractedElementProvider method parse.
@Override
public RetractedElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException, ParseException {
Date date = ParserUtils.getDateFromXep82String(parser.getAttributeValue("", RetractedElement.ATTR_STAMP));
OriginIdElement originIdElement = null;
while (originIdElement == null) {
XmlPullParser.TagEvent tag = parser.nextTag();
if (tag == XmlPullParser.TagEvent.START_ELEMENT && OriginIdElement.ELEMENT.equals(parser.getName()) && StableUniqueStanzaIdManager.NAMESPACE.equals(parser.getNamespace())) {
originIdElement = OriginIdProvider.INSTANCE.parse(parser);
}
}
return new RetractedElement(date, originIdElement);
}
use of org.jivesoftware.smack.xml.XmlPullParser in project Smack by igniterealtime.
the class CarbonTest method carbonReceivedTest.
@Test
public void carbonReceivedTest() throws Exception {
XmlPullParser parser;
String control;
CarbonExtension cc;
control = XMLBuilder.create("received").e("forwarded").a("xmlns", "urn:xmpp:forwarded:0").e("message").a("from", "romeo@montague.com").asString(outputProperties);
parser = PacketParserUtils.getParserFor(control);
cc = new CarbonManagerProvider().parse(parser);
assertEquals(CarbonExtension.Direction.received, cc.getDirection());
// check end of tag
assertEquals(XmlPullParser.Event.END_ELEMENT, parser.getEventType());
assertEquals("received", parser.getName());
}
use of org.jivesoftware.smack.xml.XmlPullParser in project Smack by igniterealtime.
the class DisplayedExtensionTest method checkDisplayedProvider.
@Test
public void checkDisplayedProvider() throws Exception {
XmlPullParser parser = PacketParserUtils.getParserFor(displayedExtension);
DisplayedExtension displayedExtension1 = new DisplayedProvider().parse(parser);
assertEquals("message-1", displayedExtension1.getId());
Message message = PacketParserUtils.parseStanza(displayedMessageStanza);
DisplayedExtension displayedExtension2 = DisplayedExtension.from(message);
assertEquals("message-1", displayedExtension2.getId());
}
Aggregations