1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-12-14 06:51:08 +01:00

Rework Smack Provider design

this is the first stop towards fixing "SMACK-65: parsing should look for
depth", by providing the initial parsing depth to the provider. Some
methods (.e.g parseMessage) now use the depth as abort condition,
instead of a unclean String equals check.

parseIQ() and parseExtension() where both renamed to parse.

This also restricts the Exceptions thrown by the parse method, to just
XmlPullParserException, IOException and SmackException (not really a big
victory, but nevertheless a slight improvement).

StreamFeatureProvider is now gone, we simply use PacketExtensionProvider
for stream features.
This commit is contained in:
Florian Schmaus 2014-10-07 21:15:20 +02:00
parent d04517cd08
commit 6980c8e63d
137 changed files with 1101 additions and 841 deletions

View file

@ -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<PrivateDataResult> {
@Override
public PrivateDataResult parse(XmlPullParser parser, int initialDepth)
throws XmlPullParserException, IOException, SmackException {
PrivateData privateData = null;
boolean done = false;
while (!done) {

View file

@ -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;
}