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

@ -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 <a href="http://xmpp.org/extensions/xep-0131">Stanza Headers and Internet Metadata (SHIM)</a>.
*
* @author Robin Collier
*/
public class HeaderProvider implements PacketExtensionProvider
public class HeaderProvider extends PacketExtensionProvider<Header>
{
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;

View file

@ -30,11 +30,11 @@ import org.jivesoftware.smackx.shim.packet.HeadersExtension;
*
* @author Robin Collier
*/
public class HeadersProvider extends EmbeddedExtensionProvider
public class HeadersProvider extends EmbeddedExtensionProvider<HeadersExtension>
{
@SuppressWarnings("unchecked")
@Override
protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
protected HeadersExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
{
return new HeadersExtension((Collection<Header>)content);
}