1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-12-12 05: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

@ -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<JivePropertiesExtension> {
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<String, Object> properties = new HashMap<String, Object>();
while (true) {
int eventType = parser.next();