1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 17:19:39 +02:00

Introduce SmackParsingException

This commit is contained in:
Florian Schmaus 2019-02-10 19:01:47 +01:00
parent 163ca2b009
commit 7dee3b88a2
54 changed files with 277 additions and 155 deletions

View file

@ -17,8 +17,8 @@
package org.jivesoftware.smackx.bytestreams.ibb.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smackx.bytestreams.ibb.packet.Data;
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
@ -39,7 +39,7 @@ public class DataPacketProvider {
@Override
public Data parse(XmlPullParser parser, int initialDepth)
throws IOException, XmlPullParserException, ParseException {
throws IOException, XmlPullParserException, SmackParsingException {
DataPacketExtension data = packetExtensionProvider.parse(parser);
return new Data(data);
}

View file

@ -18,9 +18,9 @@
package org.jivesoftware.smackx.commands.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.PacketParserUtils;
@ -42,7 +42,7 @@ import org.xmlpull.v1.XmlPullParserException;
public class AdHocCommandDataProvider extends IQProvider<AdHocCommandData> {
@Override
public AdHocCommandData parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
public AdHocCommandData parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException {
boolean done = false;
AdHocCommandData adHocCommandData = new AdHocCommandData();
DataFormProvider dataFormProvider = new DataFormProvider();

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2014 Florian Schmaus
* Copyright © 2014-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.
@ -17,9 +17,9 @@
package org.jivesoftware.smackx.delay.provider;
import java.io.IOException;
import java.text.ParseException;
import java.util.Date;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.delay.packet.DelayInformation;
@ -32,7 +32,7 @@ public abstract class AbstractDelayInformationProvider extends ExtensionElementP
@Override
public final DelayInformation parse(XmlPullParser parser,
int initialDepth) throws XmlPullParserException,
IOException, ParseException {
IOException, SmackTextParseException {
String stampString = (parser.getAttributeValue("", "stamp"));
String from = parser.getAttributeValue("", "from");
String reason = null;
@ -58,5 +58,5 @@ public abstract class AbstractDelayInformationProvider extends ExtensionElementP
return new DelayInformation(stamp, from, reason);
}
protected abstract Date parseDate(String string) throws ParseException;
protected abstract Date parseDate(String string) throws SmackTextParseException;
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2014 Florian Schmaus
* Copyright © 2014-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,10 +16,10 @@
*/
package org.jivesoftware.smackx.delay.provider;
import java.text.ParseException;
import java.util.Date;
import org.jxmpp.util.XmppDateTime;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
import org.jivesoftware.smack.util.ParserUtils;
/**
* The DelayInformationProvider parses DelayInformation packets.
@ -31,8 +31,8 @@ public class DelayInformationProvider extends AbstractDelayInformationProvider {
public static final DelayInformationProvider INSTANCE = new DelayInformationProvider();
@Override
protected Date parseDate(String string) throws ParseException {
return XmppDateTime.parseXEP0082Date(string);
protected Date parseDate(String string) throws SmackTextParseException {
return ParserUtils.getDateFromXep82String(string);
}
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2014 Florian Schmaus
* Copyright © 2014-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,10 +16,10 @@
*/
package org.jivesoftware.smackx.delay.provider;
import java.text.ParseException;
import java.util.Date;
import org.jxmpp.util.XmppDateTime;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
import org.jivesoftware.smack.util.ParserUtils;
/**
* The DelayInformationProvider parses DelayInformation packets.
@ -29,8 +29,8 @@ import org.jxmpp.util.XmppDateTime;
public class LegacyDelayInformationProvider extends AbstractDelayInformationProvider {
@Override
protected Date parseDate(String string) throws ParseException {
return XmppDateTime.parseDate(string);
protected Date parseDate(String string) throws SmackTextParseException {
return ParserUtils.getDateFromString(string);
}
}

View file

@ -18,8 +18,8 @@
package org.jivesoftware.smackx.disco.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.PacketParserUtils;
@ -36,7 +36,7 @@ import org.xmlpull.v1.XmlPullParserException;
public class DiscoverInfoProvider extends IQProvider<DiscoverInfo> {
@Override
public DiscoverInfo parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
public DiscoverInfo parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException {
DiscoverInfo discoverInfo = new DiscoverInfo();
boolean done = false;
DiscoverInfo.Identity identity;

View file

@ -17,11 +17,11 @@
package org.jivesoftware.smackx.forward.provider;
import java.io.IOException;
import java.text.ParseException;
import java.util.logging.Logger;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.util.PacketParserUtils;
@ -45,7 +45,7 @@ public class ForwardedProvider extends ExtensionElementProvider<Forwarded> {
private static final Logger LOGGER = Logger.getLogger(ForwardedProvider.class.getName());
@Override
public Forwarded parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
public Forwarded parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException {
DelayInformation di = null;
Stanza packet = null;

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2015-2017 Ishan Khanna, Fernando Ramirez
* Copyright 2015-2017 Ishan Khanna, Fernando Ramirez, 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.
@ -17,8 +17,9 @@
package org.jivesoftware.smackx.geoloc.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackUriSyntaxParsingException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.util.ParserUtils;
@ -31,7 +32,7 @@ public class GeoLocationProvider extends ExtensionElementProvider<GeoLocation> {
@Override
public GeoLocation parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException,
ParseException {
SmackTextParseException, SmackUriSyntaxParsingException {
GeoLocation.Builder builder = GeoLocation.builder();

View file

@ -17,7 +17,6 @@
package org.jivesoftware.smackx.iqregister.provider;
import java.io.IOException;
import java.text.ParseException;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@ -25,6 +24,7 @@ import java.util.Map;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.PacketParserUtils;
@ -36,7 +36,7 @@ import org.xmlpull.v1.XmlPullParserException;
public class RegistrationProvider extends IQProvider<Registration> {
@Override
public Registration parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
public Registration parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException {
String instruction = null;
Map<String, String> fields = new HashMap<>();
List<ExtensionElement> packetExtensions = new LinkedList<>();

View file

@ -17,8 +17,8 @@
package org.jivesoftware.smackx.jingle.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.jingle.element.JingleContentDescription;
@ -30,6 +30,6 @@ public abstract class JingleContentDescriptionProvider<D extends JingleContentDe
extends ExtensionElementProvider<D> {
@Override
public abstract D parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException;
public abstract D parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException;
}

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.
@ -17,10 +17,10 @@
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;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.parsing.StandardExtensionElementProvider;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.ParserUtils;
@ -44,7 +44,7 @@ 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 XmlPullParserException, IOException, ParseException {
public Jingle parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException {
Jingle.Builder builder = Jingle.getBuilder();
String actionString = parser.getAttributeValue("", Jingle.ACTION_ATTRIBUTE_NAME);
@ -102,7 +102,7 @@ public class JingleProvider extends IQProvider<Jingle> {
}
public static JingleContent parseJingleContent(XmlPullParser parser, final int initialDepth)
throws XmlPullParserException, IOException, ParseException {
throws XmlPullParserException, IOException, SmackParsingException {
JingleContent.Builder builder = JingleContent.getBuilder();
String creatorString = parser.getAttributeValue("", JingleContent.CREATOR_ATTRIBUTE_NAME);

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2018 Paul Schaub
* Copyright © 2018 Paul Schaub, 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.
@ -19,6 +19,8 @@ package org.jivesoftware.smackx.last_interaction.provider;
import java.text.ParseException;
import java.util.Date;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.last_interaction.element.IdleElement;
@ -30,9 +32,14 @@ public class IdleProvider extends ExtensionElementProvider<IdleElement> {
public static final IdleProvider TEST_INSTANCE = new IdleProvider();
@Override
public IdleElement parse(XmlPullParser parser, int initialDepth) throws ParseException {
public IdleElement parse(XmlPullParser parser, int initialDepth) throws SmackTextParseException {
String dateString = parser.getAttributeValue(null, IdleElement.ATTR_SINCE);
Date since = XmppDateTime.parseXEP0082Date(dateString);
Date since;
try {
since = XmppDateTime.parseXEP0082Date(dateString);
} catch (ParseException e) {
throw new SmackParsingException.SmackTextParseException(e);
}
return new IdleElement(since);
}
}

View file

@ -17,7 +17,6 @@
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;
@ -28,5 +27,5 @@ 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 IOException, XmlPullParserException, ParseException;
public abstract C parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException;
}

View file

@ -20,10 +20,10 @@ 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;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.provider.ProviderManager;
import org.jivesoftware.smackx.mood.Mood;
@ -40,7 +40,7 @@ public class MoodProvider extends ExtensionElementProvider<MoodElement> {
@Override
public MoodElement parse(XmlPullParser parser, int initialDepth)
throws XmlPullParserException, IOException, ParseException {
throws XmlPullParserException, IOException, SmackParsingException {
String text = null;
Mood mood = null;
MoodConcretisation concretisation = null;

View file

@ -17,7 +17,6 @@
package org.jivesoftware.smackx.mood.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smackx.mood.element.MoodConcretisation;
@ -34,7 +33,7 @@ import org.xmlpull.v1.XmlPullParserException;
public abstract class SimpleMoodConcretisationProvider<C extends MoodConcretisation> extends MoodConcretisationProvider<C> {
@Override
public C parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException, ParseException {
public C parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException {
// Since the elements name and namespace is known, we can just return an instance of the MoodConcretisation.
return simpleExtension();
}

View file

@ -18,8 +18,8 @@
package org.jivesoftware.smackx.muc.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.PacketParserUtils;
@ -36,7 +36,7 @@ import org.xmlpull.v1.XmlPullParserException;
public class MUCOwnerProvider extends IQProvider<MUCOwner> {
@Override
public MUCOwner parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
public MUCOwner parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException {
MUCOwner mucOwner = new MUCOwner();
boolean done = false;
while (!done) {

View file

@ -17,9 +17,9 @@
package org.jivesoftware.smackx.pubsub.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.provider.ProviderManager;
import org.jivesoftware.smack.util.PacketParserUtils;
@ -44,7 +44,7 @@ import org.xmlpull.v1.XmlPullParserException;
public class ItemProvider extends ExtensionElementProvider<Item> {
@Override
public Item parse(XmlPullParser parser, int initialDepth)
throws XmlPullParserException, IOException, ParseException {
throws XmlPullParserException, IOException, SmackParsingException {
String id = parser.getAttributeValue(null, "id");
String node = parser.getAttributeValue(null, "node");
String xmlns = parser.getNamespace();

View file

@ -17,9 +17,9 @@
package org.jivesoftware.smackx.pubsub.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.PacketParserUtils;
@ -37,7 +37,7 @@ import org.xmlpull.v1.XmlPullParserException;
*/
public class PubSubProvider extends IQProvider<PubSub> {
@Override
public PubSub parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
public PubSub parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException {
String namespace = parser.getNamespace();
PubSubNamespace pubSubNamespace = PubSubNamespace.valueOfFromXmlns(namespace);
PubSub pubsub = new PubSub(pubSubNamespace);

View file

@ -17,7 +17,6 @@
package org.jivesoftware.smackx.search;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
@ -25,6 +24,7 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.SimpleIQ;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.PacketParserUtils;
@ -129,7 +129,7 @@ public class UserSearch extends SimpleIQ {
// FIXME this provider does return two different types of IQs
@Override
public IQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
public IQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException {
UserSearch search = null;
SimpleUserSearch simpleUserSearch = new SimpleUserSearch();
@ -164,7 +164,7 @@ public class UserSearch extends SimpleIQ {
}
private static void buildDataForm(SimpleUserSearch search,
String instructions, XmlPullParser parser) throws XmlPullParserException, IOException, ParseException {
String instructions, XmlPullParser parser) throws XmlPullParserException, IOException, SmackParsingException {
DataForm dataForm = new DataForm(DataForm.Type.form);
boolean done = false;
dataForm.setTitle("User Search");

View file

@ -22,6 +22,7 @@ import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smackx.si.packet.StreamInitiation;
@ -43,7 +44,7 @@ public class StreamInitiationProvider extends IQProvider<StreamInitiation> {
private static final Logger LOGGER = Logger.getLogger(StreamInitiationProvider.class.getName());
@Override
public StreamInitiation parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
public StreamInitiation parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException {
boolean done = false;
// si

View file

@ -18,10 +18,10 @@
package org.jivesoftware.smackx.xdata.provider;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.roster.packet.RosterPacket;
import org.jivesoftware.smack.roster.provider.RosterPacketProvider;
@ -46,7 +46,7 @@ public class DataFormProvider extends ExtensionElementProvider<DataForm> {
public static final DataFormProvider INSTANCE = new DataFormProvider();
@Override
public DataForm parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
public DataForm parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException {
DataForm.Type dataFormType = DataForm.Type.fromString(parser.getAttributeValue("", "type"));
DataForm dataForm = new DataForm(dataFormType);
outerloop: while (true) {