mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-14 15:01:07 +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:
parent
d04517cd08
commit
6980c8e63d
137 changed files with 1101 additions and 841 deletions
|
|
@ -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<XHTMLExtension> {
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue