diff --git a/documentation/providers.md b/documentation/providers.md index dfae160f4..492a9d26e 100644 --- a/documentation/providers.md +++ b/documentation/providers.md @@ -65,7 +65,10 @@ introspection is used to try to automatically set properties of the IQ instance using the values found in the IQ packet XML. For example, an XMPP time packet resembles the following: -### Introspection +### Introspection (DEPRECATED) + +*Note*: This feature is deprecated, using introspection for parsing is not recommended. +Instead implement your own provider like shown in the next section. _Time Packet_ @@ -112,7 +115,65 @@ The introspection service will automatically try to convert the String value from the XML into a boolean, int, long, float, double, or Class depending on the type the IQ instance expects. -_IQProvider Implementation_ +### Custom IQProvider example + +Let's assume you want to write a provider for a new, unsupported IQ in Smack. + +_Custom IQ_ + +``` + + + John Doe + New York + + +``` + +_Custom IQ Provider_ + +```java +public class MyIQProvider extends IQProvider { + + @Override + public MyIQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { + // Define the data we are trying to collect with sane defaults + int age = -1; + String user = null; + String location = null; + + // Start parsing loop + outerloop: while(true) { + int eventType = parser.next(); + switch(eventType) { + case XmlPullParser.START_TAG: + String elementName = parser.getName(); + switch (elementName) { + case "user": + age = ParserUtils.getIntegerAttribute(parser, "age"); + user = parser.nextText(); + break; + case "location" + location = parser.nextText(); + break; + } + break; + case XmlPullParser.END_TAG: + // Abort condition: if the are on a end tag (closing element) of the same depth + if (parser.getDepth() == initialDepth) { + break outerloop; + } + break; + } + } + + // Construct the IQ instance at the end of parsing, when all data has been collected + return new MyIQ(user, age, location); + } +} +``` + +### DiscoItemsProvider _Disco Items Packet_ @@ -136,37 +197,48 @@ _Disco Items IQProvider_ - public class DiscoverItemsProvider implements IQProvider { + public class DiscoverItemsProvider implements IQProvider { - public IQ parseIQ(XmlPullParser parser) throws Exception { + public DiscoverItems parseIQ(XmlPullParser parser, int initialDepth) throw XmlPullParserException, IOException { DiscoverItems discoverItems = new DiscoverItems(); - boolean done = false; DiscoverItems.Item item; String jid = ""; String name = ""; String action = ""; String node = ""; discoverItems.setNode(parser.getAttributeValue("", "node")); - while (!done) { + outerloop: while (true) { int eventType = parser.next(); - - if (eventType == XmlPullParser.START_TAG && "item".equals(parser.getName())) { - // Initialize the variables from the parsed XML - jid = parser.getAttributeValue("", "jid"); - name = parser.getAttributeValue("", "name"); - node = parser.getAttributeValue("", "node"); - action = parser.getAttributeValue("", "action"); - } - else if (eventType == XmlPullParser.END_TAG && "item".equals(parser.getName())) { - // Create a new Item and add it to DiscoverItems. - item = new DiscoverItems.Item(jid); - item.setName(name); - item.setNode(node); - item.setAction(action); - discoverItems.addItem(item); - } - else if (eventType == XmlPullParser.END_TAG && "query".equals(parser.getName())) { - done = true; + switch (eventType) { + case XmlPullParser.START_TAG: + String elementName = parser.getName(); + switch (elementName) { + case "item": + // Initialize the variables from the parsed XML + jid = parser.getAttributeValue("", "jid"); + name = parser.getAttributeValue("", "name"); + node = parser.getAttributeValue("", "node"); + action = parser.getAttributeValue("", "action"); + break; + } + break; + case XmlPullParser.END_TAG: + String elementName = parser.getName(); + switch (elementName) { + case "item": + // Create a new Item and add it to DiscoverItems. + item = new DiscoverItems.Item(jid); + item.setName(name); + item.setNode(node); + item.setAction(action); + discoverItems.addItem(item); + break; + case "query": + if (parser.getDepth() == initialDepth) { + break outerloop; + } + break; + } } } return discoverItems; diff --git a/smack-core/src/integration-test/java/org/jivesoftware/smack/packet/PrivacyProviderTest.java b/smack-core/src/integration-test/java/org/jivesoftware/smack/packet/PrivacyProviderTest.java index 824b6e866..c9c1c9d2d 100644 --- a/smack-core/src/integration-test/java/org/jivesoftware/smack/packet/PrivacyProviderTest.java +++ b/smack-core/src/integration-test/java/org/jivesoftware/smack/packet/PrivacyProviderTest.java @@ -125,7 +125,7 @@ public class PrivacyProviderTest extends SmackTestCase { // Create the xml parser XmlPullParser parser = getParserFromXML(xml); // Create a packet from the xml - Privacy packet = (Privacy) (new PrivacyProvider()).parseIQ(parser); + Privacy packet = (Privacy) (new PrivacyProvider()).parse(parser); // check if it exist assertNotNull(packet); @@ -317,7 +317,7 @@ public class PrivacyProviderTest extends SmackTestCase { // Create the xml parser XmlPullParser parser = getParserFromXML(xml); // Create a packet from the xml - Privacy packet = (Privacy) (new PrivacyProvider()).parseIQ(parser); + Privacy packet = (Privacy) (new PrivacyProvider()).parse(parser); assertNotNull(packet); assertNotNull(packet.getChildElementXML()); @@ -356,7 +356,7 @@ public class PrivacyProviderTest extends SmackTestCase { // Create the xml parser XmlPullParser parser = getParserFromXML(xml); // Create a packet from the xml - Privacy packet = (Privacy) (new PrivacyProvider()).parseIQ(parser); + Privacy packet = (Privacy) (new PrivacyProvider()).parse(parser); assertNotNull(packet); diff --git a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java index ba60df0a4..bdc81df61 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java @@ -58,8 +58,8 @@ import org.jivesoftware.smack.packet.RosterVer; import org.jivesoftware.smack.packet.Session; import org.jivesoftware.smack.packet.StartTls; import org.jivesoftware.smack.packet.PlainStreamElement; +import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smack.provider.ProviderManager; -import org.jivesoftware.smack.provider.StreamFeatureProvider; import org.jivesoftware.smack.rosterstore.RosterStore; import org.jivesoftware.smack.util.PacketParserUtils; import org.jxmpp.util.XmppStringUtils; @@ -1052,9 +1052,9 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { streamFeature = PacketParserUtils.parseCompressionFeature(parser); break; default: - StreamFeatureProvider provider = ProviderManager.getStreamFeatureProvider(name, namespace); + PacketExtensionProvider provider = ProviderManager.getStreamFeatureProvider(name, namespace); if (provider != null) { - streamFeature = provider.parseStreamFeature(parser); + streamFeature = provider.parse(parser); } break; } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/EmbeddedExtensionProvider.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/EmbeddedExtensionProvider.java index c180ec168..957fdb19c 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/provider/EmbeddedExtensionProvider.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/EmbeddedExtensionProvider.java @@ -16,14 +16,17 @@ */ package org.jivesoftware.smack.provider; +import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.util.PacketParserUtils; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * @@ -78,11 +81,12 @@ import org.xmlpull.v1.XmlPullParser; * * @author Robin Collier */ -abstract public class EmbeddedExtensionProvider implements PacketExtensionProvider +abstract public class EmbeddedExtensionProvider extends PacketExtensionProvider { - final public PacketExtension parseExtension(XmlPullParser parser) throws Exception - { + @Override + final public PE parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException, SmackException { String namespace = parser.getNamespace(); String name = parser.getName(); Map attMap = new HashMap(); @@ -92,17 +96,18 @@ abstract public class EmbeddedExtensionProvider implements PacketExtensionProvid attMap.put(parser.getAttributeName(i), parser.getAttributeValue(i)); } List extensions = new ArrayList(); - + + int tag; do { - int tag = parser.next(); + tag = parser.next(); if (tag == XmlPullParser.START_TAG) extensions.add(PacketParserUtils.parsePacketExtension(parser.getName(), parser.getNamespace(), parser)); - } while (!name.equals(parser.getName())); + } while (!(tag == XmlPullParser.END_TAG && parser.getDepth() == initialDepth)); return createReturnExtension(name, namespace, attMap, extensions); } - abstract protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content); + abstract protected PE createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content); } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/ExtensionProviderInfo.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/ExtensionProviderInfo.java index c062664b3..32f1ec763 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/provider/ExtensionProviderInfo.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/ExtensionProviderInfo.java @@ -16,6 +16,8 @@ */ package org.jivesoftware.smack.provider; +import org.jivesoftware.smack.packet.PacketExtension; + /** * Defines the information required to register a packet extension Provider with the {@link ProviderManager} when using the * {@link ProviderLoader}. @@ -32,7 +34,7 @@ public final class ExtensionProviderInfo extends AbstractProviderInfo { * @param namespace Namespace that provider parses. * @param extProvider The provider implementation. */ - public ExtensionProviderInfo(String elementName, String namespace, PacketExtensionProvider extProvider) { + public ExtensionProviderInfo(String elementName, String namespace, PacketExtensionProvider extProvider) { super(elementName, namespace, extProvider); } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/IQProvider.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/IQProvider.java index aaa099b91..66e7aa0f1 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/provider/IQProvider.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/IQProvider.java @@ -18,27 +18,14 @@ package org.jivesoftware.smack.provider; import org.jivesoftware.smack.packet.IQ; -import org.xmlpull.v1.XmlPullParser; /** - * An interface for parsing custom IQ packets. Each IQProvider must be registered with + * An abstract class for parsing custom IQ packets. Each IQProvider must be registered with * the ProviderManager class for it to be used. Every implementation of this - * interface must have a public, no-argument constructor. + * abstract class must have a public, no-argument constructor. * * @author Matt Tucker */ -public interface IQProvider { +public abstract class IQProvider extends Provider { - /** - * Parse the IQ sub-document and create an IQ instance. Each IQ must have a - * single child element. At the beginning of the method call, the xml parser - * will be positioned at the opening tag of the IQ child element. At the end - * of the method call, the parser must be positioned on the closing tag - * of the child element. - * - * @param parser an XML parser. - * @return a new IQ instance. - * @throws Exception if an error occurs parsing the XML. - */ - public IQ parseIQ(XmlPullParser parser) throws Exception; } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/IQProviderInfo.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/IQProviderInfo.java index 9265c32e2..31e768393 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/provider/IQProviderInfo.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/IQProviderInfo.java @@ -34,7 +34,7 @@ public final class IQProviderInfo extends AbstractProviderInfo { * @param namespace Namespace that provider parses. * @param iqProvider The provider implementation. */ - public IQProviderInfo(String elementName, String namespace, IQProvider iqProvider) { + public IQProviderInfo(String elementName, String namespace, IQProvider iqProvider) { super(elementName, namespace, iqProvider); } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/PacketExtensionProvider.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/PacketExtensionProvider.java index bf248562a..ca14527b1 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/provider/PacketExtensionProvider.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/PacketExtensionProvider.java @@ -17,27 +17,16 @@ package org.jivesoftware.smack.provider; + import org.jivesoftware.smack.packet.PacketExtension; -import org.xmlpull.v1.XmlPullParser; /** - * An interface for parsing custom packets extensions. Each PacketExtensionProvider must + * An abstract class for parsing custom packets extensions. Each PacketExtensionProvider must * be registered with the ProviderManager class for it to be used. Every implementation - * of this interface must have a public, no-argument constructor. + * of this abstract class must have a public, no-argument constructor. * * @author Matt Tucker */ -public interface PacketExtensionProvider { +public abstract class PacketExtensionProvider extends Provider { - /** - * Parse an extension sub-packet and create a PacketExtension instance. At - * the beginning of the method call, the xml parser will be positioned on the - * opening element of the packet extension. At the end of the method call, the - * parser must be positioned on the closing element of the packet extension. - * - * @param parser an XML parser. - * @return a new IQ instance. - * @throws java.lang.Exception if an error occurs parsing the XML. - */ - public PacketExtension parseExtension(XmlPullParser parser) throws Exception; } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/StreamFeatureProvider.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/Provider.java similarity index 50% rename from smack-core/src/main/java/org/jivesoftware/smack/provider/StreamFeatureProvider.java rename to smack-core/src/main/java/org/jivesoftware/smack/provider/Provider.java index 7642ad3e3..4fcaa76a5 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/provider/StreamFeatureProvider.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/Provider.java @@ -20,20 +20,24 @@ package org.jivesoftware.smack.provider; import java.io.IOException; import org.jivesoftware.smack.SmackException; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.Element; +import org.jivesoftware.smack.util.ParserUtils; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; -/** - * - */ -public interface StreamFeatureProvider { +public abstract class Provider { - /** - * - * @param parser an XML parser. - * @return a new PacketExtension instance. - * @throws XmlPullParserException if an error occurs parsing the XML. - */ - public PacketExtension parseStreamFeature(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException; + public final E parse(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException { + // XPP3 calling convention assert: Parser should be at start tag + ParserUtils.assertAtStartTag(parser); + + final int initialDepth = parser.getDepth(); + E e = parse(parser, initialDepth); + + // XPP3 calling convention assert: Parser should be at end tag of the consumed/parsed element + ParserUtils.forwardToEndTagOfDepth(parser, initialDepth); + return e; + } + + public abstract E parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException;; } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderFileLoader.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderFileLoader.java index 8d7c3a1f9..5f33842c5 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderFileLoader.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderFileLoader.java @@ -83,11 +83,16 @@ public class ProviderFileLoader implements ProviderLoader { // reflection later to create instances of the class. // Add the provider to the map. if (IQProvider.class.isAssignableFrom(provider)) { - iqProviders.add(new IQProviderInfo(elementName, namespace, (IQProvider) provider.newInstance())); + iqProviders.add(new IQProviderInfo(elementName, namespace, (IQProvider) provider.newInstance())); } else if (IQ.class.isAssignableFrom(provider)) { iqProviders.add(new IQProviderInfo(elementName, namespace, (Class)provider)); } + else { + exceptions.add(new IllegalArgumentException( + className + + " is neither IQProvider or IQ class")); + } break; case "extensionProvider": // Attempt to load the provider class and then create @@ -96,16 +101,21 @@ public class ProviderFileLoader implements ProviderLoader { // then we'll use reflection later to create instances // of the class. if (PacketExtensionProvider.class.isAssignableFrom(provider)) { - extProviders.add(new ExtensionProviderInfo(elementName, namespace, (PacketExtensionProvider) provider.newInstance())); + extProviders.add(new ExtensionProviderInfo(elementName, namespace, (PacketExtensionProvider) provider.newInstance())); } else if (PacketExtension.class.isAssignableFrom(provider)) { extProviders.add(new ExtensionProviderInfo(elementName, namespace, provider)); } + else { + exceptions.add(new IllegalArgumentException( + className + + " is neither PacketExtensionProvider or PacketExtension class")); + } break; case "streamFeatureProvider": sfProviders.add(new StreamFeatureProviderInfo(elementName, namespace, - (StreamFeatureProvider) provider.newInstance())); + (PacketExtensionProvider) provider.newInstance())); break; default: LOGGER.warning("Unkown provider type: " + typeName); diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderManager.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderManager.java index 9d3437f08..213b32e36 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderManager.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderManager.java @@ -109,11 +109,11 @@ import org.jxmpp.util.XmppStringUtils; */ public final class ProviderManager { - private static final Map extensionProviders = new ConcurrentHashMap(); - private static final Map iqProviders = new ConcurrentHashMap(); + private static final Map> extensionProviders = new ConcurrentHashMap>(); + private static final Map> iqProviders = new ConcurrentHashMap>(); private static final Map> extensionIntrospectionProviders = new ConcurrentHashMap>(); private static final Map> iqIntrospectionProviders = new ConcurrentHashMap>(); - private static final Map streamFeatureProviders = new ConcurrentHashMap(); + private static final Map> streamFeatureProviders = new ConcurrentHashMap>(); static { // Ensure that Smack is initialized by calling getVersion, so that user @@ -157,7 +157,7 @@ public final class ProviderManager { * @param namespace the XML namespace. * @return the IQ provider. */ - public static IQProvider getIQProvider(String elementName, String namespace) { + public static IQProvider getIQProvider(String elementName, String namespace) { String key = getKey(elementName, namespace); return iqProviders.get(key); } @@ -190,13 +190,14 @@ public final class ProviderManager { * @param namespace the XML namespace. * @param provider the IQ provider. */ + @SuppressWarnings("unchecked") public static void addIQProvider(String elementName, String namespace, Object provider) { // First remove existing providers String key = removeIQProvider(elementName, namespace); if (provider instanceof IQProvider) { - iqProviders.put(key, (IQProvider) provider); + iqProviders.put(key, (IQProvider) provider); } else if (provider instanceof Class && IQ.class.isAssignableFrom((Class) provider)) { iqIntrospectionProviders.put(key, (Class) provider); } else { @@ -240,7 +241,7 @@ public final class ProviderManager { * @param namespace namespace associated with extension provider. * @return the extenion provider. */ - public static PacketExtensionProvider getExtensionProvider(String elementName, String namespace) { + public static PacketExtensionProvider getExtensionProvider(String elementName, String namespace) { String key = getKey(elementName, namespace); return extensionProviders.get(key); } @@ -259,13 +260,14 @@ public final class ProviderManager { * @param namespace the XML namespace. * @param provider the extension provider. */ + @SuppressWarnings("unchecked") public static void addExtensionProvider(String elementName, String namespace, Object provider) { // First remove existing providers String key = removeExtensionProvider(elementName, namespace); if (provider instanceof PacketExtensionProvider) { - extensionProviders.put(key, (PacketExtensionProvider) provider); + extensionProviders.put(key, (PacketExtensionProvider) provider); } else if (provider instanceof Class && PacketExtension.class.isAssignableFrom((Class) provider)) { extensionIntrospectionProviders.put(key, (Class) provider); } else { @@ -304,12 +306,12 @@ public final class ProviderManager { return Collections.unmodifiableList(providers); } - public static StreamFeatureProvider getStreamFeatureProvider(String elementName, String namespace) { + public static PacketExtensionProvider getStreamFeatureProvider(String elementName, String namespace) { String key = getKey(elementName, namespace); return streamFeatureProviders.get(key); } - public static void addStreamFeatureProvider(String elementName, String namespace, StreamFeatureProvider provider) { + public static void addStreamFeatureProvider(String elementName, String namespace, PacketExtensionProvider provider) { String key = getKey(elementName, namespace); streamFeatureProviders.put(key, provider); } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/StreamFeatureProviderInfo.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/StreamFeatureProviderInfo.java index 5156c59b0..040b98752 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/provider/StreamFeatureProviderInfo.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/StreamFeatureProviderInfo.java @@ -16,6 +16,8 @@ */ package org.jivesoftware.smack.provider; +import org.jivesoftware.smack.packet.PacketExtension; + /** * */ @@ -28,7 +30,8 @@ public final class StreamFeatureProviderInfo extends AbstractProviderInfo { * @param namespace Namespace that provider parses. * @param extProvider The provider implementation. */ - public StreamFeatureProviderInfo(String elementName, String namespace, StreamFeatureProvider extProvider) { + public StreamFeatureProviderInfo(String elementName, String namespace, + PacketExtensionProvider extProvider) { super(elementName, namespace, extProvider); } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java index bb1d81752..5623e408d 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java @@ -22,13 +22,13 @@ import java.io.StringReader; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Collection; - import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.logging.Level; import java.util.logging.Logger; +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.compress.packet.Compress; import org.jivesoftware.smack.packet.Bind; @@ -121,7 +121,7 @@ public class PacketParserUtils { case Message.ELEMENT: return parseMessage(parser); case IQ.ELEMENT: - return parseIQ(parser, connection); + return parse(parser, connection); case Presence.ELEMENT: return parsePresence(parser); default: @@ -171,9 +171,16 @@ public class PacketParserUtils { * * @param parser the XML parser, positioned at the start of a message packet. * @return a Message packet. - * @throws Exception if an exception occurs while parsing the packet. + * @throws IOException + * @throws XmlPullParserException + * @throws SmackException */ - public static Message parseMessage(XmlPullParser parser) throws Exception { + public static Message parseMessage(XmlPullParser parser) + throws XmlPullParserException, IOException, SmackException { + ParserUtils.assertAtStartTag(parser); + assert(parser.getName().equals(Message.ELEMENT)); + + final int initialDepth = parser.getDepth(); Message message = new Message(); message.setPacketID(parser.getAttributeValue("", "id")); message.setTo(parser.getAttributeValue("", "to")); @@ -197,26 +204,27 @@ public class PacketParserUtils { // Parse sub-elements. We include extra logic to make sure the values // are only read once. This is because it's possible for the names to appear // in arbitrary sub-elements. - boolean done = false; String thread = null; - while (!done) { + outerloop: while (true) { int eventType = parser.next(); - if (eventType == XmlPullParser.START_TAG) { + switch (eventType) { + case XmlPullParser.START_TAG: String elementName = parser.getName(); String namespace = parser.getNamespace(); - if (elementName.equals("subject")) { - String xmlLang = getLanguageAttribute(parser); - if (xmlLang == null) { - xmlLang = defaultLanguage; + switch(elementName) { + case "subject": + String xmlLangSubject = getLanguageAttribute(parser); + if (xmlLangSubject == null) { + xmlLangSubject = defaultLanguage; } String subject = parseElementText(parser); - if (message.getSubject(xmlLang) == null) { - message.addSubject(xmlLang, subject); + if (message.getSubject(xmlLangSubject) == null) { + message.addSubject(xmlLangSubject, subject); } - } - else if (elementName.equals(Message.BODY)) { + break; + case Message.BODY: String xmlLang = getLanguageAttribute(parser); if (xmlLang == null) { xmlLang = defaultLanguage; @@ -227,25 +235,26 @@ public class PacketParserUtils { if (message.getBody(xmlLang) == null) { message.addBody(xmlLang, body); } - } - else if (elementName.equals("thread")) { + break; + case "thread": if (thread == null) { thread = parser.nextText(); } - } - else if (elementName.equals("error")) { + break; + case "error": message.setError(parseError(parser)); - } - // Otherwise, it must be a packet extension. - else { + break; + default: message.addExtension( PacketParserUtils.parsePacketExtension(elementName, namespace, parser)); + break; } - } - else if (eventType == XmlPullParser.END_TAG) { - if (parser.getName().equals("message")) { - done = true; + break; + case XmlPullParser.END_TAG: + if (parser.getDepth() == initialDepth) { + break outerloop; } + break; } } @@ -434,9 +443,15 @@ public class PacketParserUtils { * * @param parser the XML parser, positioned at the start of a presence packet. * @return a Presence packet. - * @throws Exception if an exception occurs while parsing the packet. + * @throws IOException + * @throws XmlPullParserException + * @throws SmackException */ - public static Presence parsePresence(XmlPullParser parser) throws Exception { + public static Presence parsePresence(XmlPullParser parser) + throws XmlPullParserException, IOException, SmackException { + ParserUtils.assertAtStartTag(parser); + final int initialDepth = parser.getDepth(); + Presence.Type type = Presence.Type.available; String typeString = parser.getAttributeValue("", "type"); if (typeString != null && !typeString.equals("")) { @@ -453,20 +468,21 @@ public class PacketParserUtils { } // Parse sub-elements - boolean done = false; - while (!done) { + outerloop: while (true) { int eventType = parser.next(); - if (eventType == XmlPullParser.START_TAG) { + switch (eventType) { + case XmlPullParser.START_TAG: String elementName = parser.getName(); String namespace = parser.getNamespace(); - if (elementName.equals("status")) { + switch(elementName) { + case "status": presence.setStatus(parser.nextText()); - } - else if (elementName.equals("priority")) { + break; + case "priority": int priority = Integer.parseInt(parser.nextText()); presence.setPriority(priority); - } - else if (elementName.equals("show")) { + break; + case "show": String modeText = parser.nextText(); if (StringUtils.isNotEmpty(modeText)) { presence.setMode(Presence.Mode.fromString(modeText)); @@ -480,12 +496,12 @@ public class PacketParserUtils { + presence.getPacketID() + "' which is invalid according to RFC6121 4.7.2.1"); } - } - else if (elementName.equals("error")) { + break; + case "error": presence.setError(parseError(parser)); - } + break; + default: // Otherwise, it must be a packet extension. - else { // Be extra robust: Skip PacketExtensions that cause Exceptions, instead of // failing completely here. See SMACK-390 for more information. try { @@ -496,12 +512,13 @@ public class PacketParserUtils { "Failed to parse extension packet in Presence packet.", e); } + break; } - } - else if (eventType == XmlPullParser.END_TAG) { - if (parser.getName().equals("presence")) { - done = true; + case XmlPullParser.END_TAG: + if (parser.getDepth() == initialDepth) { + break outerloop; } + break; } } return presence; @@ -515,7 +532,7 @@ public class PacketParserUtils { * @return an IQ object. * @throws Exception if an exception occurs while parsing the packet. */ - public static IQ parseIQ(XmlPullParser parser, XMPPConnection connection) throws Exception { + public static IQ parse(XmlPullParser parser, XMPPConnection connection) throws Exception { IQ iqPacket = null; XMPPError error = null; @@ -543,9 +560,9 @@ public class PacketParserUtils { // Otherwise, see if there is a registered provider for // this element name and namespace. else { - IQProvider provider = ProviderManager.getIQProvider(elementName, namespace); + IQProvider provider = ProviderManager.getIQProvider(elementName, namespace); if (provider != null) { - iqPacket =provider.parseIQ(parser); + iqPacket = provider.parse(parser); } else { Class introspectionProvider = ProviderManager.getIQIntrospectionProvider( elementName, namespace); @@ -611,7 +628,7 @@ public class PacketParserUtils { return iqPacket; } - public static RosterPacket parseRoster(XmlPullParser parser) throws Exception { + public static RosterPacket parseRoster(XmlPullParser parser) throws XmlPullParserException, IOException { RosterPacket roster = new RosterPacket(); boolean done = false; RosterPacket.Item item = null; @@ -826,9 +843,12 @@ public class PacketParserUtils { * * @param parser the XML parser. * @return an error sub-packet. - * @throws Exception if an exception occurs while parsing the packet. + * @throws IOException + * @throws XmlPullParserException + * @throws SmackException */ - public static XMPPError parseError(XmlPullParser parser) throws Exception { + public static XMPPError parseError(XmlPullParser parser) + throws XmlPullParserException, IOException, SmackException { String type = null; String message = null; String condition = null; @@ -882,18 +902,26 @@ public class PacketParserUtils { * @param namespace the XML namespace of the packet extension. * @param parser the XML parser, positioned at the starting element of the extension. * @return a PacketExtension. - * @throws Exception */ public static PacketExtension parsePacketExtension(String elementName, String namespace, - XmlPullParser parser) throws Exception { + XmlPullParser parser) throws XmlPullParserException, + IOException, SmackException { // See if a provider is registered to handle the extension. - PacketExtensionProvider provider = ProviderManager.getExtensionProvider(elementName, namespace); + PacketExtensionProvider provider = ProviderManager.getExtensionProvider(elementName, namespace); if (provider != null) { - return provider.parseExtension(parser); + return provider.parse(parser); } Class introspectionProvider = ProviderManager.getExtensionIntrospectionProvider(elementName, namespace); if (introspectionProvider != null) { - return (PacketExtension)parseWithIntrospection(elementName, introspectionProvider, parser); + try { + return (PacketExtension)parseWithIntrospection(elementName, introspectionProvider, parser); + } catch (NoSuchMethodException | SecurityException + | InstantiationException | IllegalAccessException + | IllegalArgumentException + | InvocationTargetException + | ClassNotFoundException e) { + throw new SmackException(e); + } } // No providers registered, so use a default extension. DefaultPacketExtension extension = new DefaultPacketExtension(elementName, namespace); diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/ParserUtils.java b/smack-core/src/main/java/org/jivesoftware/smack/util/ParserUtils.java index 0264abbda..acd2829f3 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/ParserUtils.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/ParserUtils.java @@ -31,6 +31,14 @@ public class ParserUtils { assert(parser.getEventType() == XmlPullParser.END_TAG); } + public static void forwardToEndTagOfDepth(XmlPullParser parser, int depth) + throws XmlPullParserException, IOException { + int event = parser.getEventType(); + while (!(event == XmlPullParser.END_TAG && parser.getDepth() == depth)) { + event = parser.next(); + } + } + /** * Get the boolean value of an argument. * diff --git a/smack-core/src/test/java/org/jivesoftware/smack/RosterTest.java b/smack-core/src/test/java/org/jivesoftware/smack/RosterTest.java index 3287d6aae..a7a4a78a1 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/RosterTest.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/RosterTest.java @@ -327,7 +327,7 @@ public class RosterTest { .append("") .append(""); final XmlPullParser parser = TestUtils.getIQParser(sb.toString()); - final IQ rosterPush = PacketParserUtils.parseIQ(parser, connection); + final IQ rosterPush = PacketParserUtils.parse(parser, connection); initRoster(connection, roster); rosterListener.reset(); @@ -460,7 +460,7 @@ public class RosterTest { .append("") .append(""); final XmlPullParser parser = TestUtils.getIQParser(sb.toString()); - final IQ rosterPush = PacketParserUtils.parseIQ(parser, connection); + final IQ rosterPush = PacketParserUtils.parse(parser, connection); initRoster(connection, roster); rosterListener.reset(); diff --git a/smack-core/src/test/java/org/jivesoftware/smack/parsing/ParsingExceptionTest.java b/smack-core/src/test/java/org/jivesoftware/smack/parsing/ParsingExceptionTest.java index e5a693613..9b568816b 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/parsing/ParsingExceptionTest.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/parsing/ParsingExceptionTest.java @@ -72,12 +72,12 @@ public class ParsingExceptionTest { assertThat(MESSAGE_EXCEPTION_ELEMENT + EXTENSION2 + "", equalsCharSequence(content)); } - static class ThrowException implements PacketExtensionProvider { + static class ThrowException extends PacketExtensionProvider { public static final String ELEMENT = "exception"; public static final String NAMESPACE = "http://smack.jivesoftware.org/exception"; @Override - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { + public PacketExtension parse(XmlPullParser parser, int initialDepth) throws SmackException { throw new SmackException("Test Exception"); } diff --git a/smack-core/src/test/java/org/jivesoftware/smack/provider/ProviderConfigTest.java b/smack-core/src/test/java/org/jivesoftware/smack/provider/ProviderConfigTest.java index a7eabd6c2..36a18e2c8 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/provider/ProviderConfigTest.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/provider/ProviderConfigTest.java @@ -59,10 +59,10 @@ public class ProviderConfigTest { Assert.assertNotNull(ProviderManager.getIQProvider("provider", "test:file_provider")); } - public static class TestIQProvider implements IQProvider { + public static class TestIQProvider extends IQProvider { @Override - public IQ parseIQ(XmlPullParser parser) throws Exception { + public IQ parse(XmlPullParser parser, int initialDepth) { return null; } diff --git a/smack-core/src/test/java/org/jivesoftware/smack/provider/ProviderManagerTest.java b/smack-core/src/test/java/org/jivesoftware/smack/provider/ProviderManagerTest.java index 601c03afa..333b7f989 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/provider/ProviderManagerTest.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/provider/ProviderManagerTest.java @@ -34,10 +34,10 @@ public class ProviderManagerTest { assertTrue(SmackConfiguration.isSmackInitialized()); } - public static class TestIQProvider implements IQProvider { + public static class TestIQProvider extends IQProvider { @Override - public IQ parseIQ(XmlPullParser parser) throws Exception { + public IQ parse(XmlPullParser parser, int initialDepth) { return null; } diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/provider/CarbonManagerProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/provider/CarbonManagerProvider.java index 3eec6a68a..1c9890271 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/provider/CarbonManagerProvider.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/provider/CarbonManagerProvider.java @@ -16,13 +16,16 @@ */ package org.jivesoftware.smackx.carbons.provider; -import org.jivesoftware.smack.packet.PacketExtension; +import java.io.IOException; + +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.provider.PacketExtensionProvider; -import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smackx.carbons.packet.CarbonExtension; import org.jivesoftware.smackx.carbons.packet.CarbonExtension.Direction; import org.jivesoftware.smackx.forward.Forwarded; +import org.jivesoftware.smackx.forward.provider.ForwardedProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * This class implements the {@link PacketExtensionProvider} to parse @@ -31,9 +34,13 @@ import org.xmlpull.v1.XmlPullParser; * @author Georg Lukas * */ -public class CarbonManagerProvider implements PacketExtensionProvider { +public class CarbonManagerProvider extends PacketExtensionProvider { - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { + private static final ForwardedProvider FORWARDED_PROVIDER = new ForwardedProvider(); + + @Override + public CarbonExtension parse(XmlPullParser parser, int initialDepth) + throws SmackException, XmlPullParserException, IOException { Direction dir = Direction.valueOf(parser.getName()); Forwarded fwd = null; @@ -41,13 +48,13 @@ public class CarbonManagerProvider implements PacketExtensionProvider { while (!done) { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG && parser.getName().equals("forwarded")) { - fwd = (Forwarded) PacketParserUtils.parsePacketExtension(Forwarded.ELEMENT, Forwarded.NAMESPACE, parser); + fwd = FORWARDED_PROVIDER.parse(parser); } else if (eventType == XmlPullParser.END_TAG && dir == Direction.valueOf(parser.getName())) done = true; } if (fwd == null) - throw new Exception("sent/received must contain exactly one tag"); + throw new SmackException("sent/received must contain exactly one tag"); return new CarbonExtension(dir, fwd); } } diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/csi/provider/ClientStateIndicationFeatureProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/csi/provider/ClientStateIndicationFeatureProvider.java index 2facb7047..c6c98eb46 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/csi/provider/ClientStateIndicationFeatureProvider.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/csi/provider/ClientStateIndicationFeatureProvider.java @@ -19,16 +19,15 @@ package org.jivesoftware.smackx.csi.provider; import java.io.IOException; import org.jivesoftware.smack.SmackException; -import org.jivesoftware.smack.packet.PacketExtension; -import org.jivesoftware.smack.provider.StreamFeatureProvider; +import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smackx.csi.packet.ClientStateIndication; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; -public class ClientStateIndicationFeatureProvider implements StreamFeatureProvider { +public class ClientStateIndicationFeatureProvider extends PacketExtensionProvider { @Override - public PacketExtension parseStreamFeature(XmlPullParser parser) + public ClientStateIndication.Feature parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException { return ClientStateIndication.Feature.INSTANCE; } diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/provider/AbstractHttpOverXmppProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/provider/AbstractHttpOverXmppProvider.java index 0cd9456f1..01d188d7a 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/provider/AbstractHttpOverXmppProvider.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/provider/AbstractHttpOverXmppProvider.java @@ -16,6 +16,7 @@ */ package org.jivesoftware.smackx.hoxt.provider; +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smackx.hoxt.packet.AbstractHttpOverXmpp; @@ -23,7 +24,9 @@ import org.jivesoftware.smackx.shim.packet.Header; import org.jivesoftware.smackx.shim.packet.HeadersExtension; import org.jivesoftware.smackx.shim.provider.HeaderProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import java.io.IOException; import java.util.HashSet; import java.util.Set; @@ -33,7 +36,7 @@ import java.util.Set; * @author Andriy Tsykholyas * @see XEP-0332: HTTP over XMPP transport */ -public abstract class AbstractHttpOverXmppProvider implements IQProvider { +public abstract class AbstractHttpOverXmppProvider extends IQProvider { private static final String ELEMENT_HEADERS = "headers"; private static final String ELEMENT_HEADER = "header"; @@ -56,9 +59,11 @@ public abstract class AbstractHttpOverXmppProvider implements IQProvider { * @param parser parser * @param elementName name of concrete implementation of this element * @param body parent Body element - * @throws Exception if anything goes wrong + * @throws IOException + * @throws XmlPullParserException + * @throws SmackException */ - protected void parseHeadersAndData(XmlPullParser parser, String elementName, AbstractHttpOverXmpp.AbstractBody body) throws Exception { + protected void parseHeadersAndData(XmlPullParser parser, String elementName, AbstractHttpOverXmpp.AbstractBody body) throws XmlPullParserException, IOException, SmackException { boolean done = false; while (!done) { @@ -82,7 +87,7 @@ public abstract class AbstractHttpOverXmppProvider implements IQProvider { } } - private HeadersExtension parseHeaders(XmlPullParser parser) throws Exception { + private HeadersExtension parseHeaders(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException { HeaderProvider provider = new HeaderProvider(); Set
set = new HashSet
(); boolean done = false; @@ -92,7 +97,7 @@ public abstract class AbstractHttpOverXmppProvider implements IQProvider { if (eventType == XmlPullParser.START_TAG) { if (parser.getName().equals(ELEMENT_HEADER)) { - Header header = (Header) provider.parseExtension(parser); + Header header = provider.parse(parser); set.add(header); } } else if (eventType == XmlPullParser.END_TAG) { @@ -104,7 +109,7 @@ public abstract class AbstractHttpOverXmppProvider implements IQProvider { return new HeadersExtension(set); } - private AbstractHttpOverXmpp.Data parseData(XmlPullParser parser) throws Exception { + private AbstractHttpOverXmpp.Data parseData(XmlPullParser parser) throws XmlPullParserException, IOException { AbstractHttpOverXmpp.DataChild child = null; boolean done = false; @@ -143,7 +148,7 @@ public abstract class AbstractHttpOverXmppProvider implements IQProvider { return data; } - private AbstractHttpOverXmpp.Text parseText(XmlPullParser parser) throws Exception { + private AbstractHttpOverXmpp.Text parseText(XmlPullParser parser) throws XmlPullParserException, IOException { String text = null; boolean done = false; @@ -166,7 +171,7 @@ public abstract class AbstractHttpOverXmppProvider implements IQProvider { return new AbstractHttpOverXmpp.Text(text); } - private AbstractHttpOverXmpp.Xml parseXml(XmlPullParser parser) throws Exception { + private AbstractHttpOverXmpp.Xml parseXml(XmlPullParser parser) throws XmlPullParserException, IOException { StringBuilder builder = new StringBuilder(); boolean done = false; boolean startClosed = true; @@ -214,7 +219,7 @@ public abstract class AbstractHttpOverXmppProvider implements IQProvider { return new AbstractHttpOverXmpp.Xml(builder.toString()); } - private void appendXmlAttributes(XmlPullParser parser, StringBuilder builder) throws Exception { + private void appendXmlAttributes(XmlPullParser parser, StringBuilder builder) { // NOTE: for now we ignore namespaces int count = parser.getAttributeCount(); @@ -230,7 +235,7 @@ public abstract class AbstractHttpOverXmppProvider implements IQProvider { } } - private AbstractHttpOverXmpp.Base64 parseBase64(XmlPullParser parser) throws Exception { + private AbstractHttpOverXmpp.Base64 parseBase64(XmlPullParser parser) throws XmlPullParserException, IOException { String text = null; boolean done = false; @@ -254,7 +259,7 @@ public abstract class AbstractHttpOverXmppProvider implements IQProvider { return new AbstractHttpOverXmpp.Base64(text); } - private AbstractHttpOverXmpp.ChunkedBase64 parseChunkedBase64(XmlPullParser parser) throws Exception { + private AbstractHttpOverXmpp.ChunkedBase64 parseChunkedBase64(XmlPullParser parser) throws XmlPullParserException, IOException { String streamId = parser.getAttributeValue("", ATTRIBUTE_STREAM_ID); AbstractHttpOverXmpp.ChunkedBase64 child = new AbstractHttpOverXmpp.ChunkedBase64(streamId); boolean done = false; @@ -275,7 +280,7 @@ public abstract class AbstractHttpOverXmppProvider implements IQProvider { return child; } - private AbstractHttpOverXmpp.Ibb parseIbb(XmlPullParser parser) throws Exception { + private AbstractHttpOverXmpp.Ibb parseIbb(XmlPullParser parser) throws XmlPullParserException, IOException { String sid = parser.getAttributeValue("", ATTRIBUTE_SID); AbstractHttpOverXmpp.Ibb child = new AbstractHttpOverXmpp.Ibb(sid); boolean done = false; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/provider/Base64BinaryChunkProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/provider/Base64BinaryChunkProvider.java index d63701897..5f160aeb7 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/provider/Base64BinaryChunkProvider.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/provider/Base64BinaryChunkProvider.java @@ -16,10 +16,12 @@ */ package org.jivesoftware.smackx.hoxt.provider; -import org.jivesoftware.smack.packet.PacketExtension; +import java.io.IOException; + import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smackx.hoxt.packet.Base64BinaryChunk; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * Packet provider for base64 binary chunks. @@ -27,16 +29,10 @@ import org.xmlpull.v1.XmlPullParser; * @author Andriy Tsykholyas * @see XEP-0332: HTTP over XMPP transport */ -public class Base64BinaryChunkProvider implements PacketExtensionProvider { - - /** - * Required no-argument constructor. - */ - public Base64BinaryChunkProvider() { - } +public class Base64BinaryChunkProvider extends PacketExtensionProvider { @Override - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { + public Base64BinaryChunk parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { String streamId = parser.getAttributeValue("", Base64BinaryChunk.ATTRIBUTE_STREAM_ID); String nrString = parser.getAttributeValue("", Base64BinaryChunk.ATTRIBUTE_NR); String lastString = parser.getAttributeValue("", Base64BinaryChunk.ATTRIBUTE_LAST); diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/provider/HttpOverXmppReqProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/provider/HttpOverXmppReqProvider.java index ee140711e..9f2fbb505 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/provider/HttpOverXmppReqProvider.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/provider/HttpOverXmppReqProvider.java @@ -16,10 +16,13 @@ */ package org.jivesoftware.smackx.hoxt.provider; -import org.jivesoftware.smack.packet.IQ; +import java.io.IOException; + +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smackx.hoxt.packet.HttpMethod; import org.jivesoftware.smackx.hoxt.packet.HttpOverXmppReq; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * Req packet provider. @@ -27,7 +30,7 @@ import org.xmlpull.v1.XmlPullParser; * @author Andriy Tsykholyas * @see XEP-0332: HTTP over XMPP transport */ -public class HttpOverXmppReqProvider extends AbstractHttpOverXmppProvider { +public class HttpOverXmppReqProvider extends AbstractHttpOverXmppProvider { private static final String ELEMENT_REQ = "req"; @@ -42,7 +45,8 @@ public class HttpOverXmppReqProvider extends AbstractHttpOverXmppProvider { } @Override - public IQ parseIQ(XmlPullParser parser) throws Exception { + public HttpOverXmppReq parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException, SmackException { String method = parser.getAttributeValue("", ATTRIBUTE_METHOD); String resource = parser.getAttributeValue("", ATTRIBUTE_RESOURCE); String version = parser.getAttributeValue("", ATTRIBUTE_VERSION); diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/provider/HttpOverXmppRespProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/provider/HttpOverXmppRespProvider.java index 57e63562d..ed7d06ef1 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/provider/HttpOverXmppRespProvider.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/provider/HttpOverXmppRespProvider.java @@ -16,9 +16,12 @@ */ package org.jivesoftware.smackx.hoxt.provider; -import org.jivesoftware.smack.packet.IQ; +import java.io.IOException; + +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smackx.hoxt.packet.HttpOverXmppResp; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * Resp packet provider. @@ -26,21 +29,16 @@ import org.xmlpull.v1.XmlPullParser; * @author Andriy Tsykholyas * @see XEP-0332: HTTP over XMPP transport */ -public class HttpOverXmppRespProvider extends AbstractHttpOverXmppProvider { +public class HttpOverXmppRespProvider extends AbstractHttpOverXmppProvider { private static final String ELEMENT_RESP = "resp"; private static final String ATTRIBUTE_STATUS_MESSAGE = "statusMessage"; private static final String ATTRIBUTE_STATUS_CODE = "statusCode"; - /** - * Mandatory no argument constructor. - */ - public HttpOverXmppRespProvider() { - } - @Override - public IQ parseIQ(XmlPullParser parser) throws Exception { + public HttpOverXmppResp parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException, SmackException { String version = parser.getAttributeValue("", ATTRIBUTE_VERSION); String statusMessage = parser.getAttributeValue("", ATTRIBUTE_STATUS_MESSAGE); String statusCodeString = parser.getAttributeValue("", ATTRIBUTE_STATUS_CODE); diff --git a/smack-experimental/src/test/java/org/jivesoftware/smackx/carbons/CarbonTest.java b/smack-experimental/src/test/java/org/jivesoftware/smackx/carbons/CarbonTest.java index 30c81e6b7..df180ea44 100644 --- a/smack-experimental/src/test/java/org/jivesoftware/smackx/carbons/CarbonTest.java +++ b/smack-experimental/src/test/java/org/jivesoftware/smackx/carbons/CarbonTest.java @@ -52,7 +52,7 @@ public class CarbonTest extends ExperimentalInitializerTest { .asString(outputProperties); parser = PacketParserUtils.getParserFor(control); - cc = (CarbonExtension) new CarbonManagerProvider().parseExtension(parser); + cc = (CarbonExtension) new CarbonManagerProvider().parse(parser); fwd = cc.getForwarded(); // meta @@ -83,7 +83,7 @@ public class CarbonTest extends ExperimentalInitializerTest { .asString(outputProperties); parser = PacketParserUtils.getParserFor(control); - cc = (CarbonExtension) new CarbonManagerProvider().parseExtension(parser); + cc = (CarbonExtension) new CarbonManagerProvider().parse(parser); assertEquals(CarbonExtension.Direction.received, cc.getDirection()); @@ -102,6 +102,6 @@ public class CarbonTest extends ExperimentalInitializerTest { .asString(outputProperties); parser = PacketParserUtils.getParserFor(control); - new CarbonManagerProvider().parseExtension(parser); + new CarbonManagerProvider().parse(parser); } } diff --git a/smack-experimental/src/test/java/org/jivesoftware/smackx/hoxt/provider/AbstractHttpOverXmppProviderTest.java b/smack-experimental/src/test/java/org/jivesoftware/smackx/hoxt/provider/AbstractHttpOverXmppProviderTest.java index 5ccf1fba3..4d6df0874 100644 --- a/smack-experimental/src/test/java/org/jivesoftware/smackx/hoxt/provider/AbstractHttpOverXmppProviderTest.java +++ b/smack-experimental/src/test/java/org/jivesoftware/smackx/hoxt/provider/AbstractHttpOverXmppProviderTest.java @@ -52,10 +52,10 @@ public class AbstractHttpOverXmppProviderTest { expectedHeaders.put("Allow", "OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE"); expectedHeaders.put("Content-Length", "0"); - AbstractHttpOverXmppProvider provider = new HttpOverXmppRespProvider(); + HttpOverXmppRespProvider provider = new HttpOverXmppRespProvider(); XmlPullParser parser = PacketParserUtils.getParserFor(string); - IQ iq = provider.parseIQ(parser); + IQ iq = provider.parse(parser); assertTrue(iq instanceof HttpOverXmppResp); AbstractHttpOverXmpp.AbstractBody body = ((HttpOverXmppResp) iq).getResp(); @@ -72,10 +72,10 @@ public class AbstractHttpOverXmppProviderTest { Map expectedHeaders = new HashMap(); expectedHeaders.put("Host", "clayster.com"); - AbstractHttpOverXmppProvider provider = new HttpOverXmppReqProvider(); + HttpOverXmppReqProvider provider = new HttpOverXmppReqProvider(); XmlPullParser parser = PacketParserUtils.getParserFor(string); - IQ iq = provider.parseIQ(parser); + IQ iq = provider.parse(parser); assertTrue(iq instanceof HttpOverXmppReq); AbstractHttpOverXmpp.AbstractBody body = ((HttpOverXmppReq) iq).getReq(); @@ -181,10 +181,10 @@ public class AbstractHttpOverXmppProviderTest { } private AbstractHttpOverXmpp.AbstractBody parseAbstractBody(String string, String tag) throws Exception { - AbstractHttpOverXmppProvider provider = new HttpOverXmppRespProvider(); + HttpOverXmppRespProvider provider = new HttpOverXmppRespProvider(); XmlPullParser parser = PacketParserUtils.getParserFor(string, tag); - IQ iq = provider.parseIQ(parser); + IQ iq = provider.parse(parser); assertTrue(iq instanceof HttpOverXmppResp); AbstractHttpOverXmpp.AbstractBody body = ((HttpOverXmppResp) iq).getResp(); return body; diff --git a/smack-experimental/src/test/java/org/jivesoftware/smackx/hoxt/provider/Base64BinaryChunkProviderTest.java b/smack-experimental/src/test/java/org/jivesoftware/smackx/hoxt/provider/Base64BinaryChunkProviderTest.java index 25fd3aff5..a96bcca5b 100644 --- a/smack-experimental/src/test/java/org/jivesoftware/smackx/hoxt/provider/Base64BinaryChunkProviderTest.java +++ b/smack-experimental/src/test/java/org/jivesoftware/smackx/hoxt/provider/Base64BinaryChunkProviderTest.java @@ -39,7 +39,7 @@ public class Base64BinaryChunkProviderTest { Base64BinaryChunkProvider provider = new Base64BinaryChunkProvider(); XmlPullParser parser = PacketParserUtils.getParserFor(string); - PacketExtension extension = provider.parseExtension(parser); + PacketExtension extension = provider.parse(parser); assertTrue(extension instanceof Base64BinaryChunk); Base64BinaryChunk chunk = (Base64BinaryChunk) extension; @@ -57,7 +57,7 @@ public class Base64BinaryChunkProviderTest { Base64BinaryChunkProvider provider = new Base64BinaryChunkProvider(); XmlPullParser parser = PacketParserUtils.getParserFor(string); - PacketExtension extension = provider.parseExtension(parser); + PacketExtension extension = provider.parse(parser); assertTrue(extension instanceof Base64BinaryChunk); Base64BinaryChunk chunk = (Base64BinaryChunk) extension; diff --git a/smack-experimental/src/test/java/org/jivesoftware/smackx/hoxt/provider/HttpOverXmppReqProviderTest.java b/smack-experimental/src/test/java/org/jivesoftware/smackx/hoxt/provider/HttpOverXmppReqProviderTest.java index 5f3120582..48e666279 100644 --- a/smack-experimental/src/test/java/org/jivesoftware/smackx/hoxt/provider/HttpOverXmppReqProviderTest.java +++ b/smack-experimental/src/test/java/org/jivesoftware/smackx/hoxt/provider/HttpOverXmppReqProviderTest.java @@ -68,7 +68,7 @@ public class HttpOverXmppReqProviderTest { private HttpOverXmppReq.Req parseReq(String string) throws Exception { HttpOverXmppReqProvider provider = new HttpOverXmppReqProvider(); XmlPullParser parser = PacketParserUtils.getParserFor(string); - IQ iq = provider.parseIQ(parser); + IQ iq = provider.parse(parser); assertTrue(iq instanceof HttpOverXmppReq); HttpOverXmppReq castedIq = (HttpOverXmppReq) iq; return castedIq.getReq(); diff --git a/smack-experimental/src/test/java/org/jivesoftware/smackx/hoxt/provider/HttpOverXmppRespProviderTest.java b/smack-experimental/src/test/java/org/jivesoftware/smackx/hoxt/provider/HttpOverXmppRespProviderTest.java index 5270c0f4f..867b51a6c 100644 --- a/smack-experimental/src/test/java/org/jivesoftware/smackx/hoxt/provider/HttpOverXmppRespProviderTest.java +++ b/smack-experimental/src/test/java/org/jivesoftware/smackx/hoxt/provider/HttpOverXmppRespProviderTest.java @@ -37,7 +37,7 @@ public class HttpOverXmppRespProviderTest { HttpOverXmppRespProvider provider = new HttpOverXmppRespProvider(); XmlPullParser parser = PacketParserUtils.getParserFor(string); - IQ iq = provider.parseIQ(parser); + IQ iq = provider.parse(parser); assertTrue(iq instanceof HttpOverXmppResp); HttpOverXmppResp castedIq = (HttpOverXmppResp) iq; HttpOverXmppResp.Resp resp = castedIq.getResp(); @@ -53,7 +53,7 @@ public class HttpOverXmppRespProviderTest { HttpOverXmppRespProvider provider = new HttpOverXmppRespProvider(); XmlPullParser parser = PacketParserUtils.getParserFor(string); - IQ iq = provider.parseIQ(parser); + IQ iq = provider.parse(parser); assertTrue(iq instanceof HttpOverXmppResp); HttpOverXmppResp castedIq = (HttpOverXmppResp) iq; HttpOverXmppResp.Resp resp = castedIq.getResp(); diff --git a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/pubsub/CarExtensionProvider.java b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/pubsub/CarExtensionProvider.java index e3ae8c514..e250fe874 100644 --- a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/pubsub/CarExtensionProvider.java +++ b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/pubsub/CarExtensionProvider.java @@ -25,10 +25,10 @@ import org.xmlpull.v1.XmlPullParser; * @author Robin Collier * */ -public class CarExtensionProvider implements PacketExtensionProvider +public class CarExtensionProvider extends PacketExtensionProvider { - public PacketExtension parseExtension(XmlPullParser parser) throws Exception + public PacketExtension parse(XmlPullParser parser, int initialDepth) throws Exception { String color = null; int numTires = 0; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/address/provider/MultipleAddressesProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/address/provider/MultipleAddressesProvider.java index 727f8a91e..25fec9ff8 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/address/provider/MultipleAddressesProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/address/provider/MultipleAddressesProvider.java @@ -17,27 +17,24 @@ package org.jivesoftware.smackx.address.provider; -import org.jivesoftware.smack.packet.PacketExtension; +import java.io.IOException; + import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smackx.address.packet.MultipleAddresses; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * The MultipleAddressesProvider parses {@link MultipleAddresses} packets. * * @author Gaston Dombiak */ -public class MultipleAddressesProvider implements PacketExtensionProvider { +public class MultipleAddressesProvider extends PacketExtensionProvider { - /** - * Creates a new MultipleAddressesProvider. - * ProviderManager requires that every PacketExtensionProvider has a public, no-argument - * constructor. - */ - public MultipleAddressesProvider() { - } - - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { + @Override + public MultipleAddresses parse(XmlPullParser parser, + int initialDepth) throws XmlPullParserException, + IOException { boolean done = false; MultipleAddresses multipleAddresses = new MultipleAddresses(); while (!done) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/amp/provider/AMPExtensionProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/amp/provider/AMPExtensionProvider.java index 772b231b8..0d1d3c379 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/amp/provider/AMPExtensionProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/amp/provider/AMPExtensionProvider.java @@ -16,35 +16,32 @@ */ package org.jivesoftware.smackx.amp.provider; +import java.io.IOException; import java.util.logging.Logger; -import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smackx.amp.AMPDeliverCondition; import org.jivesoftware.smackx.amp.AMPExpireAtCondition; import org.jivesoftware.smackx.amp.AMPMatchResourceCondition; import org.jivesoftware.smackx.amp.packet.AMPExtension; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; -public class AMPExtensionProvider implements PacketExtensionProvider { +public class AMPExtensionProvider extends PacketExtensionProvider { private static final Logger LOGGER = Logger.getLogger(AMPExtensionProvider.class.getName()); - /** - * Creates a new AMPExtensionProvider. - * ProviderManager requires that every PacketExtensionProvider has a public, no-argument constructor - */ - public AMPExtensionProvider() {} - /** * Parses a AMPExtension packet (extension sub-packet). * * @param parser the XML parser, positioned at the starting element of the extension. * @return a PacketExtension. - * @throws Exception if a parsing error occurs. + * @throws IOException + * @throws XmlPullParserException */ @Override - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { + public AMPExtension parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException { final String from = parser.getAttributeValue(null, "from"); final String to = parser.getAttributeValue(null, "to"); final String statusString = parser.getAttributeValue(null, "status"); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/attention/packet/AttentionExtension.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/attention/packet/AttentionExtension.java index ed3854b1d..d7b667635 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/attention/packet/AttentionExtension.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/attention/packet/AttentionExtension.java @@ -80,17 +80,10 @@ public class AttentionExtension implements PacketExtension { * * @author Guus der Kinderen, guus.der.kinderen@gmail.com s */ - public static class Provider implements PacketExtensionProvider { + public static class Provider extends PacketExtensionProvider { - /* - * (non-Javadoc) - * - * @see - * org.jivesoftware.smack.provider.PacketExtensionProvider#parseExtension - * (org.xmlpull.v1.XmlPullParser) - */ - public PacketExtension parseExtension(XmlPullParser arg0) - throws Exception { + @Override + public AttentionExtension parse(XmlPullParser parser, int initialDepth) { return new AttentionExtension(); } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/Bookmarks.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/Bookmarks.java index 735ed17c7..31fc6b879 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/Bookmarks.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/Bookmarks.java @@ -215,7 +215,7 @@ public class Bookmarks implements PrivateData { super(); } - public PrivateData parsePrivateData(XmlPullParser parser) throws Exception { + public PrivateData parsePrivateData(XmlPullParser parser) throws XmlPullParserException, IOException { Bookmarks storage = new Bookmarks(); boolean done = false; @@ -265,7 +265,7 @@ public class Bookmarks implements PrivateData { return urlStore; } - private static BookmarkedConference getConferenceStorage(XmlPullParser parser) throws Exception { + private static BookmarkedConference getConferenceStorage(XmlPullParser parser) throws XmlPullParserException, IOException { String name = parser.getAttributeValue("", "name"); String autojoin = parser.getAttributeValue("", "autojoin"); String jid = parser.getAttributeValue("", "jid"); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/provider/CloseIQProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/provider/CloseIQProvider.java index 280210b75..24de1609e 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/provider/CloseIQProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/provider/CloseIQProvider.java @@ -16,7 +16,6 @@ */ package org.jivesoftware.smackx.bytestreams.ibb.provider; -import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smackx.bytestreams.ibb.packet.Close; import org.xmlpull.v1.XmlPullParser; @@ -26,9 +25,10 @@ import org.xmlpull.v1.XmlPullParser; * * @author Henning Staib */ -public class CloseIQProvider implements IQProvider { +public class CloseIQProvider extends IQProvider { - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public Close parse(XmlPullParser parser, int initialDepth) { String sid = parser.getAttributeValue("", "sid"); return new Close(sid); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/provider/DataPacketProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/provider/DataPacketProvider.java index 4fc8fdde2..a3375ba08 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/provider/DataPacketProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/provider/DataPacketProvider.java @@ -16,13 +16,13 @@ */ package org.jivesoftware.smackx.bytestreams.ibb.provider; -import org.jivesoftware.smack.packet.IQ; -import org.jivesoftware.smack.packet.PacketExtension; -import org.jivesoftware.smack.provider.IQProvider; -import org.jivesoftware.smack.provider.PacketExtensionProvider; +import java.io.IOException; + +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smackx.bytestreams.ibb.packet.Data; import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * Parses an In-Band Bytestream data packet which can be a packet extension of @@ -30,19 +30,33 @@ import org.xmlpull.v1.XmlPullParser; * * @author Henning Staib */ -public class DataPacketProvider implements PacketExtensionProvider, IQProvider { +public class DataPacketProvider { - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { - String sessionID = parser.getAttributeValue("", "sid"); - long seq = Long.parseLong(parser.getAttributeValue("", "seq")); - String data = parser.nextText(); - return new DataPacketExtension(sessionID, seq, data); + public static class IQProvider extends org.jivesoftware.smack.provider.IQProvider { + + private static final PacketExtensionProvider packetExtensionProvider = new PacketExtensionProvider(); + + @Override + public Data parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException, + SmackException { + DataPacketExtension data = packetExtensionProvider.parse(parser); + Data iq = new Data(data); + return iq; + } } - public IQ parseIQ(XmlPullParser parser) throws Exception { - DataPacketExtension data = (DataPacketExtension) parseExtension(parser); - IQ iq = new Data(data); - return iq; - } + public static class PacketExtensionProvider extends org.jivesoftware.smack.provider.PacketExtensionProvider { + @Override + public DataPacketExtension parse(XmlPullParser parser, + int initialDepth) throws XmlPullParserException, + IOException { + String sessionID = parser.getAttributeValue("", "sid"); + long seq = Long.parseLong(parser.getAttributeValue("", "seq")); + String data = parser.nextText(); + return new DataPacketExtension(sessionID, seq, data); + } + + } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/provider/OpenIQProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/provider/OpenIQProvider.java index 02a53bdd8..f3053ce1c 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/provider/OpenIQProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/provider/OpenIQProvider.java @@ -16,22 +16,24 @@ */ package org.jivesoftware.smackx.bytestreams.ibb.provider; +import java.io.IOException; import java.util.Locale; -import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType; import org.jivesoftware.smackx.bytestreams.ibb.packet.Open; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * Parses an In-Band Bytestream open packet. * * @author Henning Staib */ -public class OpenIQProvider implements IQProvider { +public class OpenIQProvider extends IQProvider { - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public Open parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { String sessionID = parser.getAttributeValue("", "sid"); int blockSize = Integer.parseInt(parser.getAttributeValue("", "block-size")); @@ -44,6 +46,8 @@ public class OpenIQProvider implements IQProvider { stanza = StanzaType.valueOf(stanzaValue.toUpperCase(Locale.US)); } + parser.next(); + return new Open(sessionID, blockSize, stanza); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/provider/BytestreamsProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/provider/BytestreamsProvider.java index 92c700483..18feb3228 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/provider/BytestreamsProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/provider/BytestreamsProvider.java @@ -16,19 +16,23 @@ */ package org.jivesoftware.smackx.bytestreams.socks5.provider; -import org.jivesoftware.smack.packet.IQ; +import java.io.IOException; + import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * Parses a bytestream packet. * * @author Alexander Wenckus */ -public class BytestreamsProvider implements IQProvider { +public class BytestreamsProvider extends IQProvider { - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public Bytestream parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException { boolean done = false; Bytestream toReturn = new Bytestream(); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/provider/CapsExtensionProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/provider/CapsExtensionProvider.java index 83bf78081..1835d5e10 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/provider/CapsExtensionProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/provider/CapsExtensionProvider.java @@ -19,17 +19,15 @@ package org.jivesoftware.smackx.caps.provider; import java.io.IOException; import org.jivesoftware.smack.SmackException; -import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.PacketExtensionProvider; -import org.jivesoftware.smack.provider.StreamFeatureProvider; import org.jivesoftware.smackx.caps.EntityCapsManager; import org.jivesoftware.smackx.caps.packet.CapsExtension; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; -public class CapsExtensionProvider implements PacketExtensionProvider, StreamFeatureProvider { +public class CapsExtensionProvider extends PacketExtensionProvider { - public PacketExtension parseExtension(XmlPullParser parser) throws XmlPullParserException, IOException, + public CapsExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException { String hash = null; String version = null; @@ -57,9 +55,4 @@ public class CapsExtensionProvider implements PacketExtensionProvider, StreamFea } } - @Override - public PacketExtension parseStreamFeature(XmlPullParser parser) throws XmlPullParserException, - IOException, SmackException { - return parseExtension(parser); - } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/chatstates/packet/ChatStateExtension.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/chatstates/packet/ChatStateExtension.java index fc2d4032c..3e6e456eb 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/chatstates/packet/ChatStateExtension.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/chatstates/packet/ChatStateExtension.java @@ -66,9 +66,10 @@ public class ChatStateExtension implements PacketExtension { return xml; } - public static class Provider implements PacketExtensionProvider { + public static class Provider extends PacketExtensionProvider { - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { + @Override + public ChatStateExtension parse(XmlPullParser parser, int initialDepth) { ChatState state; try { state = ChatState.valueOf(parser.getName()); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/provider/AdHocCommandDataProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/provider/AdHocCommandDataProvider.java index a2fc42205..541705258 100755 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/provider/AdHocCommandDataProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/provider/AdHocCommandDataProvider.java @@ -17,8 +17,9 @@ package org.jivesoftware.smackx.commands.provider; -import org.jivesoftware.smack.packet.IQ; -import org.jivesoftware.smack.packet.PacketExtension; +import java.io.IOException; + +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.packet.XMPPError; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.provider.PacketExtensionProvider; @@ -30,15 +31,18 @@ import org.jivesoftware.smackx.commands.AdHocCommandNote; import org.jivesoftware.smackx.xdata.packet.DataForm; import org.jivesoftware.smackx.xdata.provider.DataFormProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * The AdHocCommandDataProvider parses AdHocCommandData packets. * * @author Gabriel Guardincerri */ -public class AdHocCommandDataProvider implements IQProvider { +public class AdHocCommandDataProvider extends IQProvider { - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public AdHocCommandData parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException, SmackException { boolean done = false; AdHocCommandData adHocCommandData = new AdHocCommandData(); DataFormProvider dataFormProvider = new DataFormProvider(); @@ -93,7 +97,7 @@ public class AdHocCommandDataProvider implements IQProvider { adHocCommandData.addAction(AdHocCommand.Action.prev); } else if (elementName.equals("x") && namespace.equals("jabber:x:data")) { - adHocCommandData.setForm((DataForm) dataFormProvider.parseExtension(parser)); + adHocCommandData.setForm((DataForm) dataFormProvider.parse(parser)); } else if (parser.getName().equals("note")) { AdHocCommandNote.Type type = AdHocCommandNote.Type.valueOf( @@ -115,38 +119,44 @@ public class AdHocCommandDataProvider implements IQProvider { return adHocCommandData; } - public static class BadActionError implements PacketExtensionProvider { - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { + public static class BadActionError extends PacketExtensionProvider { + @Override + public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) { return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.badAction); } } - public static class MalformedActionError implements PacketExtensionProvider { - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { + public static class MalformedActionError extends PacketExtensionProvider { + @Override + public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) { return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.malformedAction); } } - public static class BadLocaleError implements PacketExtensionProvider { - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { + public static class BadLocaleError extends PacketExtensionProvider { + @Override + public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) { return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.badLocale); } } - public static class BadPayloadError implements PacketExtensionProvider { - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { + public static class BadPayloadError extends PacketExtensionProvider { + @Override + public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) { return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.badPayload); } } - public static class BadSessionIDError implements PacketExtensionProvider { - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { + public static class BadSessionIDError extends PacketExtensionProvider { + @Override + public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) { return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.badSessionid); } } - public static class SessionExpiredError implements PacketExtensionProvider { - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { + public static class SessionExpiredError extends PacketExtensionProvider { + @Override + public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) { return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.sessionExpired); } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/provider/AbstractDelayInformationProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/provider/AbstractDelayInformationProvider.java index 7f2448c99..991bb49aa 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/provider/AbstractDelayInformationProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/provider/AbstractDelayInformationProvider.java @@ -16,17 +16,22 @@ */ package org.jivesoftware.smackx.delay.provider; +import java.io.IOException; +import java.text.ParseException; import java.util.Date; -import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smackx.delay.packet.DelayInformation; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; -public abstract class AbstractDelayInformationProvider implements PacketExtensionProvider { +public abstract class AbstractDelayInformationProvider extends PacketExtensionProvider { @Override - public final PacketExtension parseExtension(XmlPullParser parser) throws Exception { + public final DelayInformation parse(XmlPullParser parser, + int initialDepth) throws XmlPullParserException, + IOException, SmackException { String stampString = (parser.getAttributeValue("", "stamp")); String from = parser.getAttributeValue("", "from"); String reason = null; @@ -46,10 +51,14 @@ public abstract class AbstractDelayInformationProvider implements PacketExtensio } else { parser.next(); } - assert(parser.getEventType() == XmlPullParser.END_TAG); - Date stamp = parseDate(stampString); + Date stamp; + try { + stamp = parseDate(stampString); + } catch (ParseException e) { + throw new SmackException(e); + } return new DelayInformation(stamp, from, reason); } - protected abstract Date parseDate(String string) throws Exception; + protected abstract Date parseDate(String string) throws ParseException; } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/provider/DiscoverInfoProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/provider/DiscoverInfoProvider.java index db0d7851e..29bcc6c28 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/provider/DiscoverInfoProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/provider/DiscoverInfoProvider.java @@ -17,20 +17,25 @@ package org.jivesoftware.smackx.disco.provider; -import org.jivesoftware.smack.packet.IQ; +import java.io.IOException; + +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smackx.disco.packet.DiscoverInfo; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * The DiscoverInfoProvider parses Service Discovery information packets. * * @author Gaston Dombiak */ -public class DiscoverInfoProvider implements IQProvider { +public class DiscoverInfoProvider extends IQProvider { - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public DiscoverInfo parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException, SmackException { DiscoverInfo discoverInfo = new DiscoverInfo(); boolean done = false; DiscoverInfo.Identity identity = null; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/provider/DiscoverItemsProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/provider/DiscoverItemsProvider.java index 8d17e8a69..cfec90a04 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/provider/DiscoverItemsProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/provider/DiscoverItemsProvider.java @@ -17,19 +17,23 @@ package org.jivesoftware.smackx.disco.provider; -import org.jivesoftware.smack.packet.IQ; +import java.io.IOException; + import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smackx.disco.packet.DiscoverItems; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * The DiscoverInfoProvider parses Service Discovery items packets. * * @author Gaston Dombiak */ -public class DiscoverItemsProvider implements IQProvider { +public class DiscoverItemsProvider extends IQProvider { - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public DiscoverItems parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException { DiscoverItems discoverItems = new DiscoverItems(); boolean done = false; DiscoverItems.Item item; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/forward/provider/ForwardedProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/forward/provider/ForwardedProvider.java index ce743b994..25ffb10e8 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/forward/provider/ForwardedProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/forward/provider/ForwardedProvider.java @@ -16,13 +16,16 @@ */ package org.jivesoftware.smackx.forward.provider; +import java.io.IOException; + +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.packet.Packet; -import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smackx.delay.packet.DelayInformation; import org.jivesoftware.smackx.forward.Forwarded; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * This class implements the {@link PacketExtensionProvider} to parse @@ -30,8 +33,10 @@ import org.xmlpull.v1.XmlPullParser; * * @author Georg Lukas */ -public class ForwardedProvider implements PacketExtensionProvider { - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { +public class ForwardedProvider extends PacketExtensionProvider { + + @Override + public Forwarded parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException { DelayInformation di = null; Packet packet = null; @@ -43,13 +48,13 @@ public class ForwardedProvider implements PacketExtensionProvider { di = (DelayInformation)PacketParserUtils.parsePacketExtension(parser.getName(), parser.getNamespace(), parser); else if (parser.getName().equals("message")) packet = PacketParserUtils.parseMessage(parser); - else throw new Exception("Unsupported forwarded packet type: " + parser.getName()); + else throw new SmackException("Unsupported forwarded packet type: " + parser.getName()); } else if (eventType == XmlPullParser.END_TAG && parser.getName().equals(Forwarded.ELEMENT)) done = true; } if (packet == null) - throw new Exception("forwarded extension must contain a packet"); + throw new SmackException("forwarded extension must contain a packet"); return new Forwarded(di, packet); } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqlast/packet/LastActivity.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqlast/packet/LastActivity.java index 321e232e9..d05eb8a8b 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqlast/packet/LastActivity.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqlast/packet/LastActivity.java @@ -100,13 +100,10 @@ public class LastActivity extends IQ { * * @author Derek DeMoro */ - public static class Provider implements IQProvider { + public static class Provider extends IQProvider { - public Provider() { - super(); - } - - public IQ parseIQ(XmlPullParser parser) throws SmackException, XmlPullParserException { + @Override + public LastActivity parse(XmlPullParser parser, int initialDepth) throws SmackException, XmlPullParserException { LastActivity lastActivity = new LastActivity(); String seconds = parser.getAttributeValue("", "seconds"); if (seconds != null) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/PrivateDataManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/PrivateDataManager.java index 8e57e8051..54916e6ce 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/PrivateDataManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/PrivateDataManager.java @@ -18,6 +18,7 @@ package org.jivesoftware.smackx.iqprivate; import org.jivesoftware.smack.Manager; +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.XMPPConnection; @@ -28,7 +29,9 @@ import org.jivesoftware.smackx.iqprivate.packet.DefaultPrivateData; import org.jivesoftware.smackx.iqprivate.packet.PrivateData; import org.jivesoftware.smackx.iqprivate.provider.PrivateDataProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import java.io.IOException; import java.util.Hashtable; import java.util.Map; import java.util.WeakHashMap; @@ -211,8 +214,11 @@ public class PrivateDataManager extends Manager { /** * An IQ provider to parse IQ results containing private data. */ - public static class PrivateDataIQProvider implements IQProvider { - public IQ parseIQ(XmlPullParser parser) throws Exception { + public static class PrivateDataIQProvider extends IQProvider { + + @Override + public PrivateDataResult parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException, SmackException { PrivateData privateData = null; boolean done = false; while (!done) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/provider/PrivateDataProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/provider/PrivateDataProvider.java index b5e1490ae..5e69e2201 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/provider/PrivateDataProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/provider/PrivateDataProvider.java @@ -17,7 +17,11 @@ package org.jivesoftware.smackx.iqprivate.provider; +import java.io.IOException; + import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smackx.iqprivate.packet.PrivateData; /** @@ -37,7 +41,6 @@ public interface PrivateDataProvider { * * @param parser an XML parser. * @return a new PrivateData instance. - * @throws Exception if an error occurs parsing the XML. */ - public PrivateData parsePrivateData(XmlPullParser parser) throws Exception; + public PrivateData parsePrivateData(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException; } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/provider/RegistrationProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/provider/RegistrationProvider.java index a6a1154ca..574eddc56 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/provider/RegistrationProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/provider/RegistrationProvider.java @@ -16,22 +16,26 @@ */ package org.jivesoftware.smackx.iqregister.provider; +import java.io.IOException; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smackx.iqregister.packet.Registration; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; -public class RegistrationProvider implements IQProvider { +public class RegistrationProvider extends IQProvider { @Override - public IQ parseIQ(XmlPullParser parser) throws Exception { + public Registration parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException, SmackException { String instruction = null; Map fields = new HashMap(); List packetExtensions = new LinkedList(); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/provider/RegistrationStreamFeatureProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/provider/RegistrationStreamFeatureProvider.java index 35726a14a..a1e54be3d 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/provider/RegistrationStreamFeatureProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/provider/RegistrationStreamFeatureProvider.java @@ -16,15 +16,14 @@ */ package org.jivesoftware.smackx.iqregister.provider; -import org.jivesoftware.smack.packet.PacketExtension; -import org.jivesoftware.smack.provider.StreamFeatureProvider; +import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smackx.iqregister.packet.Registration; import org.xmlpull.v1.XmlPullParser; -public class RegistrationStreamFeatureProvider implements StreamFeatureProvider { +public class RegistrationStreamFeatureProvider extends PacketExtensionProvider { @Override - public PacketExtension parseStreamFeature(XmlPullParser parser) { + public Registration.Feature parse(XmlPullParser parser, int initialDepth) { return Registration.Feature.INSTANCE; } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqversion/provider/VersionProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqversion/provider/VersionProvider.java index 350dcb24c..52b550cce 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqversion/provider/VersionProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqversion/provider/VersionProvider.java @@ -17,15 +17,18 @@ package org.jivesoftware.smackx.iqversion.provider; +import java.io.IOException; + import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smackx.iqversion.packet.Version; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; -public class VersionProvider implements IQProvider { - public IQ parseIQ(XmlPullParser parser) throws Exception { - assert (parser.getEventType() == XmlPullParser.START_TAG); - final int initalDepth = parser.getDepth(); +public class VersionProvider extends IQProvider { + + @Override + public Version parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { String name = null, version = null, os = null; outerloop: while (true) { @@ -46,7 +49,7 @@ public class VersionProvider implements IQProvider { } break; case XmlPullParser.END_TAG: - if (parser.getDepth() == initalDepth && parser.getName().equals(IQ.QUERY_ELEMENT)) { + if (parser.getDepth() == initialDepth && parser.getName().equals(IQ.QUERY_ELEMENT)) { break outerloop; } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jiveproperties/provider/JivePropertiesExtensionProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jiveproperties/provider/JivePropertiesExtensionProvider.java index 6d1a93a3d..986c41994 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jiveproperties/provider/JivePropertiesExtensionProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jiveproperties/provider/JivePropertiesExtensionProvider.java @@ -17,20 +17,21 @@ package org.jivesoftware.smackx.jiveproperties.provider; import java.io.ByteArrayInputStream; +import java.io.IOException; import java.io.ObjectInputStream; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; -import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smack.util.stringencoder.Base64; import org.jivesoftware.smackx.jiveproperties.JivePropertiesManager; import org.jivesoftware.smackx.jiveproperties.packet.JivePropertiesExtension; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; -public class JivePropertiesExtensionProvider implements PacketExtensionProvider { +public class JivePropertiesExtensionProvider extends PacketExtensionProvider { private static final Logger LOGGER = Logger.getLogger(JivePropertiesExtensionProvider.class.getName()); @@ -45,10 +46,13 @@ public class JivePropertiesExtensionProvider implements PacketExtensionProvider * * @param parser the XML parser, positioned at the start of a properties sub-packet. * @return a map of the properties. - * @throws Exception if an error occurs while parsing the properties. + * @throws IOException + * @throws XmlPullParserException */ @Override - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { + public JivePropertiesExtension parse(XmlPullParser parser, + int initialDepth) throws XmlPullParserException, + IOException { Map properties = new HashMap(); while (true) { int eventType = parser.next(); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/GroupChatInvitation.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/GroupChatInvitation.java index 5e74d4f30..f1d7216c6 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/GroupChatInvitation.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/GroupChatInvitation.java @@ -17,11 +17,14 @@ package org.jivesoftware.smackx.muc.packet; +import java.io.IOException; + import org.jivesoftware.smack.packet.Packet; import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smack.util.XmlStringBuilder; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * A group chat invitation packet extension, which is used to invite other @@ -125,8 +128,12 @@ public class GroupChatInvitation implements PacketExtension { return packet.getExtension(ELEMENT, NAMESPACE); } - public static class Provider implements PacketExtensionProvider { - public PacketExtension parseExtension (XmlPullParser parser) throws Exception { + public static class Provider extends PacketExtensionProvider { + + @Override + public GroupChatInvitation parse(XmlPullParser parser, + int initialDepth) throws XmlPullParserException, + IOException { String roomAddress = parser.getAttributeValue("", "jid"); // Advance to end of extension. parser.next(); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCAdminProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCAdminProvider.java index 9f37b2956..4aba2be68 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCAdminProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCAdminProvider.java @@ -17,19 +17,23 @@ package org.jivesoftware.smackx.muc.provider; -import org.jivesoftware.smack.packet.IQ; +import java.io.IOException; + import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smackx.muc.packet.MUCAdmin; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * The MUCAdminProvider parses MUCAdmin packets. (@see MUCAdmin) * * @author Gaston Dombiak */ -public class MUCAdminProvider implements IQProvider { +public class MUCAdminProvider extends IQProvider { - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public MUCAdmin parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException { MUCAdmin mucAdmin = new MUCAdmin(); boolean done = false; while (!done) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCOwnerProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCOwnerProvider.java index 5e4ba5b20..00c4236b0 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCOwnerProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCOwnerProvider.java @@ -17,20 +17,25 @@ package org.jivesoftware.smackx.muc.provider; -import org.jivesoftware.smack.packet.IQ; +import java.io.IOException; + +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smackx.muc.packet.MUCOwner; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * The MUCOwnerProvider parses MUCOwner packets. (@see MUCOwner) * * @author Gaston Dombiak */ -public class MUCOwnerProvider implements IQProvider { +public class MUCOwnerProvider extends IQProvider { - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public MUCOwner parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException, SmackException { MUCOwner mucOwner = new MUCOwner(); boolean done = false; while (!done) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCParserUtils.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCParserUtils.java index 51a6c5a39..c3f3f85fa 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCParserUtils.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCParserUtils.java @@ -16,14 +16,17 @@ */ package org.jivesoftware.smackx.muc.provider; +import java.io.IOException; + import org.jivesoftware.smackx.muc.MUCAffiliation; import org.jivesoftware.smackx.muc.MUCRole; import org.jivesoftware.smackx.muc.packet.Destroy; import org.jivesoftware.smackx.muc.packet.MUCItem; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; public class MUCParserUtils { - public static MUCItem parseItem(XmlPullParser parser) throws Exception { + public static MUCItem parseItem(XmlPullParser parser) throws XmlPullParserException, IOException { int initialDepth = parser.getDepth(); MUCAffiliation affiliation = MUCAffiliation.fromString(parser.getAttributeValue("", "affiliation")); String nick = parser.getAttributeValue("", "nick"); @@ -54,7 +57,7 @@ public class MUCParserUtils { return new MUCItem(affiliation, role, actor, reason, jid, nick); } - public static Destroy parseDestroy(XmlPullParser parser) throws Exception { + public static Destroy parseDestroy(XmlPullParser parser) throws XmlPullParserException, IOException { boolean done = false; Destroy destroy = new Destroy(); destroy.setJid(parser.getAttributeValue("", "jid")); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCUserProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCUserProvider.java index 85ebe70f3..ba670e6f2 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCUserProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCUserProvider.java @@ -18,10 +18,12 @@ package org.jivesoftware.smackx.muc.provider; -import org.jivesoftware.smack.packet.PacketExtension; +import java.io.IOException; + import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smackx.muc.packet.MUCUser; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * The MUCUserProvider parses packets with extended presence information about @@ -29,17 +31,18 @@ import org.xmlpull.v1.XmlPullParser; * * @author Gaston Dombiak */ -public class MUCUserProvider implements PacketExtensionProvider { +public class MUCUserProvider extends PacketExtensionProvider { /** * Parses a MUCUser packet (extension sub-packet). * * @param parser the XML parser, positioned at the starting element of the extension. * @return a PacketExtension. - * @throws Exception if a parsing error occurs. + * @throws IOException + * @throws XmlPullParserException */ - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { - final int initialDepth = parser.getDepth(); + @Override + public MUCUser parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { MUCUser mucUser = new MUCUser(); outerloop: while (true) { switch (parser.next()) { @@ -77,7 +80,7 @@ public class MUCUserProvider implements PacketExtensionProvider { return mucUser; } - private static MUCUser.Invite parseInvite(XmlPullParser parser) throws Exception { + private static MUCUser.Invite parseInvite(XmlPullParser parser) throws XmlPullParserException, IOException { boolean done = false; MUCUser.Invite invite = new MUCUser.Invite(); invite.setFrom(parser.getAttributeValue("", "from")); @@ -98,7 +101,7 @@ public class MUCUserProvider implements PacketExtensionProvider { return invite; } - private static MUCUser.Decline parseDecline(XmlPullParser parser) throws Exception { + private static MUCUser.Decline parseDecline(XmlPullParser parser) throws XmlPullParserException, IOException { boolean done = false; MUCUser.Decline decline = new MUCUser.Decline(); decline.setFrom(parser.getAttributeValue("", "from")); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/nick/packet/Nick.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/nick/packet/Nick.java index 34b91fe11..7cd01d42a 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/nick/packet/Nick.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/nick/packet/Nick.java @@ -16,9 +16,12 @@ */ package org.jivesoftware.smackx.nick.packet; +import java.io.IOException; + import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * A minimalistic implementation of a {@link PacketExtension} for nicknames. @@ -91,11 +94,12 @@ public class Nick implements PacketExtension { return buf.toString(); } - public static class Provider implements PacketExtensionProvider { + public static class Provider extends PacketExtensionProvider { + + @Override + public Nick parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException { - public PacketExtension parseExtension(XmlPullParser parser) - throws Exception { - parser.next(); final String name = parser.getText(); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/offline/packet/OfflineMessageInfo.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/offline/packet/OfflineMessageInfo.java index 73e4ab2fa..8500b8ab4 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/offline/packet/OfflineMessageInfo.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/offline/packet/OfflineMessageInfo.java @@ -17,9 +17,12 @@ package org.jivesoftware.smackx.offline.packet; +import java.io.IOException; + import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * OfflineMessageInfo is an extension included in the retrieved offline messages requested by @@ -85,25 +88,20 @@ public class OfflineMessageInfo implements PacketExtension { return buf.toString(); } - public static class Provider implements PacketExtensionProvider { - - /** - * Creates a new Provider. - * ProviderManager requires that every PacketExtensionProvider has a public, - * no-argument constructor - */ - public Provider() { - } + public static class Provider extends PacketExtensionProvider { /** * Parses a OfflineMessageInfo packet (extension sub-packet). * * @param parser the XML parser, positioned at the starting element of the extension. * @return a PacketExtension. - * @throws Exception if a parsing error occurs. + * @throws IOException + * @throws XmlPullParserException */ - public PacketExtension parseExtension(XmlPullParser parser) - throws Exception { + @Override + public OfflineMessageInfo parse(XmlPullParser parser, + int initialDepth) throws XmlPullParserException, + IOException { OfflineMessageInfo info = new OfflineMessageInfo(); boolean done = false; while (!done) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/offline/packet/OfflineMessageRequest.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/offline/packet/OfflineMessageRequest.java index 75a15230d..ee9bb9829 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/offline/packet/OfflineMessageRequest.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/offline/packet/OfflineMessageRequest.java @@ -20,7 +20,9 @@ package org.jivesoftware.smackx.offline.packet; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -187,9 +189,12 @@ public class OfflineMessageRequest extends IQ { } } - public static class Provider implements IQProvider { + public static class Provider extends IQProvider { - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public OfflineMessageRequest parse(XmlPullParser parser, + int initialDepth) throws XmlPullParserException, + IOException { OfflineMessageRequest request = new OfflineMessageRequest(); boolean done = false; while (!done) { @@ -214,7 +219,8 @@ public class OfflineMessageRequest extends IQ { return request; } - private Item parseItem(XmlPullParser parser) throws Exception { + private Item parseItem(XmlPullParser parser) + throws XmlPullParserException, IOException { boolean done = false; Item item = new Item(parser.getAttributeValue("", "node")); item.setAction(parser.getAttributeValue("", "action")); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/provider/PEPProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/provider/PEPProvider.java index 02e2796e2..e19f0b773 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/provider/PEPProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/provider/PEPProvider.java @@ -17,12 +17,15 @@ package org.jivesoftware.smackx.pep.provider; +import java.io.IOException; import java.util.HashMap; import java.util.Map; +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * @@ -38,19 +41,11 @@ import org.xmlpull.v1.XmlPullParser; * * @author Jeff Williams */ -public class PEPProvider implements PacketExtensionProvider { +public class PEPProvider extends PacketExtensionProvider { - Map nodeParsers = new HashMap(); - PacketExtension pepItem; - - /** - * Creates a new PEPProvider. - * ProviderManager requires that every PacketExtensionProvider has a public, no-argument constructor - */ - public PEPProvider() { - } + private static final Map> nodeParsers = new HashMap>(); - public void registerPEPParserExtension(String node, PacketExtensionProvider pepItemParser) { + public static void registerPEPParserExtension(String node, PacketExtensionProvider pepItemParser) { nodeParsers.put(node, pepItemParser); } @@ -60,10 +55,14 @@ public class PEPProvider implements PacketExtensionProvider { * * @param parser the XML parser, positioned at the starting element of the extension. * @return a PacketExtension. - * @throws Exception if a parsing error occurs. + * @throws IOException + * @throws XmlPullParserException + * @throws SmackException */ - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { - + @Override + public PacketExtension parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException, SmackException { + PacketExtension pepItem = null; boolean done = false; while (!done) { int eventType = parser.next(); @@ -73,9 +72,9 @@ public class PEPProvider implements PacketExtensionProvider { // Figure out the node for this event. String node = parser.getAttributeValue("", "node"); // Get the parser for this kind of node, and if found then parse the node. - PacketExtensionProvider nodeParser = nodeParsers.get(node); + PacketExtensionProvider nodeParser = nodeParsers.get(node); if (nodeParser != null) { - pepItem = nodeParser.parseExtension(parser); + pepItem = nodeParser.parse(parser); } } } else if (eventType == XmlPullParser.END_TAG) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/ping/provider/PingProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/ping/provider/PingProvider.java index 1a9222f1f..c1e46dfa9 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/ping/provider/PingProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/ping/provider/PingProvider.java @@ -16,14 +16,17 @@ */ package org.jivesoftware.smackx.ping.provider; -import org.jivesoftware.smack.packet.IQ; +import java.io.IOException; + import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smackx.ping.packet.Ping; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; -public class PingProvider implements IQProvider { - - public IQ parseIQ(XmlPullParser parser) throws Exception { +public class PingProvider extends IQProvider { + + @Override + public Ping parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { // No need to use the ping constructor with arguments. IQ will already // have filled out all relevant fields ('from', 'to', 'id'). return new Ping(); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/provider/PrivacyProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/provider/PrivacyProvider.java index b6b3130a1..8f78dcb8d 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/provider/PrivacyProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/provider/PrivacyProvider.java @@ -17,12 +17,13 @@ package org.jivesoftware.smackx.privacy.provider; import org.jivesoftware.smack.packet.DefaultPacketExtension; -import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smackx.privacy.packet.Privacy; import org.jivesoftware.smackx.privacy.packet.PrivacyItem; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import java.io.IOException; import java.util.ArrayList; /** @@ -33,12 +34,11 @@ import java.util.ArrayList; * * @author Francisco Vives */ -public class PrivacyProvider implements IQProvider { +public class PrivacyProvider extends IQProvider { - public PrivacyProvider() { - } - - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public Privacy parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException { Privacy privacy = new Privacy(); /* privacy.addExtension(PacketParserUtils.parsePacketExtension(parser .getName(), parser.getNamespace(), parser)); */ @@ -78,7 +78,7 @@ public class PrivacyProvider implements IQProvider { } // Parse the list complex type - public void parseList(XmlPullParser parser, Privacy privacy) throws Exception { + public void parseList(XmlPullParser parser, Privacy privacy) throws XmlPullParserException, IOException { boolean done = false; String listName = parser.getAttributeValue("", "name"); ArrayList items = new ArrayList(); @@ -100,7 +100,7 @@ public class PrivacyProvider implements IQProvider { } // Parse the list complex type - public PrivacyItem parseItem(XmlPullParser parser) throws Exception { + public PrivacyItem parseItem(XmlPullParser parser) throws XmlPullParserException, IOException { boolean done = false; // Retrieves the required attributes String actionValue = parser.getAttributeValue("", "action"); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/AffiliationProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/AffiliationProvider.java index 6b91d93c8..df4659c75 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/AffiliationProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/AffiliationProvider.java @@ -29,10 +29,10 @@ import org.jivesoftware.smackx.pubsub.Affiliation; * * @author Robin Collier */ -public class AffiliationProvider extends EmbeddedExtensionProvider +public class AffiliationProvider extends EmbeddedExtensionProvider { @Override - protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) + protected Affiliation createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) { return new Affiliation(attributeMap.get("node"), Affiliation.Type.valueOf(attributeMap.get("affiliation"))); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/AffiliationsProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/AffiliationsProvider.java index f8ca651c3..35b4bde5c 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/AffiliationsProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/AffiliationsProvider.java @@ -29,11 +29,11 @@ import org.jivesoftware.smackx.pubsub.AffiliationsExtension; * as specified in the affiliation schema. * * @author Robin Collier - */public class AffiliationsProvider extends EmbeddedExtensionProvider + */public class AffiliationsProvider extends EmbeddedExtensionProvider { @SuppressWarnings("unchecked") @Override - protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) + protected AffiliationsExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) { return new AffiliationsExtension((List)content); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ConfigEventProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ConfigEventProvider.java index b2186dd61..8b2044732 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ConfigEventProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ConfigEventProvider.java @@ -31,10 +31,10 @@ import org.jivesoftware.smackx.xdata.packet.DataForm; * * @author Robin Collier */ -public class ConfigEventProvider extends EmbeddedExtensionProvider +public class ConfigEventProvider extends EmbeddedExtensionProvider { @Override - protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map attMap, List content) + protected ConfigurationEvent createReturnExtension(String currentElement, String currentNamespace, Map attMap, List content) { if (content.size() == 0) return new ConfigurationEvent(attMap.get("node")); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/EventProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/EventProvider.java index 8536d9027..621bab98a 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/EventProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/EventProvider.java @@ -31,10 +31,10 @@ import org.jivesoftware.smackx.pubsub.NodeExtension; * * @author Robin Collier */ -public class EventProvider extends EmbeddedExtensionProvider +public class EventProvider extends EmbeddedExtensionProvider { @Override - protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map attMap, List content) + protected EventElement createReturnExtension(String currentElement, String currentNamespace, Map attMap, List content) { return new EventElement(EventElementType.valueOf(content.get(0).getElementName()), (NodeExtension)content.get(0)); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/FormNodeProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/FormNodeProvider.java index a4235d01d..8bb2d0613 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/FormNodeProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/FormNodeProvider.java @@ -32,10 +32,10 @@ import org.jivesoftware.smackx.xdata.packet.DataForm; * * @author Robin Collier */ -public class FormNodeProvider extends EmbeddedExtensionProvider +public class FormNodeProvider extends EmbeddedExtensionProvider { @Override - protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) + protected FormNode createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) { return new FormNode(FormNodeType.valueOfFromElementName(currentElement, currentNamespace), attributeMap.get("node"), new Form((DataForm)content.iterator().next())); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java index 92cc6a313..42d961faa 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java @@ -16,6 +16,9 @@ */ package org.jivesoftware.smackx.pubsub.provider; +import java.io.IOException; + +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smack.provider.ProviderManager; @@ -25,6 +28,7 @@ import org.jivesoftware.smackx.pubsub.PayloadItem; import org.jivesoftware.smackx.pubsub.SimplePayload; import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * Parses an item element as is defined in both the {@link PubSubNamespace#BASIC} and @@ -34,10 +38,11 @@ import org.xmlpull.v1.XmlPullParser; * * @author Robin Collier */ -public class ItemProvider implements PacketExtensionProvider +public class ItemProvider extends PacketExtensionProvider { - public PacketExtension parseExtension(XmlPullParser parser) throws Exception - { + @Override + public Item parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException, SmackException { String id = parser.getAttributeValue(null, "id"); String node = parser.getAttributeValue(null, "node"); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemsProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemsProvider.java index 984874e86..4a13d86c3 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemsProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemsProvider.java @@ -29,11 +29,11 @@ import org.jivesoftware.smackx.pubsub.ItemsExtension; * * @author Robin Collier */ -public class ItemsProvider extends EmbeddedExtensionProvider +public class ItemsProvider extends EmbeddedExtensionProvider { @Override - protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) + protected ItemsExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) { return new ItemsExtension(ItemsExtension.ItemsElementType.items, attributeMap.get("node"), content); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/PubSubProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/PubSubProvider.java index a8d80ac2b..cff8d1187 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/PubSubProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/PubSubProvider.java @@ -16,6 +16,9 @@ */ package org.jivesoftware.smackx.pubsub.provider; +import java.io.IOException; + +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.IQProvider; @@ -23,6 +26,7 @@ import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smackx.pubsub.packet.PubSub; import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * Parses the root pubsub packet extensions of the {@link IQ} packet and returns @@ -30,10 +34,11 @@ import org.xmlpull.v1.XmlPullParser; * * @author Robin Collier */ -public class PubSubProvider implements IQProvider +public class PubSubProvider extends IQProvider { - public IQ parseIQ(XmlPullParser parser) throws Exception - { + @Override + public PubSub parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException, SmackException { PubSub pubsub = new PubSub(); String namespace = parser.getNamespace(); pubsub.setPubSubNamespace(PubSubNamespace.valueOfFromXmlns(namespace)); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/RetractEventProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/RetractEventProvider.java index a49ebe3fc..583422c72 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/RetractEventProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/RetractEventProvider.java @@ -30,10 +30,10 @@ import org.jivesoftware.smackx.pubsub.RetractItem; * * @author Robin Collier */ -public class RetractEventProvider extends EmbeddedExtensionProvider +public class RetractEventProvider extends EmbeddedExtensionProvider { @Override - protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) + protected RetractItem createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) { return new RetractItem(attributeMap.get("id")); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SimpleNodeProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SimpleNodeProvider.java index 2468a226b..0e586574c 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SimpleNodeProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SimpleNodeProvider.java @@ -30,10 +30,10 @@ import org.jivesoftware.smackx.pubsub.PubSubElementType; * * @author Robin Collier */ -public class SimpleNodeProvider extends EmbeddedExtensionProvider +public class SimpleNodeProvider extends EmbeddedExtensionProvider { @Override - protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) + protected NodeExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) { return new NodeExtension(PubSubElementType.valueOfFromElemName(currentElement, currentNamespace), attributeMap.get("node")); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SubscriptionProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SubscriptionProvider.java index f521e0577..8ae2d6981 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SubscriptionProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SubscriptionProvider.java @@ -16,10 +16,12 @@ */ package org.jivesoftware.smackx.pubsub.provider; -import org.jivesoftware.smack.packet.PacketExtension; +import java.io.IOException; + import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smackx.pubsub.Subscription; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * Parses the subscription element out of the pubsub IQ message from @@ -27,10 +29,11 @@ import org.xmlpull.v1.XmlPullParser; * * @author Robin Collier */ -public class SubscriptionProvider implements PacketExtensionProvider +public class SubscriptionProvider extends PacketExtensionProvider { - public PacketExtension parseExtension(XmlPullParser parser) throws Exception - { + @Override + public Subscription parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException { String jid = parser.getAttributeValue(null, "jid"); String nodeId = parser.getAttributeValue(null, "node"); String subId = parser.getAttributeValue(null, "subid"); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SubscriptionsProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SubscriptionsProvider.java index 33168bde2..e65878b0f 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SubscriptionsProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SubscriptionsProvider.java @@ -30,11 +30,11 @@ import org.jivesoftware.smackx.pubsub.SubscriptionsExtension; * * @author Robin Collier */ -public class SubscriptionsProvider extends EmbeddedExtensionProvider +public class SubscriptionsProvider extends EmbeddedExtensionProvider { @SuppressWarnings("unchecked") @Override - protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) + protected SubscriptionsExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) { return new SubscriptionsExtension(attributeMap.get("node"), (List)content); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceipt.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceipt.java index 1289966b1..3fa48fdec 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceipt.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceipt.java @@ -89,11 +89,11 @@ public class DeliveryReceipt implements PacketExtension /** * This Provider parses and returns DeliveryReceipt packets. */ - public static class Provider extends EmbeddedExtensionProvider + public static class Provider extends EmbeddedExtensionProvider { @Override - protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, + protected DeliveryReceipt createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) { return new DeliveryReceipt(attributeMap.get("id")); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptRequest.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptRequest.java index 0d04affcb..612be4575 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptRequest.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptRequest.java @@ -16,11 +16,14 @@ */ package org.jivesoftware.smackx.receipts; +import java.io.IOException; + import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Packet; import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * Represents a message delivery receipt request entry as specified by @@ -86,9 +89,11 @@ public class DeliveryReceiptRequest implements PacketExtension /** * This Provider parses and returns DeliveryReceiptRequest packets. */ - public static class Provider implements PacketExtensionProvider { + public static class Provider extends PacketExtensionProvider { @Override - public PacketExtension parseExtension(XmlPullParser parser) { + public DeliveryReceiptRequest parse(XmlPullParser parser, + int initialDepth) throws XmlPullParserException, + IOException { return new DeliveryReceiptRequest(); } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/rsm/provider/RSMSetProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/rsm/provider/RSMSetProvider.java index 1a57f33bd..c9668cf43 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/rsm/provider/RSMSetProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/rsm/provider/RSMSetProvider.java @@ -16,19 +16,19 @@ */ package org.jivesoftware.smackx.rsm.provider; -import org.jivesoftware.smack.packet.PacketExtension; +import java.io.IOException; + import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smackx.rsm.packet.RSMSet; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; -public class RSMSetProvider implements PacketExtensionProvider { +public class RSMSetProvider extends PacketExtensionProvider { @Override - public PacketExtension parseExtension(XmlPullParser parser) - throws Exception { - int initialDepth = parser.getDepth(); - + public RSMSet parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException { String after = null; String before = null; int count = -1; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/search/SimpleUserSearch.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/search/SimpleUserSearch.java index e38481af0..08a056771 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/search/SimpleUserSearch.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/search/SimpleUserSearch.java @@ -20,7 +20,9 @@ import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smackx.xdata.Form; import org.jivesoftware.smackx.xdata.FormField; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -84,7 +86,7 @@ class SimpleUserSearch extends IQ { } } - protected void parseItems(XmlPullParser parser) throws Exception { + protected void parseItems(XmlPullParser parser) throws XmlPullParserException, IOException { ReportedData data = new ReportedData(); data.addColumn(new ReportedData.Column("JID", "jid", "text-single")); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/search/UserSearch.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/search/UserSearch.java index 804594f0b..2f2e0634c 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/search/UserSearch.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/search/UserSearch.java @@ -16,6 +16,9 @@ */ package org.jivesoftware.smackx.search; +import java.io.IOException; + +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.XMPPConnection; @@ -28,6 +31,7 @@ import org.jivesoftware.smackx.xdata.Form; import org.jivesoftware.smackx.xdata.FormField; import org.jivesoftware.smackx.xdata.packet.DataForm; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * Implements the protocol currently used to search information repositories on the Jabber network. To date, the jabber:iq:search protocol @@ -124,16 +128,11 @@ public class UserSearch extends IQ { /** * Internal Search service Provider. */ - public static class Provider implements IQProvider { + public static class Provider extends IQProvider { - /** - * Provider Constructor. - */ - public Provider() { - super(); - } - - public IQ parseIQ(XmlPullParser parser) throws Exception { + // FIXME this provider does return two different types of IQs + @Override + public IQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException { UserSearch search = null; SimpleUserSearch simpleUserSearch = new SimpleUserSearch(); @@ -169,7 +168,9 @@ public class UserSearch extends IQ { } } - private static void buildDataForm(SimpleUserSearch search, String instructions, XmlPullParser parser) throws Exception { + private static void buildDataForm(SimpleUserSearch search, + String instructions, XmlPullParser parser) + throws XmlPullParserException, IOException, SmackException { DataForm dataForm = new DataForm(Form.TYPE_FORM); boolean done = false; dataForm.setTitle("User Search"); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/sharedgroups/packet/SharedGroupsInfo.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/sharedgroups/packet/SharedGroupsInfo.java index 4bde6e8c2..806073df6 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/sharedgroups/packet/SharedGroupsInfo.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/sharedgroups/packet/SharedGroupsInfo.java @@ -19,7 +19,9 @@ package org.jivesoftware.smackx.sharedgroups.packet; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -58,16 +60,11 @@ public class SharedGroupsInfo extends IQ { /** * Internal Search service Provider. */ - public static class Provider implements IQProvider { + public static class Provider extends IQProvider { - /** - * Provider Constructor. - */ - public Provider() { - super(); - } - - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public SharedGroupsInfo parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException { SharedGroupsInfo groupsInfo = new SharedGroupsInfo(); boolean done = false; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/shim/provider/HeaderProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/shim/provider/HeaderProvider.java index 75bc154c0..d039f2b9b 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/shim/provider/HeaderProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/shim/provider/HeaderProvider.java @@ -16,20 +16,23 @@ */ package org.jivesoftware.smackx.shim.provider; -import org.jivesoftware.smack.packet.PacketExtension; +import java.io.IOException; + import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smackx.shim.packet.Header; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * Parses the header element as defined in Stanza Headers and Internet Metadata (SHIM). * * @author Robin Collier */ -public class HeaderProvider implements PacketExtensionProvider +public class HeaderProvider extends PacketExtensionProvider
{ - public PacketExtension parseExtension(XmlPullParser parser) throws Exception - { + @Override + public Header parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException { String name = parser.getAttributeValue(null, "name"); String value = null; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/shim/provider/HeadersProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/shim/provider/HeadersProvider.java index 30d270ec4..494648750 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/shim/provider/HeadersProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/shim/provider/HeadersProvider.java @@ -30,11 +30,11 @@ import org.jivesoftware.smackx.shim.packet.HeadersExtension; * * @author Robin Collier */ -public class HeadersProvider extends EmbeddedExtensionProvider +public class HeadersProvider extends EmbeddedExtensionProvider { @SuppressWarnings("unchecked") @Override - protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) + protected HeadersExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) { return new HeadersExtension((Collection
)content); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/si/provider/StreamInitiationProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/si/provider/StreamInitiationProvider.java index 3f52adc8c..b26af9e84 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/si/provider/StreamInitiationProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/si/provider/StreamInitiationProvider.java @@ -16,12 +16,13 @@ */ package org.jivesoftware.smackx.si.provider; +import java.io.IOException; import java.text.ParseException; import java.util.Date; import java.util.logging.Level; import java.util.logging.Logger; -import org.jivesoftware.smack.packet.IQ; +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.provider.IQProvider; import org.jxmpp.util.XmppDateTime; import org.jivesoftware.smackx.si.packet.StreamInitiation; @@ -29,6 +30,7 @@ import org.jivesoftware.smackx.si.packet.StreamInitiation.File; import org.jivesoftware.smackx.xdata.packet.DataForm; import org.jivesoftware.smackx.xdata.provider.DataFormProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * The StreamInitiationProvider parses StreamInitiation packets. @@ -36,10 +38,12 @@ import org.xmlpull.v1.XmlPullParser; * @author Alexander Wenckus * */ -public class StreamInitiationProvider implements IQProvider { +public class StreamInitiationProvider extends IQProvider { private static final Logger LOGGER = Logger.getLogger(StreamInitiationProvider.class.getName()); - - public IQ parseIQ(final XmlPullParser parser) throws Exception { + + @Override + public StreamInitiation parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException, SmackException { boolean done = false; // si @@ -79,7 +83,7 @@ public class StreamInitiationProvider implements IQProvider { isRanged = true; } else if (elementName.equals("x") && namespace.equals("jabber:x:data")) { - form = (DataForm) dataFormProvider.parseExtension(parser); + form = dataFormProvider.parse(parser); } } else if (eventType == XmlPullParser.END_TAG) { if (elementName.equals("si")) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/provider/VCardProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/provider/VCardProvider.java index 788011baf..a87ca4123 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/provider/VCardProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/provider/VCardProvider.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smackx.vcardtemp.provider; -import org.jivesoftware.smack.packet.IQ; +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smackx.vcardtemp.packet.VCard; @@ -25,14 +25,17 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.Text; +import org.xml.sax.SAXException; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; import java.io.ByteArrayInputStream; import java.io.IOException; +import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; @@ -44,12 +47,13 @@ import java.util.logging.Logger; * @author Gaston Dombiak * @author Derek DeMoro */ -public class VCardProvider implements IQProvider { +public class VCardProvider extends IQProvider { private static final Logger LOGGER = Logger.getLogger(VCardProvider.class.getName()); private static final String PREFERRED_ENCODING = "UTF-8"; - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public VCard parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException { final StringBuilder sb = new StringBuilder(); try { int event = parser.getEventType(); @@ -82,7 +86,11 @@ public class VCardProvider implements IQProvider { } String xmlText = sb.toString(); - return createVCardFromXML(xmlText); + try { + return createVCardFromXML(xmlText); + } catch (SAXException | ParserConfigurationException e) { + throw new SmackException(e); + } } /** @@ -90,9 +98,12 @@ public class VCardProvider implements IQProvider { * * @param xml the xml representing a users vCard. * @return the VCard. - * @throws Exception if an exception occurs. + * @throws IOException + * @throws SAXException + * @throws UnsupportedEncodingException + * @throws ParserConfigurationException */ - public static VCard createVCardFromXML(String xml) throws Exception { + public static VCard createVCardFromXML(String xml) throws UnsupportedEncodingException, SAXException, IOException, ParserConfigurationException { VCard vCard = new VCard(); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/provider/DataFormProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/provider/DataFormProvider.java index 04ac1229d..ee277a842 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/provider/DataFormProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/provider/DataFormProvider.java @@ -17,14 +17,15 @@ package org.jivesoftware.smackx.xdata.provider; -import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.packet.RosterPacket; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smackx.xdata.FormField; import org.jivesoftware.smackx.xdata.packet.DataForm; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -33,16 +34,10 @@ import java.util.List; * * @author Gaston Dombiak */ -public class DataFormProvider implements PacketExtensionProvider { +public class DataFormProvider extends PacketExtensionProvider { - /** - * Creates a new DataFormProvider. - * ProviderManager requires that every PacketExtensionProvider has a public, no-argument constructor - */ - public DataFormProvider() { - } - - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { + @Override + public DataForm parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { boolean done = false; DataForm dataForm = new DataForm(parser.getAttributeValue("", "type")); while (!done) { @@ -76,7 +71,7 @@ public class DataFormProvider implements PacketExtensionProvider { return dataForm; } - private FormField parseField(XmlPullParser parser) throws Exception { + private FormField parseField(XmlPullParser parser) throws XmlPullParserException, IOException { boolean done = false; FormField formField = new FormField(parser.getAttributeValue("", "var")); formField.setLabel(parser.getAttributeValue("", "label")); @@ -105,7 +100,7 @@ public class DataFormProvider implements PacketExtensionProvider { return formField; } - private DataForm.Item parseItem(XmlPullParser parser) throws Exception { + private DataForm.Item parseItem(XmlPullParser parser) throws XmlPullParserException, IOException { boolean done = false; List fields = new ArrayList(); while (!done) { @@ -123,7 +118,7 @@ public class DataFormProvider implements PacketExtensionProvider { return new DataForm.Item(fields); } - private DataForm.ReportedData parseReported(XmlPullParser parser) throws Exception { + private DataForm.ReportedData parseReported(XmlPullParser parser) throws XmlPullParserException, IOException { boolean done = false; List fields = new ArrayList(); while (!done) { @@ -141,7 +136,7 @@ public class DataFormProvider implements PacketExtensionProvider { return new DataForm.ReportedData(fields); } - private FormField.Option parseOption(XmlPullParser parser) throws Exception { + private FormField.Option parseOption(XmlPullParser parser) throws XmlPullParserException, IOException { boolean done = false; FormField.Option option = null; String label = parser.getAttributeValue("", "label"); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/xhtmlim/provider/XHTMLExtensionProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/xhtmlim/provider/XHTMLExtensionProvider.java index a424b6b14..105a1f5b3 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/xhtmlim/provider/XHTMLExtensionProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/xhtmlim/provider/XHTMLExtensionProvider.java @@ -17,7 +17,6 @@ package org.jivesoftware.smackx.xhtmlim.provider; import org.jivesoftware.smack.packet.Message; -import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smackx.xhtmlim.packet.XHTMLExtension; @@ -31,12 +30,12 @@ import java.io.IOException; * * @author Florian Schmaus */ -public class XHTMLExtensionProvider implements PacketExtensionProvider { +public class XHTMLExtensionProvider extends PacketExtensionProvider { + @Override - public PacketExtension parseExtension(XmlPullParser parser) throws IOException, XmlPullParserException { + public XHTMLExtension parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException { XHTMLExtension xhtmlExtension = new XHTMLExtension(); - int startDepth = parser.getDepth(); while (true) { int eventType = parser.getEventType(); String name = parser.getName(); @@ -45,7 +44,7 @@ public class XHTMLExtensionProvider implements PacketExtensionProvider { xhtmlExtension.addBody(PacketParserUtils.parseElement(parser)); } } else if (eventType == XmlPullParser.END_TAG) { - if (name.equals(XHTMLExtension.ELEMENT) && parser.getDepth() <= startDepth) { + if (parser.getDepth() == initialDepth) { return xhtmlExtension; } } diff --git a/smack-extensions/src/main/resources/org.jivesoftware.smackx/extensions.providers b/smack-extensions/src/main/resources/org.jivesoftware.smackx/extensions.providers index 2d4d08994..1a517b9df 100644 --- a/smack-extensions/src/main/resources/org.jivesoftware.smackx/extensions.providers +++ b/smack-extensions/src/main/resources/org.jivesoftware.smackx/extensions.providers @@ -194,7 +194,7 @@ data http://jabber.org/protocol/ibb - org.jivesoftware.smackx.bytestreams.ibb.provider.DataPacketProvider + org.jivesoftware.smackx.bytestreams.ibb.provider.DataPacketProvider$IQProvider @@ -206,7 +206,7 @@ data http://jabber.org/protocol/ibb - org.jivesoftware.smackx.bytestreams.ibb.provider.DataPacketProvider + org.jivesoftware.smackx.bytestreams.ibb.provider.DataPacketProvider$PacketExtensionProvider diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/amp/AMPExtensionTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/amp/AMPExtensionTest.java index 7b54cd877..f7b8ef454 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/amp/AMPExtensionTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/amp/AMPExtensionTest.java @@ -70,7 +70,7 @@ public class AMPExtensionTest { assertEquals(XmlPullParser.START_TAG, parser.next()); assertEquals(AMPExtension.ELEMENT, parser.getName()); - PacketExtension extension = ampProvider.parseExtension(parser); + PacketExtension extension = ampProvider.parse(parser); assertTrue(extension instanceof AMPExtension); AMPExtension amp = (AMPExtension) extension; @@ -89,7 +89,7 @@ public class AMPExtensionTest { assertEquals(XmlPullParser.START_TAG, parser.next()); assertEquals(AMPExtension.ELEMENT, parser.getName()); - PacketExtension extension = ampProvider.parseExtension(parser); + PacketExtension extension = ampProvider.parse(parser); assertTrue(extension instanceof AMPExtension); AMPExtension amp = (AMPExtension) extension; diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/provider/OpenIQProviderTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/provider/OpenIQProviderTest.java index bec2ddfa7..481d4a66f 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/provider/OpenIQProviderTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/provider/OpenIQProviderTest.java @@ -53,7 +53,7 @@ public class OpenIQProviderTest { .asString(outputProperties); OpenIQProvider oip = new OpenIQProvider(); - Open open = (Open) oip.parseIQ(getParser(control)); + Open open = oip.parse(getParser(control)); assertEquals(StanzaType.IQ, open.getStanza()); } @@ -68,7 +68,7 @@ public class OpenIQProviderTest { .asString(outputProperties); OpenIQProvider oip = new OpenIQProvider(); - Open open = (Open) oip.parseIQ(getParser(control)); + Open open = oip.parse(getParser(control)); assertEquals(StanzaType.MESSAGE, open.getStanza()); } diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/delay/provider/DelayInformationTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/delay/provider/DelayInformationTest.java index 7722e81f2..a8510237a 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/delay/provider/DelayInformationTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/delay/provider/DelayInformationTest.java @@ -69,7 +69,7 @@ public class DelayInformationTest extends InitExtensions { .asString(outputProperties); parser = PacketParserUtils.getParserFor(control); - delayInfo = (DelayInformation) p.parseExtension(parser); + delayInfo = (DelayInformation) p.parse(parser); assertEquals("capulet.com", delayInfo.getFrom()); assertEquals(date, delayInfo.getStamp()); @@ -85,7 +85,7 @@ public class DelayInformationTest extends InitExtensions { .asString(outputProperties); parser = PacketParserUtils.getParserFor(control); - delayInfo = (DelayInformation) p.parseExtension(parser); + delayInfo = (DelayInformation) p.parse(parser); assertEquals("capulet.com", delayInfo.getFrom()); assertEquals(date, delayInfo.getStamp()); @@ -109,7 +109,7 @@ public class DelayInformationTest extends InitExtensions { .a("stamp", "2002-09-10T23:08:25.12Z") .asString(outputProperties); - delayInfo = (DelayInformation) p.parseExtension(PacketParserUtils.getParserFor(control)); + delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control)); GregorianCalendar cal = (GregorianCalendar) calendar.clone(); cal.add(Calendar.MILLISECOND, 12); @@ -122,7 +122,7 @@ public class DelayInformationTest extends InitExtensions { .a("stamp", "2002-09-10T23:08:25Z") .asString(outputProperties); - delayInfo = (DelayInformation) p.parseExtension(PacketParserUtils.getParserFor(control)); + delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control)); assertEquals(calendar.getTime(), delayInfo.getStamp()); @@ -133,7 +133,7 @@ public class DelayInformationTest extends InitExtensions { .a("stamp", "2002-9-10T23:08:25Z") .asString(outputProperties); - delayInfo = (DelayInformation) p.parseExtension(PacketParserUtils.getParserFor(control)); + delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control)); assertEquals(calendar.getTime(), delayInfo.getStamp()); } @@ -152,7 +152,7 @@ public class DelayInformationTest extends InitExtensions { .a("stamp", "20020910T23:08:25") .asString(outputProperties); - delayInfo = (DelayInformation) p.parseExtension(PacketParserUtils.getParserFor(control)); + delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control)); assertEquals(calendar.getTime(), delayInfo.getStamp()); @@ -172,7 +172,7 @@ public class DelayInformationTest extends InitExtensions { .a("stamp", dateFormat.format(dateInPast.getTime())) .asString(outputProperties); - delayInfo = (DelayInformation) p.parseExtension(PacketParserUtils.getParserFor(control)); + delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control)); assertEquals(dateInPast.getTime(), delayInfo.getStamp()); @@ -183,7 +183,7 @@ public class DelayInformationTest extends InitExtensions { .a("stamp", "200868T09:16:20") .asString(outputProperties); - delayInfo = (DelayInformation) p.parseExtension(PacketParserUtils.getParserFor(control)); + delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control)); Date controlDate = XmppDateTime.parseDate("2008-06-08T09:16:20.0Z"); assertEquals(controlDate, delayInfo.getStamp()); diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/forward/ForwardedTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/forward/ForwardedTest.java index 63ce74534..2b354d0f7 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/forward/ForwardedTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/forward/ForwardedTest.java @@ -47,7 +47,7 @@ public class ForwardedTest { .asString(outputProperties); parser = PacketParserUtils.getParserFor(control); - fwd = (Forwarded) new ForwardedProvider().parseExtension(parser); + fwd = (Forwarded) new ForwardedProvider().parse(parser); // no delay in packet assertEquals(null, fwd.getDelayInformation()); @@ -71,6 +71,6 @@ public class ForwardedTest { .asString(outputProperties); parser = PacketParserUtils.getParserFor(control); - new ForwardedProvider().parseExtension(parser); + new ForwardedProvider().parse(parser); } } diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/xhtmlim/provider/XHTMLExtensionProviderTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/xhtmlim/provider/XHTMLExtensionProviderTest.java index 3f13e251c..c81dc4ad7 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/xhtmlim/provider/XHTMLExtensionProviderTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/xhtmlim/provider/XHTMLExtensionProviderTest.java @@ -40,7 +40,7 @@ public class XHTMLExtensionProviderTest { parser.next(); XHTMLExtensionProvider provider = new XHTMLExtensionProvider(); - PacketExtension extension = provider.parseExtension(parser); + PacketExtension extension = provider.parse(parser, parser.getDepth()); assertThat(extension, instanceOf(XHTMLExtension.class)); XHTMLExtension attachmentsInfo = (XHTMLExtension) extension; diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/RTPBridge.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/RTPBridge.java index e82739564..292bb765a 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/RTPBridge.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/RTPBridge.java @@ -17,12 +17,14 @@ package org.jivesoftware.smackx.jingleold.nat; +import java.io.IOException; import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.util.Enumeration; import java.util.logging.Logger; +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.XMPPConnection; @@ -34,6 +36,7 @@ import org.jivesoftware.smack.provider.ProviderManager; import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; import org.jivesoftware.smackx.disco.packet.DiscoverInfo; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * RTPBridge IQ Packet used to request and retrieve a RTPBridge Candidates that can be used for a Jingle Media Transmission between two parties that are behind NAT. @@ -316,13 +319,12 @@ public class RTPBridge extends IQ { * * @author Thiago Rocha */ - public static class Provider implements IQProvider { + public static class Provider extends IQProvider { - public Provider() { - super(); - } - - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public RTPBridge parse(XmlPullParser parser, int initialDepth) + throws SmackException, XmlPullParserException, + IOException { boolean done = false; @@ -330,7 +332,7 @@ public class RTPBridge extends IQ { String elementName; if (!parser.getNamespace().equals(RTPBridge.NAMESPACE)) - throw new Exception("Not a RTP Bridge packet"); + throw new SmackException("Not a RTP Bridge packet"); RTPBridge iq = new RTPBridge(); diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/STUN.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/STUN.java index 053906e06..c5bd32149 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/STUN.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/STUN.java @@ -16,6 +16,7 @@ */ package org.jivesoftware.smackx.jingleold.nat; +import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.logging.Logger; @@ -32,6 +33,7 @@ import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; import org.jivesoftware.smackx.disco.packet.DiscoverInfo; import org.jivesoftware.smackx.disco.packet.DiscoverItems; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * STUN IQ Packet used to request and retrieve a STUN server and port to make p2p connections easier. STUN is usually used by Jingle Media Transmission between two parties that are behind NAT. @@ -119,13 +121,12 @@ public class STUN extends IQ { * * @author Thiago Rocha */ - public static class Provider implements IQProvider { + public static class Provider extends IQProvider { - public Provider() { - super(); - } - - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public STUN parse(XmlPullParser parser, int initialDepth) + throws SmackException, XmlPullParserException, + IOException { boolean done = false; @@ -133,7 +134,7 @@ public class STUN extends IQ { String elementName; if (!parser.getNamespace().equals(NAMESPACE)) - throw new Exception("Not a STUN packet"); + throw new SmackException("Not a STUN packet"); STUN iq = new STUN(); diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleError.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleError.java index c73229d66..7562165fb 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleError.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleError.java @@ -122,7 +122,7 @@ public class JingleError implements PacketExtension { return NAMESPACE; } - public static class Provider implements PacketExtensionProvider { + public static class Provider extends PacketExtensionProvider { private PacketExtension audioInfo; @@ -135,8 +135,8 @@ public class JingleError implements PacketExtension { /** * Parse a JingleDescription.Audio extension. */ - public PacketExtension parseExtension(final XmlPullParser parser) - throws Exception { + @Override + public PacketExtension parse(XmlPullParser parser, int initialDepth) { PacketExtension result = null; if (audioInfo != null) { diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentDescriptionProvider.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentDescriptionProvider.java index 263a7f8ce..720c9e421 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentDescriptionProvider.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentDescriptionProvider.java @@ -16,36 +16,30 @@ */ package org.jivesoftware.smackx.jingleold.provider; -import org.jivesoftware.smack.packet.PacketExtension; +import java.io.IOException; + +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smackx.jingleold.media.PayloadType; import org.jivesoftware.smackx.jingleold.packet.JingleContentDescription; import org.jivesoftware.smackx.jingleold.packet.JingleContentDescription.JinglePayloadType; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * Parser for a Jingle description * * @author Alvaro Saurin */ -public abstract class JingleContentDescriptionProvider implements PacketExtensionProvider { - - /** - * Default constructor - */ - public JingleContentDescriptionProvider() { - super(); - } +public abstract class JingleContentDescriptionProvider extends PacketExtensionProvider { /** * Parse a iq/jingle/description/payload-type element. * * @param parser the input to parse * @return a payload type element - * @throws Exception */ - protected JinglePayloadType parsePayload(final XmlPullParser parser) - throws Exception { + protected JinglePayloadType parsePayload(final XmlPullParser parser) { int ptId = 0; String ptName; int ptChannels = 0; @@ -70,9 +64,14 @@ public abstract class JingleContentDescriptionProvider implements PacketExtensio * * @param parser the input to parse * @return a description element - * @throws Exception + * @throws IOException + * @throws XmlPullParserException + * @throws SmackException */ - public PacketExtension parseExtension(final XmlPullParser parser) throws Exception { + @Override + public JingleContentDescription parse(XmlPullParser parser, + int initialDepth) throws XmlPullParserException, + IOException, SmackException { boolean done = false; JingleContentDescription desc = getInstance(); @@ -84,7 +83,7 @@ public abstract class JingleContentDescriptionProvider implements PacketExtensio if (name.equals(JingleContentDescription.JinglePayloadType.NODENAME)) { desc.addJinglePayloadType(parsePayload(parser)); } else { - throw new Exception("Unknow element \"" + name + "\" in content."); + throw new SmackException("Unknow element \"" + name + "\" in content."); } } else if (eventType == XmlPullParser.END_TAG) { if (name.equals(JingleContentDescription.NODENAME)) { @@ -106,18 +105,10 @@ public abstract class JingleContentDescriptionProvider implements PacketExtensio */ public static class Audio extends JingleContentDescriptionProvider { - /** - * Default constructor - */ - public Audio() { - super(); - } - /** * Parse an audio payload type. */ - public JinglePayloadType parsePayload(final XmlPullParser parser) - throws Exception { + public JinglePayloadType parsePayload(final XmlPullParser parser) { JinglePayloadType pte = super.parsePayload(parser); PayloadType.Audio pt = new PayloadType.Audio(pte.getPayloadType()); int ptClockRate = 0; diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentInfoProvider.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentInfoProvider.java index f0ab261f7..87f9555ca 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentInfoProvider.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentInfoProvider.java @@ -27,27 +27,14 @@ import org.xmlpull.v1.XmlPullParser; * * @author Alvaro Saurin */ -public class JingleContentInfoProvider implements PacketExtensionProvider { - - /** - * Creates a new provider. ProviderManager requires that every - * PacketExtensionProvider has a public, no-argument constructor - */ - public JingleContentInfoProvider() { - super(); - } - - public PacketExtension parseExtension(final XmlPullParser parser) throws Exception { - // This method must be overwritten by subclasses... - return null; - } +public class JingleContentInfoProvider { /** * JingleDescription.Audio info provider */ - public static class Audio extends JingleContentInfoProvider { + public static class Audio extends PacketExtensionProvider { - private PacketExtension audioInfo; + private final PacketExtension audioInfo; /** * Empty constructor. @@ -69,8 +56,8 @@ public class JingleContentInfoProvider implements PacketExtensionProvider { /** * Parse a JingleDescription.Audio extension. */ - public PacketExtension parseExtension(final XmlPullParser parser) - throws Exception { + @Override + public PacketExtension parse(XmlPullParser parser, int initialDepth) { PacketExtension result = null; if (audioInfo != null) { diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentProvider.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentProvider.java index 169abf187..1895512ae 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentProvider.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentProvider.java @@ -16,7 +16,6 @@ */ package org.jivesoftware.smackx.jingleold.provider; -import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smackx.jingleold.packet.JingleContent; import org.xmlpull.v1.XmlPullParser; @@ -26,30 +25,19 @@ import org.xmlpull.v1.XmlPullParser; * * @author Jeff Williams */ -public class JingleContentProvider implements PacketExtensionProvider { - - /** - * Creates a new provider. ProviderManager requires that every - * PacketExtensionProvider has a public, no-argument constructor - */ - public JingleContentProvider() { - super(); - } +public class JingleContentProvider extends PacketExtensionProvider { /** * Parse a JingleContent extension. */ - public PacketExtension parseExtension(final XmlPullParser parser) throws Exception { - PacketExtension result = null; - + @Override + public JingleContent parse(XmlPullParser parser, int initialDepth) { String elementName = parser.getName(); String creator = parser.getAttributeValue("", JingleContent.CREATOR); String name = parser.getAttributeValue("", JingleContent.NAME); // Try to get an Audio content info - result = new JingleContent(creator, name); - - return result; + return new JingleContent(creator, name); } } diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleDescriptionProvider.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleDescriptionProvider.java index 550b9ecd8..a4b7644fa 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleDescriptionProvider.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleDescriptionProvider.java @@ -16,25 +16,21 @@ */ package org.jivesoftware.smackx.jingleold.provider; -import org.jivesoftware.smack.packet.PacketExtension; +import java.io.IOException; + +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smackx.jingleold.media.PayloadType; import org.jivesoftware.smackx.jingleold.packet.JingleDescription; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * Parser for a Jingle description * * @author Alvaro Saurin */ -public abstract class JingleDescriptionProvider implements PacketExtensionProvider { - - /** - * Default constructor - */ - public JingleDescriptionProvider() { - super(); - } +public abstract class JingleDescriptionProvider extends PacketExtensionProvider { /** * Parse a iq/jingle/description/payload-type element. @@ -42,9 +38,8 @@ public abstract class JingleDescriptionProvider implements PacketExtensionProvid * @param parser * the input to parse * @return a payload type element - * @throws Exception */ - protected PayloadType parsePayload(final XmlPullParser parser) throws Exception { + protected PayloadType parsePayload(final XmlPullParser parser) { int ptId = 0; String ptName; int ptChannels = 0; @@ -70,9 +65,11 @@ public abstract class JingleDescriptionProvider implements PacketExtensionProvid * @param parser * the input to parse * @return a description element - * @throws Exception + * @throws SmackException + * @throws IOException + * @throws XmlPullParserException */ - public PacketExtension parseExtension(final XmlPullParser parser) throws Exception { + public JingleDescription parse(XmlPullParser parser, int initialDepth) throws SmackException, XmlPullParserException, IOException { boolean done = false; JingleDescription desc = getInstance(); @@ -84,7 +81,7 @@ public abstract class JingleDescriptionProvider implements PacketExtensionProvid if (name.equals(PayloadType.NODENAME)) { desc.addPayloadType(parsePayload(parser)); } else { - throw new Exception("Unknow element \"" + name + "\" in content."); + throw new SmackException("Unknow element \"" + name + "\" in content."); } } else if (eventType == XmlPullParser.END_TAG) { if (name.equals(JingleDescription.NODENAME)) { @@ -106,17 +103,10 @@ public abstract class JingleDescriptionProvider implements PacketExtensionProvid */ public static class Audio extends JingleDescriptionProvider { - /** - * Default constructor - */ - public Audio() { - super(); - } - /** * Parse an audio payload type. */ - public PayloadType parsePayload(final XmlPullParser parser) throws Exception { + public PayloadType parsePayload(final XmlPullParser parser) { PayloadType pte = super.parsePayload(parser); PayloadType.Audio pt = new PayloadType.Audio(pte); int ptClockRate = 0; diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleProvider.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleProvider.java index 0b64a1eb9..1a9a41e19 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleProvider.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleProvider.java @@ -17,9 +17,11 @@ package org.jivesoftware.smackx.jingleold.provider; +import java.io.IOException; + import org.jivesoftware.smack.SmackException; -import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; +import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smackx.jingleold.JingleActionEnum; import org.jivesoftware.smackx.jingleold.packet.Jingle; import org.jivesoftware.smackx.jingleold.packet.JingleContent; @@ -27,26 +29,24 @@ import org.jivesoftware.smackx.jingleold.packet.JingleContentInfo; import org.jivesoftware.smackx.jingleold.packet.JingleDescription; import org.jivesoftware.smackx.jingleold.packet.JingleTransport; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * The JingleProvider parses Jingle packets. * * @author Alvaro Saurin */ -public class JingleProvider implements IQProvider { - - /** - * Creates a new provider. ProviderManager requires that every - * PacketExtensionProvider has a public, no-argument constructor - */ - public JingleProvider() { - super(); - } +public class JingleProvider extends IQProvider { /** * Parse a iq/jingle element. + * @throws IOException + * @throws XmlPullParserException + * @throws SmackException */ - public IQ parseIQ(final XmlPullParser parser) throws Exception { + @Override + public Jingle parse(XmlPullParser parser, int intialDepth) + throws XmlPullParserException, IOException, SmackException { Jingle jingle = new Jingle(); String sid = ""; @@ -61,7 +61,7 @@ public class JingleProvider implements IQProvider { JingleDescriptionProvider jdpAudio = new JingleDescriptionProvider.Audio(); JingleTransportProvider jtpRawUdp = new JingleTransportProvider.RawUdp(); JingleTransportProvider jtpIce = new JingleTransportProvider.Ice(); - JingleContentInfoProvider jmipAudio = new JingleContentInfoProvider.Audio(); + PacketExtensionProvider jmipAudio = new JingleContentInfoProvider.Audio(); int eventType; String elementName; @@ -91,24 +91,24 @@ public class JingleProvider implements IQProvider { if (elementName.equals(JingleContent.NODENAME)) { // Add a new element to the jingle - currentContent = (JingleContent) jcp.parseExtension(parser); + currentContent = (JingleContent) jcp.parse(parser); jingle.addContent(currentContent); } else if (elementName.equals(JingleDescription.NODENAME) && namespace.equals(JingleDescription.Audio.NAMESPACE)) { // Set the element of the - currentContent.setDescription((JingleDescription) jdpAudio.parseExtension(parser)); + currentContent.setDescription((JingleDescription) jdpAudio.parse(parser)); } else if (elementName.equals(JingleTransport.NODENAME)) { // Add all of the elements to the of the jingle // Parse the possible transport namespaces if (namespace.equals(JingleTransport.RawUdp.NAMESPACE)) { - currentContent.addJingleTransport((JingleTransport) jtpRawUdp.parseExtension(parser)); + currentContent.addJingleTransport((JingleTransport) jtpRawUdp.parse(parser)); } else if (namespace.equals(JingleTransport.Ice.NAMESPACE)) { - currentContent.addJingleTransport((JingleTransport) jtpIce.parseExtension(parser)); + currentContent.addJingleTransport((JingleTransport) jtpIce.parse(parser)); } else { throw new SmackException("Unknown transport namespace \"" + namespace + "\" in Jingle packet."); } } else if (namespace.equals(JingleContentInfo.Audio.NAMESPACE)) { - jingle.setContentInfo((JingleContentInfo) jmipAudio.parseExtension(parser)); + jingle.setContentInfo((JingleContentInfo) jmipAudio.parse(parser)); } else { throw new SmackException("Unknown combination of namespace \"" + namespace + "\" and element name \"" + elementName + "\" in Jingle packet."); diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleTransportProvider.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleTransportProvider.java index 16400ebad..fa5aaa7b3 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleTransportProvider.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleTransportProvider.java @@ -16,28 +16,23 @@ */ package org.jivesoftware.smackx.jingleold.provider; -import org.jivesoftware.smack.packet.PacketExtension; +import java.io.IOException; + +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smackx.jingleold.nat.ICECandidate; import org.jivesoftware.smackx.jingleold.nat.TransportCandidate; import org.jivesoftware.smackx.jingleold.packet.JingleTransport; import org.jivesoftware.smackx.jingleold.packet.JingleTransport.JingleTransportCandidate; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * Provider for a Jingle transport element * * @author Alvaro Saurin */ -public abstract class JingleTransportProvider implements PacketExtensionProvider { - - /** - * Creates a new provider. ProviderManager requires that every - * PacketExtensionProvider has a public, no-argument constructor - */ - public JingleTransportProvider() { - super(); - } +public abstract class JingleTransportProvider extends PacketExtensionProvider { /** * Obtain the corresponding TransportNegotiator instance. @@ -53,9 +48,12 @@ public abstract class JingleTransportProvider implements PacketExtensionProvider * * @param parser the structure to parse * @return a transport element. - * @throws Exception + * @throws IOException + * @throws XmlPullParserException + * @throws SmackException */ - public PacketExtension parseExtension(final XmlPullParser parser) throws Exception { + @Override + public JingleTransport parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException { boolean done = false; JingleTransport trans = getInstance(); @@ -69,7 +67,7 @@ public abstract class JingleTransportProvider implements PacketExtensionProvider if (jtc != null) trans.addCandidate(jtc); } else { - throw new Exception("Unknown tag \"" + name + "\" in transport element."); + throw new SmackException("Unknown tag \"" + name + "\" in transport element."); } } else if (eventType == XmlPullParser.END_TAG) { @@ -82,8 +80,7 @@ public abstract class JingleTransportProvider implements PacketExtensionProvider return trans; } - protected abstract JingleTransportCandidate parseCandidate(final XmlPullParser parser) - throws Exception; + protected abstract JingleTransportCandidate parseCandidate(final XmlPullParser parser); /** * RTP-ICE profile @@ -111,9 +108,8 @@ public abstract class JingleTransportProvider implements PacketExtensionProvider * * @param parser the structure to parse * @return a candidate element - * @throws Exception */ - protected JingleTransportCandidate parseCandidate(XmlPullParser parser) throws Exception { + protected JingleTransportCandidate parseCandidate(XmlPullParser parser) { ICECandidate mt = new ICECandidate(); String channel = parser.getAttributeValue("", "channel"); @@ -221,9 +217,8 @@ public abstract class JingleTransportProvider implements PacketExtensionProvider * * @param parser the structure to parse * @return a candidate element - * @throws Exception */ - protected JingleTransportCandidate parseCandidate(XmlPullParser parser) throws Exception { + protected JingleTransportCandidate parseCandidate(XmlPullParser parser) { TransportCandidate.Fixed mt = new TransportCandidate.Fixed(); String generation = parser.getAttributeValue("", "generation"); diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/OfferConfirmation.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/OfferConfirmation.java index b6531938b..2a1c2247b 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/OfferConfirmation.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/OfferConfirmation.java @@ -17,11 +17,14 @@ package org.jivesoftware.smackx.workgroup.agent; +import java.io.IOException; + import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; public class OfferConfirmation extends IQ { @@ -57,9 +60,11 @@ public class OfferConfirmation extends IQ { return buf.toString(); } - public static class Provider implements IQProvider { + public static class Provider extends IQProvider { - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public OfferConfirmation parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException { final OfferConfirmation confirmation = new OfferConfirmation(); boolean done = false; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/forms/WorkgroupForm.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/forms/WorkgroupForm.java index 8d3cbde57..e449335ff 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/forms/WorkgroupForm.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/forms/WorkgroupForm.java @@ -17,10 +17,14 @@ package org.jivesoftware.smackx.workgroup.ext.forms; +import java.io.IOException; + +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.PacketParserUtils; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; public class WorkgroupForm extends IQ { @@ -50,13 +54,12 @@ public class WorkgroupForm extends IQ { * * @author Derek DeMoro */ - public static class InternalProvider implements IQProvider { + public static class InternalProvider extends IQProvider { - public InternalProvider() { - super(); - } - - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public WorkgroupForm parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException, + SmackException { WorkgroupForm answer = new WorkgroupForm(); boolean done = false; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/history/AgentChatHistory.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/history/AgentChatHistory.java index 83767bdea..f20f055e2 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/history/AgentChatHistory.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/history/AgentChatHistory.java @@ -20,7 +20,9 @@ package org.jivesoftware.smackx.workgroup.ext.history; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Date; @@ -88,9 +90,10 @@ public class AgentChatHistory extends IQ { /** * Packet extension provider for AgentHistory packets. */ - public static class InternalProvider implements IQProvider { + public static class InternalProvider extends IQProvider { - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public AgentChatHistory parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { if (parser.getEventType() != XmlPullParser.START_TAG) { throw new IllegalStateException("Parser not in proper position, or bad XML."); } @@ -111,7 +114,7 @@ public class AgentChatHistory extends IQ { return agentChatHistory; } - private AgentChatSession parseChatSetting(XmlPullParser parser) throws Exception { + private AgentChatSession parseChatSetting(XmlPullParser parser) throws XmlPullParserException, IOException { boolean done = false; Date date = null; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/history/ChatMetadata.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/history/ChatMetadata.java index 10f0e4b04..1acc1d83a 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/history/ChatMetadata.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/history/ChatMetadata.java @@ -21,7 +21,9 @@ import org.jivesoftware.smackx.workgroup.util.MetaDataUtils; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -76,13 +78,11 @@ public class ChatMetadata extends IQ { * * @author Derek DeMoro */ - public static class Provider implements IQProvider { + public static class Provider extends IQProvider { - public Provider() { - super(); - } - - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public ChatMetadata parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException { final ChatMetadata chatM = new ChatMetadata(); boolean done = false; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/macros/Macros.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/macros/Macros.java index b3af9508f..bf8d4eb46 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/macros/Macros.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/macros/Macros.java @@ -17,11 +17,13 @@ package org.jivesoftware.smackx.workgroup.ext.macros; +import java.io.IOException; import java.io.StringReader; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.StringUtils; +import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserFactory; import org.xmlpull.v1.XmlPullParser; @@ -92,13 +94,10 @@ public class Macros extends IQ { * * @author Derek DeMoro */ - public static class InternalProvider implements IQProvider { + public static class InternalProvider extends IQProvider { - public InternalProvider() { - super(); - } - - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public Macros parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { Macros macroGroup = new Macros(); boolean done = false; @@ -121,7 +120,7 @@ public class Macros extends IQ { return macroGroup; } - public Macro parseMacro(XmlPullParser parser) throws Exception { + public Macro parseMacro(XmlPullParser parser) throws XmlPullParserException, IOException { Macro macro = new Macro(); boolean done = false; while (!done) { @@ -150,7 +149,7 @@ public class Macros extends IQ { return macro; } - public MacroGroup parseMacroGroup(XmlPullParser parser) throws Exception { + public MacroGroup parseMacroGroup(XmlPullParser parser) throws XmlPullParserException, IOException { MacroGroup group = new MacroGroup(); boolean done = false; @@ -176,7 +175,7 @@ public class Macros extends IQ { return group; } - public MacroGroup parseMacroGroups(String macros) throws Exception { + public MacroGroup parseMacroGroups(String macros) throws XmlPullParserException, IOException { MacroGroup group = null; XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser(); diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/notes/ChatNotes.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/notes/ChatNotes.java index 2733ba7e6..842d79e39 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/notes/ChatNotes.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/notes/ChatNotes.java @@ -17,10 +17,13 @@ package org.jivesoftware.smackx.workgroup.ext.notes; +import java.io.IOException; + import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.XmlStringBuilder; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * IQ packet for retrieving and adding Chat Notes. @@ -76,13 +79,10 @@ public class ChatNotes extends IQ { * * @author Derek DeMoro */ - public static class Provider implements IQProvider { + public static class Provider extends IQProvider { - public Provider() { - super(); - } - - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public ChatNotes parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { ChatNotes chatNotes = new ChatNotes(); boolean done = false; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/AgentInfo.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/AgentInfo.java index 4c4f36c5b..1826bf591 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/AgentInfo.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/AgentInfo.java @@ -17,9 +17,12 @@ package org.jivesoftware.smackx.workgroup.packet; +import java.io.IOException; + import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * IQ packet for retrieving and changing the Agent personal information. @@ -97,13 +100,10 @@ public class AgentInfo extends IQ { * * @author Gaston Dombiak */ - public static class Provider implements IQProvider { + public static class Provider extends IQProvider { - public Provider() { - super(); - } - - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public AgentInfo parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { AgentInfo answer = new AgentInfo(); boolean done = false; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/AgentStatus.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/AgentStatus.java index 51ae7bdca..360e595d6 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/AgentStatus.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/AgentStatus.java @@ -16,6 +16,7 @@ */ package org.jivesoftware.smackx.workgroup.packet; +import java.io.IOException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -28,6 +29,7 @@ import java.util.TimeZone; import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * Agent status packet. @@ -221,9 +223,10 @@ public class AgentStatus implements PacketExtension { /** * Packet extension provider for AgentStatus packets. */ - public static class Provider implements PacketExtensionProvider { + public static class Provider extends PacketExtensionProvider { - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { + @Override + public AgentStatus parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { AgentStatus agentStatus = new AgentStatus(); agentStatus.workgroupJID = parser.getAttributeValue("", "jid"); diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/AgentStatusRequest.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/AgentStatusRequest.java index 0da55cbfb..eab3501bd 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/AgentStatusRequest.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/AgentStatusRequest.java @@ -20,7 +20,9 @@ package org.jivesoftware.smackx.workgroup.packet; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import java.io.IOException; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; @@ -114,15 +116,12 @@ public class AgentStatusRequest extends IQ { /** * Packet extension provider for AgentStatusRequest packets. */ - public static class Provider implements IQProvider { + public static class Provider extends IQProvider { - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public AgentStatusRequest parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { AgentStatusRequest statusRequest = new AgentStatusRequest(); - if (parser.getEventType() != XmlPullParser.START_TAG) { - throw new IllegalStateException("Parser not in proper position, or bad XML."); - } - boolean done = false; while (!done) { int eventType = parser.next(); @@ -138,7 +137,7 @@ public class AgentStatusRequest extends IQ { return statusRequest; } - private Item parseAgent(XmlPullParser parser) throws Exception { + private Item parseAgent(XmlPullParser parser) throws XmlPullParserException, IOException { boolean done = false; String jid = parser.getAttributeValue("", "jid"); diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/AgentWorkgroups.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/AgentWorkgroups.java index ff99fbb2b..b2aabc9e5 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/AgentWorkgroups.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/AgentWorkgroups.java @@ -20,7 +20,9 @@ package org.jivesoftware.smackx.workgroup.packet; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; @@ -96,13 +98,10 @@ public class AgentWorkgroups extends IQ { * * @author Gaston Dombiak */ - public static class Provider implements IQProvider { + public static class Provider extends IQProvider { - public Provider() { - super(); - } - - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public AgentWorkgroups parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { String agentJID = parser.getAttributeValue("", "jid"); List workgroups = new ArrayList(); diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/MetaDataProvider.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/MetaDataProvider.java index 2cb58b697..4a1ad2c65 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/MetaDataProvider.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/MetaDataProvider.java @@ -17,29 +17,29 @@ package org.jivesoftware.smackx.workgroup.packet; +import java.io.IOException; import java.util.List; import java.util.Map; import org.jivesoftware.smackx.workgroup.MetaData; import org.jivesoftware.smackx.workgroup.util.MetaDataUtils; - -import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.PacketExtensionProvider; - import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * This provider parses meta data if it's not contained already in a larger extension provider. * * @author loki der quaeler */ -public class MetaDataProvider implements PacketExtensionProvider { +public class MetaDataProvider extends PacketExtensionProvider { /** * PacketExtensionProvider implementation + * @throws IOException + * @throws XmlPullParserException */ - public PacketExtension parseExtension (XmlPullParser parser) - throws Exception { + public MetaData parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { Map> metaData = MetaDataUtils.parseMetaData(parser); return new MetaData(metaData); diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/MonitorPacket.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/MonitorPacket.java index d846f4190..44e4a5d9f 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/MonitorPacket.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/MonitorPacket.java @@ -16,9 +16,12 @@ */ package org.jivesoftware.smackx.workgroup.packet; +import java.io.IOException; + import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; public class MonitorPacket extends IQ { @@ -79,13 +82,10 @@ public class MonitorPacket extends IQ { /** * Packet extension provider for Monitor Packets. */ - public static class InternalProvider implements IQProvider { - - public IQ parseIQ(XmlPullParser parser) throws Exception { - if (parser.getEventType() != XmlPullParser.START_TAG) { - throw new IllegalStateException("Parser not in proper position, or bad XML."); - } + public static class InternalProvider extends IQProvider { + @Override + public MonitorPacket parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { MonitorPacket packet = new MonitorPacket(); boolean done = false; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OccupantsInfo.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OccupantsInfo.java index b724d57f6..ee0d088f1 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OccupantsInfo.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OccupantsInfo.java @@ -17,6 +17,8 @@ package org.jivesoftware.smackx.workgroup.packet; +import java.io.IOException; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Collections; import java.util.Date; @@ -24,9 +26,11 @@ import java.util.HashSet; import java.util.Set; import java.util.TimeZone; +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * Packet used for requesting information about occupants of a room or for retrieving information @@ -126,12 +130,10 @@ public class OccupantsInfo extends IQ { /** * Packet extension provider for AgentStatusRequest packets. */ - public static class Provider implements IQProvider { + public static class Provider extends IQProvider { - public IQ parseIQ(XmlPullParser parser) throws Exception { - if (parser.getEventType() != XmlPullParser.START_TAG) { - throw new IllegalStateException("Parser not in proper position, or bad XML."); - } + @Override + public OccupantsInfo parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { OccupantsInfo occupantsInfo = new OccupantsInfo(parser.getAttributeValue("", "roomID")); boolean done = false; @@ -148,7 +150,7 @@ public class OccupantsInfo extends IQ { return occupantsInfo; } - private OccupantInfo parseOccupantInfo(XmlPullParser parser) throws Exception { + private OccupantInfo parseOccupantInfo(XmlPullParser parser) throws XmlPullParserException, IOException { boolean done = false; String jid = null; @@ -163,7 +165,11 @@ public class OccupantsInfo extends IQ { nickname = parser.nextText(); } else if ((eventType == XmlPullParser.START_TAG) && ("joined".equals(parser.getName()))) { - joined = UTC_FORMAT.parse(parser.nextText()); + try { + joined = UTC_FORMAT.parse(parser.nextText()); + } catch (ParseException e) { + new SmackException(e); + } } else if (eventType == XmlPullParser.END_TAG && "occupant".equals(parser.getName())) { done = true; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRequestProvider.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRequestProvider.java index cab8b5a6e..8a382db75 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRequestProvider.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRequestProvider.java @@ -23,11 +23,14 @@ import org.jivesoftware.smackx.workgroup.agent.OfferContent; import org.jivesoftware.smackx.workgroup.agent.TransferRequest; import org.jivesoftware.smackx.workgroup.agent.UserRequest; import org.jivesoftware.smackx.workgroup.util.MetaDataUtils; +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.PacketParserUtils; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -37,12 +40,14 @@ import java.util.Map; * * @author loki der quaeler */ -public class OfferRequestProvider implements IQProvider { +public class OfferRequestProvider extends IQProvider { + // FIXME It seems because OfferRequestPacket is also defined here, we can + // not add it as generic to the provider, the provider and the packet should + // be split, but since this is legacy code, I don't think that this will + // happen anytime soon. - public OfferRequestProvider() { - } - - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public OfferRequestPacket parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException { int eventType = parser.getEventType(); String sessionID = null; int timeout = -1; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRevokeProvider.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRevokeProvider.java index 21672c6ac..01b065f41 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRevokeProvider.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRevokeProvider.java @@ -17,18 +17,22 @@ package org.jivesoftware.smackx.workgroup.packet; +import java.io.IOException; + import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * An IQProvider class which has savvy about the offer-revoke tag.
* * @author loki der quaeler */ -public class OfferRevokeProvider implements IQProvider { +public class OfferRevokeProvider extends IQProvider { - public IQ parseIQ (XmlPullParser parser) throws Exception { + @Override + public OfferRevokePacket parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { // The parser will be positioned on the opening IQ tag, so get the JID attribute. String userJID = parser.getAttributeValue("", "jid"); // Default the userID to the JID. diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueDetails.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueDetails.java index 1fb1ef394..eb6b9765e 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueDetails.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueDetails.java @@ -18,10 +18,14 @@ package org.jivesoftware.smackx.workgroup.packet; import org.jivesoftware.smackx.workgroup.QueueUser; +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import java.io.IOException; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashSet; @@ -139,9 +143,12 @@ public class QueueDetails implements PacketExtension { /** * Provider class for QueueDetails packet extensions. */ - public static class Provider implements PacketExtensionProvider { - - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { + public static class Provider extends PacketExtensionProvider { + + @Override + public QueueDetails parse(XmlPullParser parser, + int initialDepth) throws XmlPullParserException, + IOException, SmackException { SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); QueueDetails queueDetails = new QueueDetails(); @@ -174,10 +181,19 @@ public class QueueDetails implements PacketExtension { time = Integer.parseInt(parser.nextText()); } else if ("join-time".equals(parser.getName())) { - joinTime = dateFormat.parse(parser.nextText()); + try { + joinTime = dateFormat.parse(parser.nextText()); + } catch (ParseException e) { + throw new SmackException(e); + } } else if( parser.getName().equals( "waitTime" ) ) { - Date wait = dateFormat.parse(parser.nextText()); + Date wait; + try { + wait = dateFormat.parse(parser.nextText()); + } catch (ParseException e) { + throw new SmackException(e); + } LOGGER.fine(wait.toString()); } diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueOverview.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueOverview.java index 7728f540d..8461c3303 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueOverview.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueOverview.java @@ -18,10 +18,14 @@ package org.jivesoftware.smackx.workgroup.packet; import org.jivesoftware.smackx.workgroup.agent.WorkgroupQueue; +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import java.io.IOException; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; @@ -113,17 +117,16 @@ public class QueueOverview implements PacketExtension { return buf.toString(); } - public static class Provider implements PacketExtensionProvider { + public static class Provider extends PacketExtensionProvider { - public PacketExtension parseExtension (XmlPullParser parser) throws Exception { + @Override + public QueueOverview parse(XmlPullParser parser, + int initialDepth) throws XmlPullParserException, + IOException, SmackException { int eventType = parser.getEventType(); QueueOverview queueOverview = new QueueOverview(); SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); - if (eventType != XmlPullParser.START_TAG) { - // throw exception - } - eventType = parser.next(); while ((eventType != XmlPullParser.END_TAG) || (!ELEMENT_NAME.equals(parser.getName()))) @@ -135,7 +138,11 @@ public class QueueOverview implements PacketExtension { queueOverview.setAverageWaitTime(Integer.parseInt(parser.nextText())); } else if ("oldest".equals(parser.getName())) { - queueOverview.setOldestEntry((dateFormat.parse(parser.nextText()))); + try { + queueOverview.setOldestEntry((dateFormat.parse(parser.nextText()))); + } catch (ParseException e) { + throw new SmackException(e); + } } else if ("status".equals(parser.getName())) { queueOverview.setStatus(WorkgroupQueue.Status.fromString(parser.nextText())); diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueUpdate.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueUpdate.java index a8f8004cc..db21ab904 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueUpdate.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueUpdate.java @@ -17,9 +17,12 @@ package org.jivesoftware.smackx.workgroup.packet; +import java.io.IOException; + import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * An IQ packet that encapsulates both types of workgroup queue @@ -87,9 +90,11 @@ public class QueueUpdate implements PacketExtension { return NAMESPACE; } - public static class Provider implements PacketExtensionProvider { + public static class Provider extends PacketExtensionProvider { - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { + @Override + public QueueUpdate parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException { boolean done = false; int position = -1; int timeRemaining = -1; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/RoomInvitation.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/RoomInvitation.java index b0717d321..463a7cc22 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/RoomInvitation.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/RoomInvitation.java @@ -17,9 +17,12 @@ package org.jivesoftware.smackx.workgroup.packet; +import java.io.IOException; + import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * Packet extension for {@link org.jivesoftware.smackx.workgroup.agent.InvitationRequest}. @@ -138,9 +141,12 @@ public class RoomInvitation implements PacketExtension { workgroup } - public static class Provider implements PacketExtensionProvider { + public static class Provider extends PacketExtensionProvider { - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { + @Override + public RoomInvitation parse(XmlPullParser parser, + int initialDepth) throws XmlPullParserException, + IOException { final RoomInvitation invitation = new RoomInvitation(); invitation.type = Type.valueOf(parser.getAttributeValue("", "type")); diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/RoomTransfer.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/RoomTransfer.java index 5bb643c05..a23e8bf92 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/RoomTransfer.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/RoomTransfer.java @@ -17,9 +17,12 @@ package org.jivesoftware.smackx.workgroup.packet; +import java.io.IOException; + import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * Packet extension for {@link org.jivesoftware.smackx.workgroup.agent.TransferRequest}. @@ -138,9 +141,12 @@ public class RoomTransfer implements PacketExtension { workgroup } - public static class Provider implements PacketExtensionProvider { + public static class Provider extends PacketExtensionProvider { - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { + @Override + public RoomTransfer parse(XmlPullParser parser, + int initialDepth) throws XmlPullParserException, + IOException { final RoomTransfer invitation = new RoomTransfer(); invitation.type = RoomTransfer.Type.valueOf(parser.getAttributeValue("", "type")); diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/SessionID.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/SessionID.java index a4be3c48c..0930fd961 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/SessionID.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/SessionID.java @@ -17,9 +17,12 @@ package org.jivesoftware.smackx.workgroup.packet; +import java.io.IOException; + import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; public class SessionID implements PacketExtension { @@ -61,9 +64,11 @@ public class SessionID implements PacketExtension { return buf.toString(); } - public static class Provider implements PacketExtensionProvider { + public static class Provider extends PacketExtensionProvider { - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { + @Override + public SessionID parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException { String sessionID = parser.getAttributeValue("", "id"); // Advance to end of extension. diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptProvider.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptProvider.java index b328e2bbf..7f44228e9 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptProvider.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptProvider.java @@ -17,12 +17,14 @@ package org.jivesoftware.smackx.workgroup.packet; +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.provider.IQProvider; -import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.Packet; import org.jivesoftware.smack.util.PacketParserUtils; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -31,13 +33,10 @@ import java.util.List; * * @author Gaston Dombiak */ -public class TranscriptProvider implements IQProvider { +public class TranscriptProvider extends IQProvider { - public TranscriptProvider() { - super(); - } - - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public Transcript parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException { String sessionID = parser.getAttributeValue("", "sessionID"); List packets = new ArrayList(); diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptSearch.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptSearch.java index 15022f2ee..e4be77727 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptSearch.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptSearch.java @@ -17,10 +17,14 @@ package org.jivesoftware.smackx.workgroup.packet; +import java.io.IOException; + +import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.PacketParserUtils; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * IQ packet for retrieving the transcript search form, submiting the completed search form @@ -56,13 +60,10 @@ public class TranscriptSearch extends IQ { * * @author Gaston Dombiak */ - public static class Provider implements IQProvider { + public static class Provider extends IQProvider { - public Provider() { - super(); - } - - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public TranscriptSearch parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException { TranscriptSearch answer = new TranscriptSearch(); boolean done = false; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptsProvider.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptsProvider.java index 1619cc91f..db4e0533c 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptsProvider.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptsProvider.java @@ -17,7 +17,6 @@ package org.jivesoftware.smackx.workgroup.packet; -import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; @@ -35,18 +34,15 @@ import java.util.TimeZone; * * @author Gaston Dombiak */ -public class TranscriptsProvider implements IQProvider { +public class TranscriptsProvider extends IQProvider { private static final SimpleDateFormat UTC_FORMAT = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss"); static { UTC_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+0")); } - public TranscriptsProvider() { - super(); - } - - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public Transcripts parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { String userID = parser.getAttributeValue("", "userID"); List summaries = new ArrayList(); diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/UserID.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/UserID.java index d2e44d7ed..145a0519d 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/UserID.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/UserID.java @@ -17,9 +17,12 @@ package org.jivesoftware.smackx.workgroup.packet; +import java.io.IOException; + import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; public class UserID implements PacketExtension { @@ -61,9 +64,11 @@ public class UserID implements PacketExtension { return buf.toString(); } - public static class Provider implements PacketExtensionProvider { + public static class Provider extends PacketExtensionProvider { - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { + @Override + public UserID parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException { String userID = parser.getAttributeValue("", "id"); // Advance to end of extension. diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/WorkgroupInformation.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/WorkgroupInformation.java index b490eccfb..00a9208a8 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/WorkgroupInformation.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/WorkgroupInformation.java @@ -17,9 +17,12 @@ package org.jivesoftware.smackx.workgroup.packet; +import java.io.IOException; + import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * A packet extension that contains information about the user and agent in a @@ -65,13 +68,17 @@ public class WorkgroupInformation implements PacketExtension { return buf.toString(); } - public static class Provider implements PacketExtensionProvider { + public static class Provider extends PacketExtensionProvider { /** * PacketExtensionProvider implementation + * @throws IOException + * @throws XmlPullParserException */ - public PacketExtension parseExtension (XmlPullParser parser) - throws Exception { + @Override + public WorkgroupInformation parse(XmlPullParser parser, + int initialDepth) throws XmlPullParserException, + IOException { String workgroupJID = parser.getAttributeValue("", "jid"); // since this is a start and end tag, and we arrive on the start, this should guarantee diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/settings/ChatSettings.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/settings/ChatSettings.java index df7960d32..1cf1ffccb 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/settings/ChatSettings.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/settings/ChatSettings.java @@ -20,7 +20,9 @@ package org.jivesoftware.smackx.workgroup.settings; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; @@ -125,9 +127,10 @@ public class ChatSettings extends IQ { /** * Packet extension provider for AgentStatusRequest packets. */ - public static class InternalProvider implements IQProvider { + public static class InternalProvider extends IQProvider { - public IQ parseIQ(XmlPullParser parser) throws Exception { + @Override + public ChatSettings parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { if (parser.getEventType() != XmlPullParser.START_TAG) { throw new IllegalStateException("Parser not in proper position, or bad XML."); } @@ -148,7 +151,7 @@ public class ChatSettings extends IQ { return chatSettings; } - private ChatSetting parseChatSetting(XmlPullParser parser) throws Exception { + private ChatSetting parseChatSetting(XmlPullParser parser) throws XmlPullParserException, IOException { boolean done = false; String key = null; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/settings/GenericSettings.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/settings/GenericSettings.java index fa94f826d..4b898ad5a 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/settings/GenericSettings.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/settings/GenericSettings.java @@ -21,7 +21,9 @@ import org.jivesoftware.smackx.workgroup.util.ModelUtil; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -77,13 +79,10 @@ public class GenericSettings extends IQ { /** * Packet extension provider for SoundSetting Packets. */ - public static class InternalProvider implements IQProvider { - - public IQ parseIQ(XmlPullParser parser) throws Exception { - if (parser.getEventType() != XmlPullParser.START_TAG) { - throw new IllegalStateException("Parser not in proper position, or bad XML."); - } + public static class InternalProvider extends IQProvider { + @Override + public GenericSettings parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { GenericSettings setting = new GenericSettings(); boolean done = false; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/settings/OfflineSettings.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/settings/OfflineSettings.java index 2a46d149b..fbb2c4f38 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/settings/OfflineSettings.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/settings/OfflineSettings.java @@ -17,10 +17,13 @@ package org.jivesoftware.smackx.workgroup.settings; +import java.io.IOException; + import org.jivesoftware.smackx.workgroup.util.ModelUtil; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; public class OfflineSettings extends IQ { private String redirectURL; @@ -108,13 +111,10 @@ public class OfflineSettings extends IQ { /** * Packet extension provider for AgentStatusRequest packets. */ - public static class InternalProvider implements IQProvider { - - public IQ parseIQ(XmlPullParser parser) throws Exception { - if (parser.getEventType() != XmlPullParser.START_TAG) { - throw new IllegalStateException("Parser not in proper position, or bad XML."); - } + public static class InternalProvider extends IQProvider { + @Override + public OfflineSettings parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { OfflineSettings offlineSettings = new OfflineSettings(); boolean done = false; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/settings/SearchSettings.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/settings/SearchSettings.java index 22a21599b..3d823a942 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/settings/SearchSettings.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/settings/SearchSettings.java @@ -16,10 +16,13 @@ */ package org.jivesoftware.smackx.workgroup.settings; +import java.io.IOException; + import org.jivesoftware.smackx.workgroup.util.ModelUtil; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; public class SearchSettings extends IQ { private String forumsLocation; @@ -79,13 +82,10 @@ public class SearchSettings extends IQ { /** * Packet extension provider for AgentStatusRequest packets. */ - public static class InternalProvider implements IQProvider { - - public IQ parseIQ(XmlPullParser parser) throws Exception { - if (parser.getEventType() != XmlPullParser.START_TAG) { - throw new IllegalStateException("Parser not in proper position, or bad XML."); - } + public static class InternalProvider extends IQProvider { + @Override + public SearchSettings parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { SearchSettings settings = new SearchSettings(); boolean done = false; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/settings/SoundSettings.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/settings/SoundSettings.java index e6dab43e6..e9562563a 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/settings/SoundSettings.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/settings/SoundSettings.java @@ -17,10 +17,13 @@ package org.jivesoftware.smackx.workgroup.settings; +import java.io.IOException; + import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.stringencoder.Base64; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; public class SoundSettings extends IQ { private String outgoingSound; @@ -69,13 +72,10 @@ public class SoundSettings extends IQ { /** * Packet extension provider for SoundSetting Packets. */ - public static class InternalProvider implements IQProvider { - - public IQ parseIQ(XmlPullParser parser) throws Exception { - if (parser.getEventType() != XmlPullParser.START_TAG) { - throw new IllegalStateException("Parser not in proper position, or bad XML."); - } + public static class InternalProvider extends IQProvider { + @Override + public SoundSettings parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { SoundSettings soundSettings = new SoundSettings(); boolean done = false; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/settings/WorkgroupProperties.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/settings/WorkgroupProperties.java index 872ebca3f..758e31af3 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/settings/WorkgroupProperties.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/settings/WorkgroupProperties.java @@ -17,10 +17,13 @@ package org.jivesoftware.smackx.workgroup.settings; +import java.io.IOException; + import org.jivesoftware.smackx.workgroup.util.ModelUtil; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; public class WorkgroupProperties extends IQ { @@ -89,13 +92,10 @@ public class WorkgroupProperties extends IQ { /** * Packet extension provider for SoundSetting Packets. */ - public static class InternalProvider implements IQProvider { - - public IQ parseIQ(XmlPullParser parser) throws Exception { - if (parser.getEventType() != XmlPullParser.START_TAG) { - throw new IllegalStateException("Parser not in proper position, or bad XML."); - } + public static class InternalProvider extends IQProvider { + @Override + public WorkgroupProperties parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { WorkgroupProperties props = new WorkgroupProperties(); boolean done = false; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/provider/MessageEventProvider.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/provider/MessageEventProvider.java index e13d33309..94c55127a 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/provider/MessageEventProvider.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/provider/MessageEventProvider.java @@ -17,10 +17,12 @@ package org.jivesoftware.smackx.xevent.provider; -import org.jivesoftware.smack.packet.PacketExtension; +import java.io.IOException; + import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smackx.xevent.packet.MessageEvent; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * @@ -28,24 +30,19 @@ import org.xmlpull.v1.XmlPullParser; * * @author Gaston Dombiak */ -public class MessageEventProvider implements PacketExtensionProvider { - - /** - * Creates a new MessageEventProvider. - * ProviderManager requires that every PacketExtensionProvider has a public, no-argument constructor - */ - public MessageEventProvider() { - } +public class MessageEventProvider extends PacketExtensionProvider { /** * Parses a MessageEvent packet (extension sub-packet). * * @param parser the XML parser, positioned at the starting element of the extension. * @return a PacketExtension. - * @throws Exception if a parsing error occurs. + * @throws IOException + * @throws XmlPullParserException */ - public PacketExtension parseExtension(XmlPullParser parser) - throws Exception { + @Override + public MessageEvent parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException { MessageEvent messageEvent = new MessageEvent(); boolean done = false; while (!done) { diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/provider/RosterExchangeProvider.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/provider/RosterExchangeProvider.java index 4550e4038..45fd9274e 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/provider/RosterExchangeProvider.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/provider/RosterExchangeProvider.java @@ -17,13 +17,14 @@ package org.jivesoftware.smackx.xroster.provider; +import java.io.IOException; import java.util.ArrayList; -import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smackx.xroster.RemoteRosterEntry; import org.jivesoftware.smackx.xroster.packet.RosterExchange; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; /** * @@ -31,23 +32,19 @@ import org.xmlpull.v1.XmlPullParser; * * @author Gaston Dombiak */ -public class RosterExchangeProvider implements PacketExtensionProvider { - - /** - * Creates a new RosterExchangeProvider. - * ProviderManager requires that every PacketExtensionProvider has a public, no-argument constructor - */ - public RosterExchangeProvider() { - } +public class RosterExchangeProvider extends PacketExtensionProvider { /** * Parses a RosterExchange packet (extension sub-packet). * * @param parser the XML parser, positioned at the starting element of the extension. * @return a PacketExtension. - * @throws Exception if a parsing error occurs. + * @throws IOException + * @throws XmlPullParserException */ - public PacketExtension parseExtension(XmlPullParser parser) throws Exception { + @Override + public RosterExchange parse(XmlPullParser parser, int initialDepth) + throws XmlPullParserException, IOException { RosterExchange rosterExchange = new RosterExchange(); boolean done = false; diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/sm/provider/StreamManagementStreamFeatureProvider.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/sm/provider/StreamManagementStreamFeatureProvider.java index 072c1e38f..8a1869528 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/sm/provider/StreamManagementStreamFeatureProvider.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/sm/provider/StreamManagementStreamFeatureProvider.java @@ -16,18 +16,16 @@ */ package org.jivesoftware.smack.tcp.sm.provider; -import org.jivesoftware.smack.packet.PacketExtension; -import org.jivesoftware.smack.provider.StreamFeatureProvider; +import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smack.tcp.sm.packet.StreamManagement.StreamManagementFeature; import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; -public class StreamManagementStreamFeatureProvider implements StreamFeatureProvider { +public class StreamManagementStreamFeatureProvider extends PacketExtensionProvider { - @Override - public PacketExtension parseStreamFeature(XmlPullParser parser) - throws XmlPullParserException { - return StreamManagementFeature.INSTANCE; - } + @Override + public StreamManagementFeature parse(XmlPullParser parser, + int initialDepth) { + return StreamManagementFeature.INSTANCE; + } }