mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-12 14:01:08 +01:00
Use XmlEnvironment in parsing/provider subsystem
This commit is contained in:
parent
43bb418d99
commit
8df69bd3ce
188 changed files with 486 additions and 264 deletions
|
|
@ -27,7 +27,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
* extensions. This effectively extends the idea of an extension within one of the
|
||||
* top level {@link Stanza} types to consider any embedded element to be an extension
|
||||
* of its parent. This more easily enables the usage of some of Smacks parsing
|
||||
* utilities such as {@link PacketParserUtils#parseExtensionElement(String, String, org.xmlpull.v1.XmlPullParser)} to be used
|
||||
* utilities such as {@link PacketParserUtils#parseExtensionElement(String, String, org.xmlpull.v1.XmlPullParser, org.jivesoftware.smack.packet.XmlEnvironment)} to be used
|
||||
* to parse any element of the XML being parsed.
|
||||
*
|
||||
* <p>Top level extensions have only one element, but they can have multiple children, or
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package org.jivesoftware.smackx.pubsub.provider;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
|
||||
|
|
@ -36,7 +37,7 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
public class AffiliationProvider extends ExtensionElementProvider<Affiliation> {
|
||||
|
||||
@Override
|
||||
public Affiliation parse(XmlPullParser parser, int initialDepth) throws IOException {
|
||||
public Affiliation parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws IOException {
|
||||
String node = parser.getAttributeValue(null, "node");
|
||||
BareJid jid = ParserUtils.getBareJidAttribute(parser);
|
||||
String namespaceString = parser.getNamespace();
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package org.jivesoftware.smackx.pubsub.provider;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.provider.ProviderManager;
|
||||
|
|
@ -43,7 +44,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
*/
|
||||
public class ItemProvider extends ExtensionElementProvider<Item> {
|
||||
@Override
|
||||
public Item parse(XmlPullParser parser, int initialDepth)
|
||||
public Item parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
|
||||
throws XmlPullParserException, IOException, SmackParsingException {
|
||||
String id = parser.getAttributeValue(null, "id");
|
||||
String node = parser.getAttributeValue(null, "node");
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package org.jivesoftware.smackx.pubsub.provider;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
|
|
@ -37,7 +38,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
*/
|
||||
public class PubSubProvider extends IQProvider<PubSub> {
|
||||
@Override
|
||||
public PubSub parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException {
|
||||
public PubSub parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
|
||||
String namespace = parser.getNamespace();
|
||||
PubSubNamespace pubSubNamespace = PubSubNamespace.valueOfFromXmlns(namespace);
|
||||
PubSub pubsub = new PubSub(pubSubNamespace);
|
||||
|
|
@ -46,7 +47,7 @@ public class PubSubProvider extends IQProvider<PubSub> {
|
|||
int eventType = parser.next();
|
||||
switch (eventType) {
|
||||
case XmlPullParser.START_TAG:
|
||||
PacketParserUtils.addExtensionElement(pubsub, parser);
|
||||
PacketParserUtils.addExtensionElement(pubsub, parser, xmlEnvironment);
|
||||
break;
|
||||
case XmlPullParser.END_TAG:
|
||||
if (parser.getDepth() == initialDepth) {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package org.jivesoftware.smackx.pubsub.provider;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
|
||||
|
|
@ -35,7 +36,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
*/
|
||||
public class SubscriptionProvider extends ExtensionElementProvider<Subscription> {
|
||||
@Override
|
||||
public Subscription parse(XmlPullParser parser, int initialDepth)
|
||||
public Subscription parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
|
||||
throws XmlPullParserException, IOException {
|
||||
Jid jid = ParserUtils.getJidAttribute(parser);
|
||||
String nodeId = parser.getAttributeValue(null, "node");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue