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

Rework exceptions in the parsing / provider subsystem

This commit is contained in:
Florian Schmaus 2019-02-05 10:41:50 +01:00
parent 4c42d0cd32
commit 083dac8b83
130 changed files with 504 additions and 342 deletions

View file

@ -16,13 +16,17 @@
*/
package org.jivesoftware.smackx.mood.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.mood.element.MoodConcretisation;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
public abstract class MoodConcretisationProvider<C extends MoodConcretisation> extends ExtensionElementProvider<C> {
@Override
public abstract C parse(XmlPullParser parser, int initialDepth) throws Exception;
public abstract C parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException, ParseException;
}

View file

@ -19,6 +19,8 @@ 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.text.ParseException;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -37,7 +39,8 @@ public class MoodProvider extends ExtensionElementProvider<MoodElement> {
public static final MoodProvider INSTANCE = new MoodProvider();
@Override
public MoodElement parse(XmlPullParser parser, int initialDepth) throws Exception {
public MoodElement parse(XmlPullParser parser, int initialDepth)
throws XmlPullParserException, IOException, ParseException {
String text = null;
Mood mood = null;
MoodConcretisation concretisation = null;

View file

@ -16,9 +16,13 @@
*/
package org.jivesoftware.smackx.mood.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smackx.mood.element.MoodConcretisation;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/**
* Simple {@link MoodConcretisationProvider} implementation, suitable for really simple {@link MoodConcretisation}s,
@ -30,7 +34,7 @@ import org.xmlpull.v1.XmlPullParser;
public abstract class SimpleMoodConcretisationProvider<C extends MoodConcretisation> extends MoodConcretisationProvider<C> {
@Override
public C parse(XmlPullParser parser, int initialDepth) throws Exception {
public C parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException, ParseException {
// Since the elements name and namespace is known, we can just return an instance of the MoodConcretisation.
return simpleExtension();
}