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

Replace XPP3 by XmlPullParser interface wrapping StAX and XPP3

Introducing Smack's own XmlPullParser interface which tries to stay as
compatible as possible to XPP3. The interface is used to either wrap
StAX's XMLStreamReader if Smack is used on Java SE, and XPP3's
XmlPullParser if Smack is used on on Android.

Fixes SMACK-591.

Also introduce JUnit 5 and non-strict javadoc projects.
This commit is contained in:
Florian Schmaus 2019-05-06 22:06:13 +02:00
parent b3646abecd
commit 4133eb175c
414 changed files with 3855 additions and 2041 deletions

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.mood;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smackx.mood.element.MoodElement;
import org.jxmpp.jid.BareJid;

View file

@ -28,6 +28,7 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.provider.ProviderManager;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.mood.element.MoodConcretisation;
import org.jivesoftware.smackx.mood.element.MoodElement;

View file

@ -21,6 +21,7 @@ import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.NamedElement;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smackx.mood.Mood;
/**

View file

@ -20,10 +20,10 @@ import java.io.IOException;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.mood.element.MoodConcretisation;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.jivesoftware.smackx.mood.element.MoodConcretisation;
public abstract class MoodConcretisationProvider<C extends MoodConcretisation> extends ExtensionElementProvider<C> {

View file

@ -16,9 +16,6 @@
*/
package org.jivesoftware.smackx.mood.provider;
import static org.xmlpull.v1.XmlPullParser.END_TAG;
import static org.xmlpull.v1.XmlPullParser.START_TAG;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -27,13 +24,13 @@ import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.provider.ProviderManager;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.mood.Mood;
import org.jivesoftware.smackx.mood.element.MoodConcretisation;
import org.jivesoftware.smackx.mood.element.MoodElement;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
public class MoodProvider extends ExtensionElementProvider<MoodElement> {
private static final Logger LOGGER = Logger.getLogger(MoodProvider.class.getName());
@ -47,12 +44,12 @@ public class MoodProvider extends ExtensionElementProvider<MoodElement> {
MoodConcretisation concretisation = null;
outerloop: while (true) {
int tag = parser.next();
XmlPullParser.Event tag = parser.next();
String name = parser.getName();
String namespace = parser.getNamespace();
switch (tag) {
case START_TAG:
case START_ELEMENT:
if (MoodElement.ELEM_TEXT.equals(name)) {
text = parser.nextText();
continue outerloop;
@ -76,12 +73,17 @@ public class MoodProvider extends ExtensionElementProvider<MoodElement> {
throw new XmlPullParserException("Unknown mood value: " + name + " encountered.");
}
case END_TAG:
case END_ELEMENT:
if (MoodElement.ELEMENT.equals(name)) {
MoodElement.MoodSubjectElement subjectElement = (mood == null && concretisation == null) ?
null : new MoodElement.MoodSubjectElement(mood, concretisation);
return new MoodElement(subjectElement, text);
}
break;
default:
// Catch all for incomplete switch (MissingCasesInEnumSwitch) statement.
break;
}
}
}

View file

@ -19,10 +19,10 @@ package org.jivesoftware.smackx.mood.provider;
import java.io.IOException;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smackx.mood.element.MoodConcretisation;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.jivesoftware.smackx.mood.element.MoodConcretisation;
/**
* Simple {@link MoodConcretisationProvider} implementation, suitable for really simple {@link MoodConcretisation}s,