mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-09 09:09:38 +02:00
Introduce SmackParsingException
This commit is contained in:
parent
163ca2b009
commit
7dee3b88a2
54 changed files with 277 additions and 155 deletions
|
@ -17,8 +17,8 @@
|
|||
package org.jivesoftware.smackx.carbons.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.carbons.packet.CarbonExtension;
|
||||
|
@ -41,7 +41,7 @@ public class CarbonManagerProvider extends ExtensionElementProvider<CarbonExtens
|
|||
private static final ForwardedProvider FORWARDED_PROVIDER = new ForwardedProvider();
|
||||
|
||||
@Override
|
||||
public CarbonExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
|
||||
public CarbonExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException {
|
||||
Direction dir = Direction.valueOf(parser.getName());
|
||||
Forwarded fwd = null;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2014 Andriy Tsykholyas, 2015 Florian Schmaus
|
||||
* Copyright 2014 Andriy Tsykholyas, 2015-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.hoxt.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
|
@ -56,11 +56,11 @@ public abstract class AbstractHttpOverXmppProvider<H extends AbstractHttpOverXmp
|
|||
*
|
||||
* @param parser parser
|
||||
* @return HeadersExtension or null if no headers
|
||||
* @throws ParseException
|
||||
* @throws XmlPullParserException
|
||||
* @throws IOException
|
||||
* @throws SmackParsingException
|
||||
*/
|
||||
protected HeadersExtension parseHeaders(XmlPullParser parser) throws IOException, XmlPullParserException, ParseException {
|
||||
protected HeadersExtension parseHeaders(XmlPullParser parser) throws IOException, XmlPullParserException, SmackParsingException {
|
||||
HeadersExtension headersExtension = null;
|
||||
/* We are either at start of headers, start of data or end of req/res */
|
||||
if (parser.next() == XmlPullParser.START_TAG && parser.getName().equals(HeadersExtension.ELEMENT)) {
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
package org.jivesoftware.smackx.hoxt.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
|
||||
import org.jivesoftware.smackx.hoxt.packet.HttpMethod;
|
||||
|
@ -40,7 +40,7 @@ public class HttpOverXmppReqProvider extends AbstractHttpOverXmppProvider<HttpOv
|
|||
private static final String ATTRIBUTE_MAX_CHUNK_SIZE = "maxChunkSize";
|
||||
|
||||
@Override
|
||||
public HttpOverXmppReq parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException, ParseException {
|
||||
public HttpOverXmppReq parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException, SmackParsingException {
|
||||
HttpOverXmppReq.Builder builder = HttpOverXmppReq.builder();
|
||||
builder.setResource(parser.getAttributeValue("", ATTRIBUTE_RESOURCE));
|
||||
builder.setVersion(parser.getAttributeValue("", ATTRIBUTE_VERSION));
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
package org.jivesoftware.smackx.hoxt.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smackx.hoxt.packet.AbstractHttpOverXmpp;
|
||||
import org.jivesoftware.smackx.hoxt.packet.HttpOverXmppResp;
|
||||
import org.jivesoftware.smackx.shim.packet.HeadersExtension;
|
||||
|
@ -38,7 +38,7 @@ public class HttpOverXmppRespProvider extends AbstractHttpOverXmppProvider<HttpO
|
|||
private static final String ATTRIBUTE_STATUS_CODE = "statusCode";
|
||||
|
||||
@Override
|
||||
public HttpOverXmppResp parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException, ParseException {
|
||||
public HttpOverXmppResp parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException, SmackParsingException {
|
||||
String version = parser.getAttributeValue("", ATTRIBUTE_VERSION);
|
||||
String statusMessage = parser.getAttributeValue("", ATTRIBUTE_STATUS_MESSAGE);
|
||||
String statusCodeString = parser.getAttributeValue("", ATTRIBUTE_STATUS_CODE);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2016 Florian Schmaus
|
||||
* Copyright © 2016-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.
|
||||
|
@ -23,6 +23,8 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
|
||||
|
@ -42,7 +44,7 @@ public class IoTFieldsExtensionProvider extends ExtensionElementProvider<IoTFiel
|
|||
private static final Logger LOGGER = Logger.getLogger(IoTFieldsExtensionProvider.class.getName());
|
||||
|
||||
@Override
|
||||
public IoTFieldsExtension parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException, ParseException {
|
||||
public IoTFieldsExtension parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException, SmackTextParseException {
|
||||
int seqNr = ParserUtils.getIntegerAttributeOrThrow(parser, "seqnr", "IoT data request <accepted/> without sequence number");
|
||||
boolean done = ParserUtils.getBooleanAttribute(parser, "done", false);
|
||||
List<NodeElement> nodes = new ArrayList<>();
|
||||
|
@ -68,7 +70,7 @@ public class IoTFieldsExtensionProvider extends ExtensionElementProvider<IoTFiel
|
|||
return new IoTFieldsExtension(seqNr, done, nodes);
|
||||
}
|
||||
|
||||
public NodeElement parseNode(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException {
|
||||
public NodeElement parseNode(XmlPullParser parser) throws XmlPullParserException, IOException, SmackTextParseException {
|
||||
final int initialDepth = parser.getDepth();
|
||||
final NodeInfo nodeInfo = NodeInfoParser.parse(parser);
|
||||
List<TimestampElement> timestampElements = new ArrayList<>();
|
||||
|
@ -94,10 +96,15 @@ public class IoTFieldsExtensionProvider extends ExtensionElementProvider<IoTFiel
|
|||
return new NodeElement(nodeInfo, timestampElements);
|
||||
}
|
||||
|
||||
public TimestampElement parseTimestampElement(XmlPullParser parser) throws ParseException, XmlPullParserException, IOException {
|
||||
public TimestampElement parseTimestampElement(XmlPullParser parser) throws XmlPullParserException, IOException, SmackTextParseException {
|
||||
final int initialDepth = parser.getDepth();
|
||||
final String dateString = parser.getAttributeValue(null, "value");
|
||||
final Date date = XmppDateTime.parseDate(dateString);
|
||||
Date date;
|
||||
try {
|
||||
date = XmppDateTime.parseDate(dateString);
|
||||
} catch (ParseException e) {
|
||||
throw new SmackParsingException.SmackTextParseException(e);
|
||||
}
|
||||
List<IoTDataField> fields = new ArrayList<>();
|
||||
outerloop: while (true) {
|
||||
final int eventType = parser.next();
|
||||
|
|
|
@ -20,8 +20,8 @@ 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 org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smackx.hashes.element.HashElement;
|
||||
import org.jivesoftware.smackx.hashes.provider.HashElementProvider;
|
||||
|
@ -38,7 +38,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
*/
|
||||
public class ChecksumProvider extends ExtensionElementProvider<Checksum> {
|
||||
@Override
|
||||
public Checksum parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
|
||||
public Checksum parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException {
|
||||
JingleContent.Creator creator = null;
|
||||
String creatorString = parser.getAttributeValue(null, Checksum.ATTR_CREATOR);
|
||||
if (creatorString != null) {
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.io.IOException;
|
|||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smackx.hashes.element.HashElement;
|
||||
import org.jivesoftware.smackx.hashes.provider.HashElementProvider;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement;
|
||||
|
@ -42,7 +43,7 @@ public class JingleFileTransferProvider
|
|||
extends JingleContentDescriptionProvider<JingleFileTransfer> {
|
||||
|
||||
@Override
|
||||
public JingleFileTransfer parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
|
||||
public JingleFileTransfer parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException {
|
||||
ArrayList<JingleContentDescriptionChildElement> payloads = new ArrayList<>();
|
||||
boolean inRange = false;
|
||||
JingleFileTransferChild.Builder builder = JingleFileTransferChild.getBuilder();
|
||||
|
@ -59,7 +60,11 @@ public class JingleFileTransferProvider
|
|||
if (tag == START_TAG) {
|
||||
switch (elem) {
|
||||
case JingleFileTransferChild.ELEM_DATE:
|
||||
try {
|
||||
builder.setDate(XmppDateTime.parseXEP0082Date(parser.nextText()));
|
||||
} catch (ParseException e) {
|
||||
throw new SmackParsingException.SmackTextParseException(e);
|
||||
}
|
||||
break;
|
||||
|
||||
case JingleFileTransferChild.ELEM_DESC:
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
package org.jivesoftware.smackx.mam.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.ParserUtils;
|
||||
|
||||
|
@ -40,7 +40,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
public class MamFinIQProvider extends IQProvider<MamFinIQ> {
|
||||
|
||||
@Override
|
||||
public MamFinIQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
|
||||
public MamFinIQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException {
|
||||
String queryId = parser.getAttributeValue("", "queryid");
|
||||
boolean complete = ParserUtils.getBooleanAttribute(parser, "complete", false);
|
||||
boolean stable = ParserUtils.getBooleanAttribute(parser, "stable", true);
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
package org.jivesoftware.smackx.mam.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
|
||||
import org.jivesoftware.smackx.mam.element.MamQueryIQ;
|
||||
|
@ -40,7 +40,7 @@ public class MamQueryIQProvider extends IQProvider<MamQueryIQ> {
|
|||
|
||||
@Override
|
||||
public MamQueryIQ parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException, ParseException {
|
||||
throws XmlPullParserException, IOException, SmackParsingException {
|
||||
DataForm dataForm = null;
|
||||
String queryId = parser.getAttributeValue("", "queryid");
|
||||
String node = parser.getAttributeValue("", "node");
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
package org.jivesoftware.smackx.mam.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.forward.packet.Forwarded;
|
||||
|
@ -39,7 +39,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
public class MamResultProvider extends ExtensionElementProvider<MamResultExtension> {
|
||||
|
||||
@Override
|
||||
public MamResultExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
|
||||
public MamResultExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException {
|
||||
Forwarded forwarded = null;
|
||||
String queryId = parser.getAttributeValue("", "queryid");
|
||||
String id = parser.getAttributeValue("", "id");
|
||||
|
|
|
@ -19,9 +19,9 @@ package org.jivesoftware.smackx.reference.provider;
|
|||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
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.ParserUtils;
|
||||
|
@ -35,7 +35,7 @@ public class ReferenceProvider extends ExtensionElementProvider<ReferenceElement
|
|||
public static final ReferenceProvider TEST_PROVIDER = new ReferenceProvider();
|
||||
|
||||
@Override
|
||||
public ReferenceElement parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
|
||||
public ReferenceElement parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException {
|
||||
Integer begin = ParserUtils.getIntegerAttribute(parser, ReferenceElement.ATTR_BEGIN);
|
||||
Integer end = ParserUtils.getIntegerAttribute(parser, ReferenceElement.ATTR_END);
|
||||
String typeString = parser.getAttributeValue(null, ReferenceElement.ATTR_TYPE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue