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

@ -1,6 +1,6 @@
/**
*
* Copyright 2017 Florian Schmaus
* Copyright 2017-2019 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,16 +16,20 @@
*/
package org.jivesoftware.smackx.jingle.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.jingle.element.JingleContentDescription;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
public abstract class JingleContentDescriptionProvider<D extends JingleContentDescription>
extends ExtensionElementProvider<D> {
@Override
public abstract D parse(XmlPullParser parser, int initialDepth) throws Exception;
public abstract D parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException;
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2017 Florian Schmaus
* Copyright 2017-2019 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,16 +16,19 @@
*/
package org.jivesoftware.smackx.jingle.provider;
import java.io.IOException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
public abstract class JingleContentTransportProvider<T extends JingleContentTransport>
extends ExtensionElementProvider<T> {
@Override
public abstract T parse(XmlPullParser parser, int initialDepth) throws Exception;
public abstract T parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException;
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2017 Florian Schmaus
* Copyright 2017-2019 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -25,7 +25,7 @@ import org.xmlpull.v1.XmlPullParser;
public class JingleErrorProvider extends ExtensionElementProvider<JingleError> {
@Override
public JingleError parse(XmlPullParser parser, int initialDepth) throws Exception {
public JingleError parse(XmlPullParser parser, int initialDepth) {
String errorName = parser.getName();
return JingleError.fromString(errorName);
}

View file

@ -16,6 +16,8 @@
*/
package org.jivesoftware.smackx.jingle.provider;
import java.io.IOException;
import java.text.ParseException;
import java.util.logging.Logger;
import org.jivesoftware.smack.packet.StandardExtensionElement;
@ -35,13 +37,14 @@ import org.jivesoftware.smackx.jingle.element.UnknownJingleContentTransport;
import org.jxmpp.jid.FullJid;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
public class JingleProvider extends IQProvider<Jingle> {
private static final Logger LOGGER = Logger.getLogger(JingleProvider.class.getName());
@Override
public Jingle parse(XmlPullParser parser, int initialDepth) throws Exception {
public Jingle parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
Jingle.Builder builder = Jingle.getBuilder();
String actionString = parser.getAttributeValue("", Jingle.ACTION_ATTRIBUTE_NAME);
@ -99,7 +102,7 @@ public class JingleProvider extends IQProvider<Jingle> {
}
public static JingleContent parseJingleContent(XmlPullParser parser, final int initialDepth)
throws Exception {
throws XmlPullParserException, IOException, ParseException {
JingleContent.Builder builder = JingleContent.getBuilder();
String creatorString = parser.getAttributeValue("", JingleContent.CREATOR_ATTRIBUTE_NAME);

View file

@ -26,7 +26,7 @@ import org.xmlpull.v1.XmlPullParser;
*/
public class JingleIBBTransportProvider extends JingleContentTransportProvider<JingleIBBTransport> {
@Override
public JingleIBBTransport parse(XmlPullParser parser, int initialDepth) throws Exception {
public JingleIBBTransport parse(XmlPullParser parser, int initialDepth) {
String blockSizeString = parser.getAttributeValue(null, JingleIBBTransport.ATTR_BLOCK_SIZE);
String sid = parser.getAttributeValue(null, JingleIBBTransport.ATTR_SID);

View file

@ -27,6 +27,8 @@ import static org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.Jing
import static org.xmlpull.v1.XmlPullParser.END_TAG;
import static org.xmlpull.v1.XmlPullParser.START_TAG;
import java.io.IOException;
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
import org.jivesoftware.smackx.jingle.provider.JingleContentTransportProvider;
import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransport;
@ -35,6 +37,7 @@ import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTr
import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransportInfo.JingleS5BCandidateTransportInfo;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/**
* Provider for JingleSocks5BytestreamTransport elements.
@ -42,7 +45,7 @@ import org.xmlpull.v1.XmlPullParser;
public class JingleS5BTransportProvider extends JingleContentTransportProvider<JingleS5BTransport> {
@Override
public JingleS5BTransport parse(XmlPullParser parser, int initialDepth) throws Exception {
public JingleS5BTransport parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
JingleS5BTransport.Builder builder = JingleS5BTransport.getBuilder();
String streamId = parser.getAttributeValue(null, JingleS5BTransport.ATTR_SID);