mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-10 10:49:41 +02:00
Rework Smack Provider design
this is the first stop towards fixing "SMACK-65: parsing should look for depth", by providing the initial parsing depth to the provider. Some methods (.e.g parseMessage) now use the depth as abort condition, instead of a unclean String equals check. parseIQ() and parseExtension() where both renamed to parse. This also restricts the Exceptions thrown by the parse method, to just XmlPullParserException, IOException and SmackException (not really a big victory, but nevertheless a slight improvement). StreamFeatureProvider is now gone, we simply use PacketExtensionProvider for stream features.
This commit is contained in:
parent
d04517cd08
commit
6980c8e63d
137 changed files with 1101 additions and 841 deletions
|
@ -25,10 +25,10 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
* @author Robin Collier
|
||||
*
|
||||
*/
|
||||
public class CarExtensionProvider implements PacketExtensionProvider
|
||||
public class CarExtensionProvider extends PacketExtensionProvider
|
||||
{
|
||||
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception
|
||||
public PacketExtension parse(XmlPullParser parser, int initialDepth) throws Exception
|
||||
{
|
||||
String color = null;
|
||||
int numTires = 0;
|
||||
|
|
|
@ -17,27 +17,24 @@
|
|||
|
||||
package org.jivesoftware.smackx.address.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smackx.address.packet.MultipleAddresses;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* The MultipleAddressesProvider parses {@link MultipleAddresses} packets.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class MultipleAddressesProvider implements PacketExtensionProvider {
|
||||
public class MultipleAddressesProvider extends PacketExtensionProvider<MultipleAddresses> {
|
||||
|
||||
/**
|
||||
* Creates a new MultipleAddressesProvider.
|
||||
* ProviderManager requires that every PacketExtensionProvider has a public, no-argument
|
||||
* constructor.
|
||||
*/
|
||||
public MultipleAddressesProvider() {
|
||||
}
|
||||
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public MultipleAddresses parse(XmlPullParser parser,
|
||||
int initialDepth) throws XmlPullParserException,
|
||||
IOException {
|
||||
boolean done = false;
|
||||
MultipleAddresses multipleAddresses = new MultipleAddresses();
|
||||
while (!done) {
|
||||
|
|
|
@ -16,35 +16,32 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.amp.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smackx.amp.AMPDeliverCondition;
|
||||
import org.jivesoftware.smackx.amp.AMPExpireAtCondition;
|
||||
import org.jivesoftware.smackx.amp.AMPMatchResourceCondition;
|
||||
import org.jivesoftware.smackx.amp.packet.AMPExtension;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
||||
public class AMPExtensionProvider implements PacketExtensionProvider {
|
||||
public class AMPExtensionProvider extends PacketExtensionProvider<AMPExtension> {
|
||||
private static final Logger LOGGER = Logger.getLogger(AMPExtensionProvider.class.getName());
|
||||
|
||||
/**
|
||||
* Creates a new AMPExtensionProvider.
|
||||
* ProviderManager requires that every PacketExtensionProvider has a public, no-argument constructor
|
||||
*/
|
||||
public AMPExtensionProvider() {}
|
||||
|
||||
/**
|
||||
* Parses a AMPExtension packet (extension sub-packet).
|
||||
*
|
||||
* @param parser the XML parser, positioned at the starting element of the extension.
|
||||
* @return a PacketExtension.
|
||||
* @throws Exception if a parsing error occurs.
|
||||
* @throws IOException
|
||||
* @throws XmlPullParserException
|
||||
*/
|
||||
@Override
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
public AMPExtension parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException {
|
||||
final String from = parser.getAttributeValue(null, "from");
|
||||
final String to = parser.getAttributeValue(null, "to");
|
||||
final String statusString = parser.getAttributeValue(null, "status");
|
||||
|
|
|
@ -80,17 +80,10 @@ public class AttentionExtension implements PacketExtension {
|
|||
*
|
||||
* @author Guus der Kinderen, guus.der.kinderen@gmail.com
|
||||
s */
|
||||
public static class Provider implements PacketExtensionProvider {
|
||||
public static class Provider extends PacketExtensionProvider<AttentionExtension> {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.jivesoftware.smack.provider.PacketExtensionProvider#parseExtension
|
||||
* (org.xmlpull.v1.XmlPullParser)
|
||||
*/
|
||||
public PacketExtension parseExtension(XmlPullParser arg0)
|
||||
throws Exception {
|
||||
@Override
|
||||
public AttentionExtension parse(XmlPullParser parser, int initialDepth) {
|
||||
return new AttentionExtension();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -215,7 +215,7 @@ public class Bookmarks implements PrivateData {
|
|||
super();
|
||||
}
|
||||
|
||||
public PrivateData parsePrivateData(XmlPullParser parser) throws Exception {
|
||||
public PrivateData parsePrivateData(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
Bookmarks storage = new Bookmarks();
|
||||
|
||||
boolean done = false;
|
||||
|
@ -265,7 +265,7 @@ public class Bookmarks implements PrivateData {
|
|||
return urlStore;
|
||||
}
|
||||
|
||||
private static BookmarkedConference getConferenceStorage(XmlPullParser parser) throws Exception {
|
||||
private static BookmarkedConference getConferenceStorage(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
String name = parser.getAttributeValue("", "name");
|
||||
String autojoin = parser.getAttributeValue("", "autojoin");
|
||||
String jid = parser.getAttributeValue("", "jid");
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.ibb.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Close;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
@ -26,9 +25,10 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
*
|
||||
* @author Henning Staib
|
||||
*/
|
||||
public class CloseIQProvider implements IQProvider {
|
||||
public class CloseIQProvider extends IQProvider<Close> {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public Close parse(XmlPullParser parser, int initialDepth) {
|
||||
String sid = parser.getAttributeValue("", "sid");
|
||||
return new Close(sid);
|
||||
}
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.ibb.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Data;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* Parses an In-Band Bytestream data packet which can be a packet extension of
|
||||
|
@ -30,19 +30,33 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
*
|
||||
* @author Henning Staib
|
||||
*/
|
||||
public class DataPacketProvider implements PacketExtensionProvider, IQProvider {
|
||||
public class DataPacketProvider {
|
||||
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
String sessionID = parser.getAttributeValue("", "sid");
|
||||
long seq = Long.parseLong(parser.getAttributeValue("", "seq"));
|
||||
String data = parser.nextText();
|
||||
return new DataPacketExtension(sessionID, seq, data);
|
||||
public static class IQProvider extends org.jivesoftware.smack.provider.IQProvider<Data> {
|
||||
|
||||
private static final PacketExtensionProvider packetExtensionProvider = new PacketExtensionProvider();
|
||||
|
||||
@Override
|
||||
public Data parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException,
|
||||
SmackException {
|
||||
DataPacketExtension data = packetExtensionProvider.parse(parser);
|
||||
Data iq = new Data(data);
|
||||
return iq;
|
||||
}
|
||||
}
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
DataPacketExtension data = (DataPacketExtension) parseExtension(parser);
|
||||
IQ iq = new Data(data);
|
||||
return iq;
|
||||
}
|
||||
public static class PacketExtensionProvider extends org.jivesoftware.smack.provider.PacketExtensionProvider<DataPacketExtension> {
|
||||
|
||||
@Override
|
||||
public DataPacketExtension parse(XmlPullParser parser,
|
||||
int initialDepth) throws XmlPullParserException,
|
||||
IOException {
|
||||
String sessionID = parser.getAttributeValue("", "sid");
|
||||
long seq = Long.parseLong(parser.getAttributeValue("", "seq"));
|
||||
String data = parser.nextText();
|
||||
return new DataPacketExtension(sessionID, seq, data);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,22 +16,24 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.ibb.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* Parses an In-Band Bytestream open packet.
|
||||
*
|
||||
* @author Henning Staib
|
||||
*/
|
||||
public class OpenIQProvider implements IQProvider {
|
||||
public class OpenIQProvider extends IQProvider<Open> {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public Open parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
String sessionID = parser.getAttributeValue("", "sid");
|
||||
int blockSize = Integer.parseInt(parser.getAttributeValue("", "block-size"));
|
||||
|
||||
|
@ -44,6 +46,8 @@ public class OpenIQProvider implements IQProvider {
|
|||
stanza = StanzaType.valueOf(stanzaValue.toUpperCase(Locale.US));
|
||||
}
|
||||
|
||||
parser.next();
|
||||
|
||||
return new Open(sessionID, blockSize, stanza);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,19 +16,23 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.socks5.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* Parses a bytestream packet.
|
||||
*
|
||||
* @author Alexander Wenckus
|
||||
*/
|
||||
public class BytestreamsProvider implements IQProvider {
|
||||
public class BytestreamsProvider extends IQProvider<Bytestream> {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public Bytestream parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException {
|
||||
boolean done = false;
|
||||
|
||||
Bytestream toReturn = new Bytestream();
|
||||
|
|
|
@ -19,17 +19,15 @@ package org.jivesoftware.smackx.caps.provider;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.provider.StreamFeatureProvider;
|
||||
import org.jivesoftware.smackx.caps.EntityCapsManager;
|
||||
import org.jivesoftware.smackx.caps.packet.CapsExtension;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class CapsExtensionProvider implements PacketExtensionProvider, StreamFeatureProvider {
|
||||
public class CapsExtensionProvider extends PacketExtensionProvider<CapsExtension> {
|
||||
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws XmlPullParserException, IOException,
|
||||
public CapsExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException,
|
||||
SmackException {
|
||||
String hash = null;
|
||||
String version = null;
|
||||
|
@ -57,9 +55,4 @@ public class CapsExtensionProvider implements PacketExtensionProvider, StreamFea
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketExtension parseStreamFeature(XmlPullParser parser) throws XmlPullParserException,
|
||||
IOException, SmackException {
|
||||
return parseExtension(parser);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,9 +66,10 @@ public class ChatStateExtension implements PacketExtension {
|
|||
return xml;
|
||||
}
|
||||
|
||||
public static class Provider implements PacketExtensionProvider {
|
||||
public static class Provider extends PacketExtensionProvider<ChatStateExtension> {
|
||||
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public ChatStateExtension parse(XmlPullParser parser, int initialDepth) {
|
||||
ChatState state;
|
||||
try {
|
||||
state = ChatState.valueOf(parser.getName());
|
||||
|
|
|
@ -17,8 +17,9 @@
|
|||
|
||||
package org.jivesoftware.smackx.commands.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
|
@ -30,15 +31,18 @@ import org.jivesoftware.smackx.commands.AdHocCommandNote;
|
|||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
import org.jivesoftware.smackx.xdata.provider.DataFormProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* The AdHocCommandDataProvider parses AdHocCommandData packets.
|
||||
*
|
||||
* @author Gabriel Guardincerri
|
||||
*/
|
||||
public class AdHocCommandDataProvider implements IQProvider {
|
||||
public class AdHocCommandDataProvider extends IQProvider<AdHocCommandData> {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public AdHocCommandData parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
boolean done = false;
|
||||
AdHocCommandData adHocCommandData = new AdHocCommandData();
|
||||
DataFormProvider dataFormProvider = new DataFormProvider();
|
||||
|
@ -93,7 +97,7 @@ public class AdHocCommandDataProvider implements IQProvider {
|
|||
adHocCommandData.addAction(AdHocCommand.Action.prev);
|
||||
}
|
||||
else if (elementName.equals("x") && namespace.equals("jabber:x:data")) {
|
||||
adHocCommandData.setForm((DataForm) dataFormProvider.parseExtension(parser));
|
||||
adHocCommandData.setForm((DataForm) dataFormProvider.parse(parser));
|
||||
}
|
||||
else if (parser.getName().equals("note")) {
|
||||
AdHocCommandNote.Type type = AdHocCommandNote.Type.valueOf(
|
||||
|
@ -115,38 +119,44 @@ public class AdHocCommandDataProvider implements IQProvider {
|
|||
return adHocCommandData;
|
||||
}
|
||||
|
||||
public static class BadActionError implements PacketExtensionProvider {
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
public static class BadActionError extends PacketExtensionProvider<AdHocCommandData.SpecificError> {
|
||||
@Override
|
||||
public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) {
|
||||
return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.badAction);
|
||||
}
|
||||
}
|
||||
|
||||
public static class MalformedActionError implements PacketExtensionProvider {
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
public static class MalformedActionError extends PacketExtensionProvider<AdHocCommandData.SpecificError> {
|
||||
@Override
|
||||
public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) {
|
||||
return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.malformedAction);
|
||||
}
|
||||
}
|
||||
|
||||
public static class BadLocaleError implements PacketExtensionProvider {
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
public static class BadLocaleError extends PacketExtensionProvider<AdHocCommandData.SpecificError> {
|
||||
@Override
|
||||
public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) {
|
||||
return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.badLocale);
|
||||
}
|
||||
}
|
||||
|
||||
public static class BadPayloadError implements PacketExtensionProvider {
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
public static class BadPayloadError extends PacketExtensionProvider<AdHocCommandData.SpecificError> {
|
||||
@Override
|
||||
public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) {
|
||||
return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.badPayload);
|
||||
}
|
||||
}
|
||||
|
||||
public static class BadSessionIDError implements PacketExtensionProvider {
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
public static class BadSessionIDError extends PacketExtensionProvider<AdHocCommandData.SpecificError> {
|
||||
@Override
|
||||
public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) {
|
||||
return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.badSessionid);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SessionExpiredError implements PacketExtensionProvider {
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
public static class SessionExpiredError extends PacketExtensionProvider<AdHocCommandData.SpecificError> {
|
||||
@Override
|
||||
public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) {
|
||||
return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.sessionExpired);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,17 +16,22 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.delay.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smackx.delay.packet.DelayInformation;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public abstract class AbstractDelayInformationProvider implements PacketExtensionProvider {
|
||||
public abstract class AbstractDelayInformationProvider extends PacketExtensionProvider<DelayInformation> {
|
||||
|
||||
@Override
|
||||
public final PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
public final DelayInformation parse(XmlPullParser parser,
|
||||
int initialDepth) throws XmlPullParserException,
|
||||
IOException, SmackException {
|
||||
String stampString = (parser.getAttributeValue("", "stamp"));
|
||||
String from = parser.getAttributeValue("", "from");
|
||||
String reason = null;
|
||||
|
@ -46,10 +51,14 @@ public abstract class AbstractDelayInformationProvider implements PacketExtensio
|
|||
} else {
|
||||
parser.next();
|
||||
}
|
||||
assert(parser.getEventType() == XmlPullParser.END_TAG);
|
||||
Date stamp = parseDate(stampString);
|
||||
Date stamp;
|
||||
try {
|
||||
stamp = parseDate(stampString);
|
||||
} catch (ParseException e) {
|
||||
throw new SmackException(e);
|
||||
}
|
||||
return new DelayInformation(stamp, from, reason);
|
||||
}
|
||||
|
||||
protected abstract Date parseDate(String string) throws Exception;
|
||||
protected abstract Date parseDate(String string) throws ParseException;
|
||||
}
|
||||
|
|
|
@ -17,20 +17,25 @@
|
|||
|
||||
package org.jivesoftware.smackx.disco.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* The DiscoverInfoProvider parses Service Discovery information packets.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class DiscoverInfoProvider implements IQProvider {
|
||||
public class DiscoverInfoProvider extends IQProvider<DiscoverInfo> {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public DiscoverInfo parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
DiscoverInfo discoverInfo = new DiscoverInfo();
|
||||
boolean done = false;
|
||||
DiscoverInfo.Identity identity = null;
|
||||
|
|
|
@ -17,19 +17,23 @@
|
|||
|
||||
package org.jivesoftware.smackx.disco.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* The DiscoverInfoProvider parses Service Discovery items packets.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class DiscoverItemsProvider implements IQProvider {
|
||||
public class DiscoverItemsProvider extends IQProvider<DiscoverItems> {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public DiscoverItems parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException {
|
||||
DiscoverItems discoverItems = new DiscoverItems();
|
||||
boolean done = false;
|
||||
DiscoverItems.Item item;
|
||||
|
|
|
@ -16,13 +16,16 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.forward.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.delay.packet.DelayInformation;
|
||||
import org.jivesoftware.smackx.forward.Forwarded;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* This class implements the {@link PacketExtensionProvider} to parse
|
||||
|
@ -30,8 +33,10 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
*
|
||||
* @author Georg Lukas
|
||||
*/
|
||||
public class ForwardedProvider implements PacketExtensionProvider {
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
public class ForwardedProvider extends PacketExtensionProvider<Forwarded> {
|
||||
|
||||
@Override
|
||||
public Forwarded parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
|
||||
DelayInformation di = null;
|
||||
Packet packet = null;
|
||||
|
||||
|
@ -43,13 +48,13 @@ public class ForwardedProvider implements PacketExtensionProvider {
|
|||
di = (DelayInformation)PacketParserUtils.parsePacketExtension(parser.getName(), parser.getNamespace(), parser);
|
||||
else if (parser.getName().equals("message"))
|
||||
packet = PacketParserUtils.parseMessage(parser);
|
||||
else throw new Exception("Unsupported forwarded packet type: " + parser.getName());
|
||||
else throw new SmackException("Unsupported forwarded packet type: " + parser.getName());
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG && parser.getName().equals(Forwarded.ELEMENT))
|
||||
done = true;
|
||||
}
|
||||
if (packet == null)
|
||||
throw new Exception("forwarded extension must contain a packet");
|
||||
throw new SmackException("forwarded extension must contain a packet");
|
||||
return new Forwarded(di, packet);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,13 +100,10 @@ public class LastActivity extends IQ {
|
|||
*
|
||||
* @author Derek DeMoro
|
||||
*/
|
||||
public static class Provider implements IQProvider {
|
||||
public static class Provider extends IQProvider<LastActivity> {
|
||||
|
||||
public Provider() {
|
||||
super();
|
||||
}
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws SmackException, XmlPullParserException {
|
||||
@Override
|
||||
public LastActivity parse(XmlPullParser parser, int initialDepth) throws SmackException, XmlPullParserException {
|
||||
LastActivity lastActivity = new LastActivity();
|
||||
String seconds = parser.getAttributeValue("", "seconds");
|
||||
if (seconds != null) {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package org.jivesoftware.smackx.iqprivate;
|
||||
|
||||
import org.jivesoftware.smack.Manager;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
|
@ -28,7 +29,9 @@ import org.jivesoftware.smackx.iqprivate.packet.DefaultPrivateData;
|
|||
import org.jivesoftware.smackx.iqprivate.packet.PrivateData;
|
||||
import org.jivesoftware.smackx.iqprivate.provider.PrivateDataProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
@ -211,8 +214,11 @@ public class PrivateDataManager extends Manager {
|
|||
/**
|
||||
* An IQ provider to parse IQ results containing private data.
|
||||
*/
|
||||
public static class PrivateDataIQProvider implements IQProvider {
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
public static class PrivateDataIQProvider extends IQProvider<PrivateDataResult> {
|
||||
|
||||
@Override
|
||||
public PrivateDataResult parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
PrivateData privateData = null;
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
|
|
|
@ -17,7 +17,11 @@
|
|||
|
||||
package org.jivesoftware.smackx.iqprivate.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smackx.iqprivate.packet.PrivateData;
|
||||
|
||||
/**
|
||||
|
@ -37,7 +41,6 @@ public interface PrivateDataProvider {
|
|||
*
|
||||
* @param parser an XML parser.
|
||||
* @return a new PrivateData instance.
|
||||
* @throws Exception if an error occurs parsing the XML.
|
||||
*/
|
||||
public PrivateData parsePrivateData(XmlPullParser parser) throws Exception;
|
||||
public PrivateData parsePrivateData(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException;
|
||||
}
|
||||
|
|
|
@ -16,22 +16,26 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.iqregister.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.iqregister.packet.Registration;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class RegistrationProvider implements IQProvider {
|
||||
public class RegistrationProvider extends IQProvider<Registration> {
|
||||
|
||||
@Override
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
public Registration parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
String instruction = null;
|
||||
Map<String, String> fields = new HashMap<String, String>();
|
||||
List<PacketExtension> packetExtensions = new LinkedList<PacketExtension>();
|
||||
|
|
|
@ -16,15 +16,14 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.iqregister.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.StreamFeatureProvider;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smackx.iqregister.packet.Registration;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
public class RegistrationStreamFeatureProvider implements StreamFeatureProvider {
|
||||
public class RegistrationStreamFeatureProvider extends PacketExtensionProvider<Registration.Feature> {
|
||||
|
||||
@Override
|
||||
public PacketExtension parseStreamFeature(XmlPullParser parser) {
|
||||
public Registration.Feature parse(XmlPullParser parser, int initialDepth) {
|
||||
return Registration.Feature.INSTANCE;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,15 +17,18 @@
|
|||
|
||||
package org.jivesoftware.smackx.iqversion.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smackx.iqversion.packet.Version;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class VersionProvider implements IQProvider {
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
assert (parser.getEventType() == XmlPullParser.START_TAG);
|
||||
final int initalDepth = parser.getDepth();
|
||||
public class VersionProvider extends IQProvider<Version> {
|
||||
|
||||
@Override
|
||||
public Version parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
String name = null, version = null, os = null;
|
||||
|
||||
outerloop: while (true) {
|
||||
|
@ -46,7 +49,7 @@ public class VersionProvider implements IQProvider {
|
|||
}
|
||||
break;
|
||||
case XmlPullParser.END_TAG:
|
||||
if (parser.getDepth() == initalDepth && parser.getName().equals(IQ.QUERY_ELEMENT)) {
|
||||
if (parser.getDepth() == initialDepth && parser.getName().equals(IQ.QUERY_ELEMENT)) {
|
||||
break outerloop;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,20 +17,21 @@
|
|||
package org.jivesoftware.smackx.jiveproperties.provider;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.util.stringencoder.Base64;
|
||||
import org.jivesoftware.smackx.jiveproperties.JivePropertiesManager;
|
||||
import org.jivesoftware.smackx.jiveproperties.packet.JivePropertiesExtension;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class JivePropertiesExtensionProvider implements PacketExtensionProvider {
|
||||
public class JivePropertiesExtensionProvider extends PacketExtensionProvider<JivePropertiesExtension> {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(JivePropertiesExtensionProvider.class.getName());
|
||||
|
||||
|
@ -45,10 +46,13 @@ public class JivePropertiesExtensionProvider implements PacketExtensionProvider
|
|||
*
|
||||
* @param parser the XML parser, positioned at the start of a properties sub-packet.
|
||||
* @return a map of the properties.
|
||||
* @throws Exception if an error occurs while parsing the properties.
|
||||
* @throws IOException
|
||||
* @throws XmlPullParserException
|
||||
*/
|
||||
@Override
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
public JivePropertiesExtension parse(XmlPullParser parser,
|
||||
int initialDepth) throws XmlPullParserException,
|
||||
IOException {
|
||||
Map<String, Object> properties = new HashMap<String, Object>();
|
||||
while (true) {
|
||||
int eventType = parser.next();
|
||||
|
|
|
@ -17,11 +17,14 @@
|
|||
|
||||
package org.jivesoftware.smackx.muc.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* A group chat invitation packet extension, which is used to invite other
|
||||
|
@ -125,8 +128,12 @@ public class GroupChatInvitation implements PacketExtension {
|
|||
return packet.getExtension(ELEMENT, NAMESPACE);
|
||||
}
|
||||
|
||||
public static class Provider implements PacketExtensionProvider {
|
||||
public PacketExtension parseExtension (XmlPullParser parser) throws Exception {
|
||||
public static class Provider extends PacketExtensionProvider<GroupChatInvitation> {
|
||||
|
||||
@Override
|
||||
public GroupChatInvitation parse(XmlPullParser parser,
|
||||
int initialDepth) throws XmlPullParserException,
|
||||
IOException {
|
||||
String roomAddress = parser.getAttributeValue("", "jid");
|
||||
// Advance to end of extension.
|
||||
parser.next();
|
||||
|
|
|
@ -17,19 +17,23 @@
|
|||
|
||||
package org.jivesoftware.smackx.muc.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCAdmin;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* The MUCAdminProvider parses MUCAdmin packets. (@see MUCAdmin)
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class MUCAdminProvider implements IQProvider {
|
||||
public class MUCAdminProvider extends IQProvider<MUCAdmin> {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public MUCAdmin parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException {
|
||||
MUCAdmin mucAdmin = new MUCAdmin();
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
|
|
|
@ -17,20 +17,25 @@
|
|||
|
||||
package org.jivesoftware.smackx.muc.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCOwner;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* The MUCOwnerProvider parses MUCOwner packets. (@see MUCOwner)
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class MUCOwnerProvider implements IQProvider {
|
||||
public class MUCOwnerProvider extends IQProvider<MUCOwner> {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public MUCOwner parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
MUCOwner mucOwner = new MUCOwner();
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
|
|
|
@ -16,14 +16,17 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.muc.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smackx.muc.MUCAffiliation;
|
||||
import org.jivesoftware.smackx.muc.MUCRole;
|
||||
import org.jivesoftware.smackx.muc.packet.Destroy;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCItem;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class MUCParserUtils {
|
||||
public static MUCItem parseItem(XmlPullParser parser) throws Exception {
|
||||
public static MUCItem parseItem(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
int initialDepth = parser.getDepth();
|
||||
MUCAffiliation affiliation = MUCAffiliation.fromString(parser.getAttributeValue("", "affiliation"));
|
||||
String nick = parser.getAttributeValue("", "nick");
|
||||
|
@ -54,7 +57,7 @@ public class MUCParserUtils {
|
|||
return new MUCItem(affiliation, role, actor, reason, jid, nick);
|
||||
}
|
||||
|
||||
public static Destroy parseDestroy(XmlPullParser parser) throws Exception {
|
||||
public static Destroy parseDestroy(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
boolean done = false;
|
||||
Destroy destroy = new Destroy();
|
||||
destroy.setJid(parser.getAttributeValue("", "jid"));
|
||||
|
|
|
@ -18,10 +18,12 @@
|
|||
package org.jivesoftware.smackx.muc.provider;
|
||||
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCUser;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* The MUCUserProvider parses packets with extended presence information about
|
||||
|
@ -29,17 +31,18 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class MUCUserProvider implements PacketExtensionProvider {
|
||||
public class MUCUserProvider extends PacketExtensionProvider<MUCUser> {
|
||||
|
||||
/**
|
||||
* Parses a MUCUser packet (extension sub-packet).
|
||||
*
|
||||
* @param parser the XML parser, positioned at the starting element of the extension.
|
||||
* @return a PacketExtension.
|
||||
* @throws Exception if a parsing error occurs.
|
||||
* @throws IOException
|
||||
* @throws XmlPullParserException
|
||||
*/
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
final int initialDepth = parser.getDepth();
|
||||
@Override
|
||||
public MUCUser parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
MUCUser mucUser = new MUCUser();
|
||||
outerloop: while (true) {
|
||||
switch (parser.next()) {
|
||||
|
@ -77,7 +80,7 @@ public class MUCUserProvider implements PacketExtensionProvider {
|
|||
return mucUser;
|
||||
}
|
||||
|
||||
private static MUCUser.Invite parseInvite(XmlPullParser parser) throws Exception {
|
||||
private static MUCUser.Invite parseInvite(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
boolean done = false;
|
||||
MUCUser.Invite invite = new MUCUser.Invite();
|
||||
invite.setFrom(parser.getAttributeValue("", "from"));
|
||||
|
@ -98,7 +101,7 @@ public class MUCUserProvider implements PacketExtensionProvider {
|
|||
return invite;
|
||||
}
|
||||
|
||||
private static MUCUser.Decline parseDecline(XmlPullParser parser) throws Exception {
|
||||
private static MUCUser.Decline parseDecline(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
boolean done = false;
|
||||
MUCUser.Decline decline = new MUCUser.Decline();
|
||||
decline.setFrom(parser.getAttributeValue("", "from"));
|
||||
|
|
|
@ -16,9 +16,12 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.nick.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* A minimalistic implementation of a {@link PacketExtension} for nicknames.
|
||||
|
@ -91,11 +94,12 @@ public class Nick implements PacketExtension {
|
|||
return buf.toString();
|
||||
}
|
||||
|
||||
public static class Provider implements PacketExtensionProvider {
|
||||
public static class Provider extends PacketExtensionProvider<Nick> {
|
||||
|
||||
@Override
|
||||
public Nick parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException {
|
||||
|
||||
public PacketExtension parseExtension(XmlPullParser parser)
|
||||
throws Exception {
|
||||
|
||||
parser.next();
|
||||
final String name = parser.getText();
|
||||
|
||||
|
|
|
@ -17,9 +17,12 @@
|
|||
|
||||
package org.jivesoftware.smackx.offline.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* OfflineMessageInfo is an extension included in the retrieved offline messages requested by
|
||||
|
@ -85,25 +88,20 @@ public class OfflineMessageInfo implements PacketExtension {
|
|||
return buf.toString();
|
||||
}
|
||||
|
||||
public static class Provider implements PacketExtensionProvider {
|
||||
|
||||
/**
|
||||
* Creates a new Provider.
|
||||
* ProviderManager requires that every PacketExtensionProvider has a public,
|
||||
* no-argument constructor
|
||||
*/
|
||||
public Provider() {
|
||||
}
|
||||
public static class Provider extends PacketExtensionProvider<OfflineMessageInfo> {
|
||||
|
||||
/**
|
||||
* Parses a OfflineMessageInfo packet (extension sub-packet).
|
||||
*
|
||||
* @param parser the XML parser, positioned at the starting element of the extension.
|
||||
* @return a PacketExtension.
|
||||
* @throws Exception if a parsing error occurs.
|
||||
* @throws IOException
|
||||
* @throws XmlPullParserException
|
||||
*/
|
||||
public PacketExtension parseExtension(XmlPullParser parser)
|
||||
throws Exception {
|
||||
@Override
|
||||
public OfflineMessageInfo parse(XmlPullParser parser,
|
||||
int initialDepth) throws XmlPullParserException,
|
||||
IOException {
|
||||
OfflineMessageInfo info = new OfflineMessageInfo();
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
|
|
|
@ -20,7 +20,9 @@ package org.jivesoftware.smackx.offline.packet;
|
|||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -187,9 +189,12 @@ public class OfflineMessageRequest extends IQ {
|
|||
}
|
||||
}
|
||||
|
||||
public static class Provider implements IQProvider {
|
||||
public static class Provider extends IQProvider<OfflineMessageRequest> {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public OfflineMessageRequest parse(XmlPullParser parser,
|
||||
int initialDepth) throws XmlPullParserException,
|
||||
IOException {
|
||||
OfflineMessageRequest request = new OfflineMessageRequest();
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
|
@ -214,7 +219,8 @@ public class OfflineMessageRequest extends IQ {
|
|||
return request;
|
||||
}
|
||||
|
||||
private Item parseItem(XmlPullParser parser) throws Exception {
|
||||
private Item parseItem(XmlPullParser parser)
|
||||
throws XmlPullParserException, IOException {
|
||||
boolean done = false;
|
||||
Item item = new Item(parser.getAttributeValue("", "node"));
|
||||
item.setAction(parser.getAttributeValue("", "action"));
|
||||
|
|
|
@ -17,12 +17,15 @@
|
|||
|
||||
package org.jivesoftware.smackx.pep.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -38,19 +41,11 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
*
|
||||
* @author Jeff Williams
|
||||
*/
|
||||
public class PEPProvider implements PacketExtensionProvider {
|
||||
public class PEPProvider extends PacketExtensionProvider<PacketExtension> {
|
||||
|
||||
Map<String, PacketExtensionProvider> nodeParsers = new HashMap<String, PacketExtensionProvider>();
|
||||
PacketExtension pepItem;
|
||||
|
||||
/**
|
||||
* Creates a new PEPProvider.
|
||||
* ProviderManager requires that every PacketExtensionProvider has a public, no-argument constructor
|
||||
*/
|
||||
public PEPProvider() {
|
||||
}
|
||||
private static final Map<String, PacketExtensionProvider<?>> nodeParsers = new HashMap<String, PacketExtensionProvider<?>>();
|
||||
|
||||
public void registerPEPParserExtension(String node, PacketExtensionProvider pepItemParser) {
|
||||
public static void registerPEPParserExtension(String node, PacketExtensionProvider<?> pepItemParser) {
|
||||
nodeParsers.put(node, pepItemParser);
|
||||
}
|
||||
|
||||
|
@ -60,10 +55,14 @@ public class PEPProvider implements PacketExtensionProvider {
|
|||
*
|
||||
* @param parser the XML parser, positioned at the starting element of the extension.
|
||||
* @return a PacketExtension.
|
||||
* @throws Exception if a parsing error occurs.
|
||||
* @throws IOException
|
||||
* @throws XmlPullParserException
|
||||
* @throws SmackException
|
||||
*/
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
|
||||
@Override
|
||||
public PacketExtension parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
PacketExtension pepItem = null;
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
|
@ -73,9 +72,9 @@ public class PEPProvider implements PacketExtensionProvider {
|
|||
// Figure out the node for this event.
|
||||
String node = parser.getAttributeValue("", "node");
|
||||
// Get the parser for this kind of node, and if found then parse the node.
|
||||
PacketExtensionProvider nodeParser = nodeParsers.get(node);
|
||||
PacketExtensionProvider<?> nodeParser = nodeParsers.get(node);
|
||||
if (nodeParser != null) {
|
||||
pepItem = nodeParser.parseExtension(parser);
|
||||
pepItem = nodeParser.parse(parser);
|
||||
}
|
||||
}
|
||||
} else if (eventType == XmlPullParser.END_TAG) {
|
||||
|
|
|
@ -16,14 +16,17 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.ping.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smackx.ping.packet.Ping;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class PingProvider implements IQProvider {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
public class PingProvider extends IQProvider<Ping> {
|
||||
|
||||
@Override
|
||||
public Ping parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
// No need to use the ping constructor with arguments. IQ will already
|
||||
// have filled out all relevant fields ('from', 'to', 'id').
|
||||
return new Ping();
|
||||
|
|
|
@ -17,12 +17,13 @@
|
|||
package org.jivesoftware.smackx.privacy.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.DefaultPacketExtension;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smackx.privacy.packet.Privacy;
|
||||
import org.jivesoftware.smackx.privacy.packet.PrivacyItem;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
|
@ -33,12 +34,11 @@ import java.util.ArrayList;
|
|||
*
|
||||
* @author Francisco Vives
|
||||
*/
|
||||
public class PrivacyProvider implements IQProvider {
|
||||
public class PrivacyProvider extends IQProvider<Privacy> {
|
||||
|
||||
public PrivacyProvider() {
|
||||
}
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public Privacy parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException {
|
||||
Privacy privacy = new Privacy();
|
||||
/* privacy.addExtension(PacketParserUtils.parsePacketExtension(parser
|
||||
.getName(), parser.getNamespace(), parser)); */
|
||||
|
@ -78,7 +78,7 @@ public class PrivacyProvider implements IQProvider {
|
|||
}
|
||||
|
||||
// Parse the list complex type
|
||||
public void parseList(XmlPullParser parser, Privacy privacy) throws Exception {
|
||||
public void parseList(XmlPullParser parser, Privacy privacy) throws XmlPullParserException, IOException {
|
||||
boolean done = false;
|
||||
String listName = parser.getAttributeValue("", "name");
|
||||
ArrayList<PrivacyItem> items = new ArrayList<PrivacyItem>();
|
||||
|
@ -100,7 +100,7 @@ public class PrivacyProvider implements IQProvider {
|
|||
}
|
||||
|
||||
// Parse the list complex type
|
||||
public PrivacyItem parseItem(XmlPullParser parser) throws Exception {
|
||||
public PrivacyItem parseItem(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
boolean done = false;
|
||||
// Retrieves the required attributes
|
||||
String actionValue = parser.getAttributeValue("", "action");
|
||||
|
|
|
@ -29,10 +29,10 @@ import org.jivesoftware.smackx.pubsub.Affiliation;
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class AffiliationProvider extends EmbeddedExtensionProvider
|
||||
public class AffiliationProvider extends EmbeddedExtensionProvider<Affiliation>
|
||||
{
|
||||
@Override
|
||||
protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
protected Affiliation createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
{
|
||||
return new Affiliation(attributeMap.get("node"), Affiliation.Type.valueOf(attributeMap.get("affiliation")));
|
||||
}
|
||||
|
|
|
@ -29,11 +29,11 @@ import org.jivesoftware.smackx.pubsub.AffiliationsExtension;
|
|||
* as specified in the <a href="http://xmpp.org/extensions/xep-0060.html#schemas-pubsub">affiliation schema</a>.
|
||||
*
|
||||
* @author Robin Collier
|
||||
*/public class AffiliationsProvider extends EmbeddedExtensionProvider
|
||||
*/public class AffiliationsProvider extends EmbeddedExtensionProvider<AffiliationsExtension>
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
protected AffiliationsExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
{
|
||||
return new AffiliationsExtension((List<Affiliation>)content);
|
||||
}
|
||||
|
|
|
@ -31,10 +31,10 @@ import org.jivesoftware.smackx.xdata.packet.DataForm;
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class ConfigEventProvider extends EmbeddedExtensionProvider
|
||||
public class ConfigEventProvider extends EmbeddedExtensionProvider<ConfigurationEvent>
|
||||
{
|
||||
@Override
|
||||
protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attMap, List<? extends PacketExtension> content)
|
||||
protected ConfigurationEvent createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attMap, List<? extends PacketExtension> content)
|
||||
{
|
||||
if (content.size() == 0)
|
||||
return new ConfigurationEvent(attMap.get("node"));
|
||||
|
|
|
@ -31,10 +31,10 @@ import org.jivesoftware.smackx.pubsub.NodeExtension;
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class EventProvider extends EmbeddedExtensionProvider
|
||||
public class EventProvider extends EmbeddedExtensionProvider<EventElement>
|
||||
{
|
||||
@Override
|
||||
protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attMap, List<? extends PacketExtension> content)
|
||||
protected EventElement createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attMap, List<? extends PacketExtension> content)
|
||||
{
|
||||
return new EventElement(EventElementType.valueOf(content.get(0).getElementName()), (NodeExtension)content.get(0));
|
||||
}
|
||||
|
|
|
@ -32,10 +32,10 @@ import org.jivesoftware.smackx.xdata.packet.DataForm;
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class FormNodeProvider extends EmbeddedExtensionProvider
|
||||
public class FormNodeProvider extends EmbeddedExtensionProvider<FormNode>
|
||||
{
|
||||
@Override
|
||||
protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
protected FormNode createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
{
|
||||
return new FormNode(FormNodeType.valueOfFromElementName(currentElement, currentNamespace), attributeMap.get("node"), new Form((DataForm)content.iterator().next()));
|
||||
}
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.pubsub.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.provider.ProviderManager;
|
||||
|
@ -25,6 +28,7 @@ import org.jivesoftware.smackx.pubsub.PayloadItem;
|
|||
import org.jivesoftware.smackx.pubsub.SimplePayload;
|
||||
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* Parses an <b>item</b> element as is defined in both the {@link PubSubNamespace#BASIC} and
|
||||
|
@ -34,10 +38,11 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class ItemProvider implements PacketExtensionProvider
|
||||
public class ItemProvider extends PacketExtensionProvider<Item>
|
||||
{
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception
|
||||
{
|
||||
@Override
|
||||
public Item parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
String id = parser.getAttributeValue(null, "id");
|
||||
String node = parser.getAttributeValue(null, "node");
|
||||
|
||||
|
|
|
@ -29,11 +29,11 @@ import org.jivesoftware.smackx.pubsub.ItemsExtension;
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class ItemsProvider extends EmbeddedExtensionProvider
|
||||
public class ItemsProvider extends EmbeddedExtensionProvider<ItemsExtension>
|
||||
{
|
||||
|
||||
@Override
|
||||
protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
protected ItemsExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
{
|
||||
return new ItemsExtension(ItemsExtension.ItemsElementType.items, attributeMap.get("node"), content);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.pubsub.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
|
@ -23,6 +26,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
import org.jivesoftware.smackx.pubsub.packet.PubSub;
|
||||
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* Parses the root pubsub packet extensions of the {@link IQ} packet and returns
|
||||
|
@ -30,10 +34,11 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class PubSubProvider implements IQProvider
|
||||
public class PubSubProvider extends IQProvider<PubSub>
|
||||
{
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception
|
||||
{
|
||||
@Override
|
||||
public PubSub parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
PubSub pubsub = new PubSub();
|
||||
String namespace = parser.getNamespace();
|
||||
pubsub.setPubSubNamespace(PubSubNamespace.valueOfFromXmlns(namespace));
|
||||
|
|
|
@ -30,10 +30,10 @@ import org.jivesoftware.smackx.pubsub.RetractItem;
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class RetractEventProvider extends EmbeddedExtensionProvider
|
||||
public class RetractEventProvider extends EmbeddedExtensionProvider<RetractItem>
|
||||
{
|
||||
@Override
|
||||
protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
protected RetractItem createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
{
|
||||
return new RetractItem(attributeMap.get("id"));
|
||||
}
|
||||
|
|
|
@ -30,10 +30,10 @@ import org.jivesoftware.smackx.pubsub.PubSubElementType;
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class SimpleNodeProvider extends EmbeddedExtensionProvider
|
||||
public class SimpleNodeProvider extends EmbeddedExtensionProvider<NodeExtension>
|
||||
{
|
||||
@Override
|
||||
protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
protected NodeExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
{
|
||||
return new NodeExtension(PubSubElementType.valueOfFromElemName(currentElement, currentNamespace), attributeMap.get("node"));
|
||||
}
|
||||
|
|
|
@ -16,10 +16,12 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.pubsub.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smackx.pubsub.Subscription;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* Parses the <b>subscription</b> element out of the pubsub IQ message from
|
||||
|
@ -27,10 +29,11 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class SubscriptionProvider implements PacketExtensionProvider
|
||||
public class SubscriptionProvider extends PacketExtensionProvider<Subscription>
|
||||
{
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception
|
||||
{
|
||||
@Override
|
||||
public Subscription parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException {
|
||||
String jid = parser.getAttributeValue(null, "jid");
|
||||
String nodeId = parser.getAttributeValue(null, "node");
|
||||
String subId = parser.getAttributeValue(null, "subid");
|
||||
|
|
|
@ -30,11 +30,11 @@ import org.jivesoftware.smackx.pubsub.SubscriptionsExtension;
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class SubscriptionsProvider extends EmbeddedExtensionProvider
|
||||
public class SubscriptionsProvider extends EmbeddedExtensionProvider<SubscriptionsExtension>
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
protected SubscriptionsExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
{
|
||||
return new SubscriptionsExtension(attributeMap.get("node"), (List<Subscription>)content);
|
||||
}
|
||||
|
|
|
@ -89,11 +89,11 @@ public class DeliveryReceipt implements PacketExtension
|
|||
/**
|
||||
* This Provider parses and returns DeliveryReceipt packets.
|
||||
*/
|
||||
public static class Provider extends EmbeddedExtensionProvider
|
||||
public static class Provider extends EmbeddedExtensionProvider<DeliveryReceipt>
|
||||
{
|
||||
|
||||
@Override
|
||||
protected PacketExtension createReturnExtension(String currentElement, String currentNamespace,
|
||||
protected DeliveryReceipt createReturnExtension(String currentElement, String currentNamespace,
|
||||
Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
{
|
||||
return new DeliveryReceipt(attributeMap.get("id"));
|
||||
|
|
|
@ -16,11 +16,14 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.receipts;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* Represents a <b>message delivery receipt request</b> entry as specified by
|
||||
|
@ -86,9 +89,11 @@ public class DeliveryReceiptRequest implements PacketExtension
|
|||
/**
|
||||
* This Provider parses and returns DeliveryReceiptRequest packets.
|
||||
*/
|
||||
public static class Provider implements PacketExtensionProvider {
|
||||
public static class Provider extends PacketExtensionProvider<DeliveryReceiptRequest> {
|
||||
@Override
|
||||
public PacketExtension parseExtension(XmlPullParser parser) {
|
||||
public DeliveryReceiptRequest parse(XmlPullParser parser,
|
||||
int initialDepth) throws XmlPullParserException,
|
||||
IOException {
|
||||
return new DeliveryReceiptRequest();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,19 +16,19 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.rsm.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
import org.jivesoftware.smackx.rsm.packet.RSMSet;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class RSMSetProvider implements PacketExtensionProvider {
|
||||
public class RSMSetProvider extends PacketExtensionProvider<RSMSet> {
|
||||
|
||||
@Override
|
||||
public PacketExtension parseExtension(XmlPullParser parser)
|
||||
throws Exception {
|
||||
int initialDepth = parser.getDepth();
|
||||
|
||||
public RSMSet parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException {
|
||||
String after = null;
|
||||
String before = null;
|
||||
int count = -1;
|
||||
|
|
|
@ -20,7 +20,9 @@ import org.jivesoftware.smack.packet.IQ;
|
|||
import org.jivesoftware.smackx.xdata.Form;
|
||||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -84,7 +86,7 @@ class SimpleUserSearch extends IQ {
|
|||
}
|
||||
}
|
||||
|
||||
protected void parseItems(XmlPullParser parser) throws Exception {
|
||||
protected void parseItems(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
ReportedData data = new ReportedData();
|
||||
data.addColumn(new ReportedData.Column("JID", "jid", "text-single"));
|
||||
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.search;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
|
@ -28,6 +31,7 @@ import org.jivesoftware.smackx.xdata.Form;
|
|||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* Implements the protocol currently used to search information repositories on the Jabber network. To date, the jabber:iq:search protocol
|
||||
|
@ -124,16 +128,11 @@ public class UserSearch extends IQ {
|
|||
/**
|
||||
* Internal Search service Provider.
|
||||
*/
|
||||
public static class Provider implements IQProvider {
|
||||
public static class Provider extends IQProvider<IQ> {
|
||||
|
||||
/**
|
||||
* Provider Constructor.
|
||||
*/
|
||||
public Provider() {
|
||||
super();
|
||||
}
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
// FIXME this provider does return two different types of IQs
|
||||
@Override
|
||||
public IQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
|
||||
UserSearch search = null;
|
||||
SimpleUserSearch simpleUserSearch = new SimpleUserSearch();
|
||||
|
||||
|
@ -169,7 +168,9 @@ public class UserSearch extends IQ {
|
|||
}
|
||||
}
|
||||
|
||||
private static void buildDataForm(SimpleUserSearch search, String instructions, XmlPullParser parser) throws Exception {
|
||||
private static void buildDataForm(SimpleUserSearch search,
|
||||
String instructions, XmlPullParser parser)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
DataForm dataForm = new DataForm(Form.TYPE_FORM);
|
||||
boolean done = false;
|
||||
dataForm.setTitle("User Search");
|
||||
|
|
|
@ -19,7 +19,9 @@ package org.jivesoftware.smackx.sharedgroups.packet;
|
|||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -58,16 +60,11 @@ public class SharedGroupsInfo extends IQ {
|
|||
/**
|
||||
* Internal Search service Provider.
|
||||
*/
|
||||
public static class Provider implements IQProvider {
|
||||
public static class Provider extends IQProvider<SharedGroupsInfo> {
|
||||
|
||||
/**
|
||||
* Provider Constructor.
|
||||
*/
|
||||
public Provider() {
|
||||
super();
|
||||
}
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public SharedGroupsInfo parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException {
|
||||
SharedGroupsInfo groupsInfo = new SharedGroupsInfo();
|
||||
|
||||
boolean done = false;
|
||||
|
|
|
@ -16,20 +16,23 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.shim.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smackx.shim.packet.Header;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* Parses the header element as defined in <a href="http://xmpp.org/extensions/xep-0131">Stanza Headers and Internet Metadata (SHIM)</a>.
|
||||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class HeaderProvider implements PacketExtensionProvider
|
||||
public class HeaderProvider extends PacketExtensionProvider<Header>
|
||||
{
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception
|
||||
{
|
||||
@Override
|
||||
public Header parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException {
|
||||
String name = parser.getAttributeValue(null, "name");
|
||||
String value = null;
|
||||
|
||||
|
|
|
@ -30,11 +30,11 @@ import org.jivesoftware.smackx.shim.packet.HeadersExtension;
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class HeadersProvider extends EmbeddedExtensionProvider
|
||||
public class HeadersProvider extends EmbeddedExtensionProvider<HeadersExtension>
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
protected HeadersExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
|
||||
{
|
||||
return new HeadersExtension((Collection<Header>)content);
|
||||
}
|
||||
|
|
|
@ -16,12 +16,13 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.si.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jxmpp.util.XmppDateTime;
|
||||
import org.jivesoftware.smackx.si.packet.StreamInitiation;
|
||||
|
@ -29,6 +30,7 @@ import org.jivesoftware.smackx.si.packet.StreamInitiation.File;
|
|||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
import org.jivesoftware.smackx.xdata.provider.DataFormProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* The StreamInitiationProvider parses StreamInitiation packets.
|
||||
|
@ -36,10 +38,12 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
* @author Alexander Wenckus
|
||||
*
|
||||
*/
|
||||
public class StreamInitiationProvider implements IQProvider {
|
||||
public class StreamInitiationProvider extends IQProvider<StreamInitiation> {
|
||||
private static final Logger LOGGER = Logger.getLogger(StreamInitiationProvider.class.getName());
|
||||
|
||||
public IQ parseIQ(final XmlPullParser parser) throws Exception {
|
||||
|
||||
@Override
|
||||
public StreamInitiation parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
boolean done = false;
|
||||
|
||||
// si
|
||||
|
@ -79,7 +83,7 @@ public class StreamInitiationProvider implements IQProvider {
|
|||
isRanged = true;
|
||||
} else if (elementName.equals("x")
|
||||
&& namespace.equals("jabber:x:data")) {
|
||||
form = (DataForm) dataFormProvider.parseExtension(parser);
|
||||
form = dataFormProvider.parse(parser);
|
||||
}
|
||||
} else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (elementName.equals("si")) {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.vcardtemp.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smackx.vcardtemp.packet.VCard;
|
||||
|
@ -25,14 +25,17 @@ import org.w3c.dom.Element;
|
|||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.w3c.dom.Text;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
@ -44,12 +47,13 @@ import java.util.logging.Logger;
|
|||
* @author Gaston Dombiak
|
||||
* @author Derek DeMoro
|
||||
*/
|
||||
public class VCardProvider implements IQProvider {
|
||||
public class VCardProvider extends IQProvider<VCard> {
|
||||
private static final Logger LOGGER = Logger.getLogger(VCardProvider.class.getName());
|
||||
|
||||
private static final String PREFERRED_ENCODING = "UTF-8";
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public VCard parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
try {
|
||||
int event = parser.getEventType();
|
||||
|
@ -82,7 +86,11 @@ public class VCardProvider implements IQProvider {
|
|||
}
|
||||
|
||||
String xmlText = sb.toString();
|
||||
return createVCardFromXML(xmlText);
|
||||
try {
|
||||
return createVCardFromXML(xmlText);
|
||||
} catch (SAXException | ParserConfigurationException e) {
|
||||
throw new SmackException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -90,9 +98,12 @@ public class VCardProvider implements IQProvider {
|
|||
*
|
||||
* @param xml the xml representing a users vCard.
|
||||
* @return the VCard.
|
||||
* @throws Exception if an exception occurs.
|
||||
* @throws IOException
|
||||
* @throws SAXException
|
||||
* @throws UnsupportedEncodingException
|
||||
* @throws ParserConfigurationException
|
||||
*/
|
||||
public static VCard createVCardFromXML(String xml) throws Exception {
|
||||
public static VCard createVCardFromXML(String xml) throws UnsupportedEncodingException, SAXException, IOException, ParserConfigurationException {
|
||||
VCard vCard = new VCard();
|
||||
|
||||
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||
|
|
|
@ -17,14 +17,15 @@
|
|||
|
||||
package org.jivesoftware.smackx.xdata.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.RosterPacket;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -33,16 +34,10 @@ import java.util.List;
|
|||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class DataFormProvider implements PacketExtensionProvider {
|
||||
public class DataFormProvider extends PacketExtensionProvider<DataForm> {
|
||||
|
||||
/**
|
||||
* Creates a new DataFormProvider.
|
||||
* ProviderManager requires that every PacketExtensionProvider has a public, no-argument constructor
|
||||
*/
|
||||
public DataFormProvider() {
|
||||
}
|
||||
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public DataForm parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
boolean done = false;
|
||||
DataForm dataForm = new DataForm(parser.getAttributeValue("", "type"));
|
||||
while (!done) {
|
||||
|
@ -76,7 +71,7 @@ public class DataFormProvider implements PacketExtensionProvider {
|
|||
return dataForm;
|
||||
}
|
||||
|
||||
private FormField parseField(XmlPullParser parser) throws Exception {
|
||||
private FormField parseField(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
boolean done = false;
|
||||
FormField formField = new FormField(parser.getAttributeValue("", "var"));
|
||||
formField.setLabel(parser.getAttributeValue("", "label"));
|
||||
|
@ -105,7 +100,7 @@ public class DataFormProvider implements PacketExtensionProvider {
|
|||
return formField;
|
||||
}
|
||||
|
||||
private DataForm.Item parseItem(XmlPullParser parser) throws Exception {
|
||||
private DataForm.Item parseItem(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
boolean done = false;
|
||||
List<FormField> fields = new ArrayList<FormField>();
|
||||
while (!done) {
|
||||
|
@ -123,7 +118,7 @@ public class DataFormProvider implements PacketExtensionProvider {
|
|||
return new DataForm.Item(fields);
|
||||
}
|
||||
|
||||
private DataForm.ReportedData parseReported(XmlPullParser parser) throws Exception {
|
||||
private DataForm.ReportedData parseReported(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
boolean done = false;
|
||||
List<FormField> fields = new ArrayList<FormField>();
|
||||
while (!done) {
|
||||
|
@ -141,7 +136,7 @@ public class DataFormProvider implements PacketExtensionProvider {
|
|||
return new DataForm.ReportedData(fields);
|
||||
}
|
||||
|
||||
private FormField.Option parseOption(XmlPullParser parser) throws Exception {
|
||||
private FormField.Option parseOption(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
boolean done = false;
|
||||
FormField.Option option = null;
|
||||
String label = parser.getAttributeValue("", "label");
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package org.jivesoftware.smackx.xhtmlim.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.xhtmlim.packet.XHTMLExtension;
|
||||
|
@ -31,12 +30,12 @@ import java.io.IOException;
|
|||
*
|
||||
* @author Florian Schmaus
|
||||
*/
|
||||
public class XHTMLExtensionProvider implements PacketExtensionProvider {
|
||||
public class XHTMLExtensionProvider extends PacketExtensionProvider<XHTMLExtension> {
|
||||
|
||||
@Override
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws IOException, XmlPullParserException {
|
||||
public XHTMLExtension parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException {
|
||||
XHTMLExtension xhtmlExtension = new XHTMLExtension();
|
||||
|
||||
int startDepth = parser.getDepth();
|
||||
while (true) {
|
||||
int eventType = parser.getEventType();
|
||||
String name = parser.getName();
|
||||
|
@ -45,7 +44,7 @@ public class XHTMLExtensionProvider implements PacketExtensionProvider {
|
|||
xhtmlExtension.addBody(PacketParserUtils.parseElement(parser));
|
||||
}
|
||||
} else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (name.equals(XHTMLExtension.ELEMENT) && parser.getDepth() <= startDepth) {
|
||||
if (parser.getDepth() == initialDepth) {
|
||||
return xhtmlExtension;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@
|
|||
<iqProvider>
|
||||
<elementName>data</elementName>
|
||||
<namespace>http://jabber.org/protocol/ibb</namespace>
|
||||
<className>org.jivesoftware.smackx.bytestreams.ibb.provider.DataPacketProvider</className>
|
||||
<className>org.jivesoftware.smackx.bytestreams.ibb.provider.DataPacketProvider$IQProvider</className>
|
||||
</iqProvider>
|
||||
|
||||
<iqProvider>
|
||||
|
@ -206,7 +206,7 @@
|
|||
<extensionProvider>
|
||||
<elementName>data</elementName>
|
||||
<namespace>http://jabber.org/protocol/ibb</namespace>
|
||||
<className>org.jivesoftware.smackx.bytestreams.ibb.provider.DataPacketProvider</className>
|
||||
<className>org.jivesoftware.smackx.bytestreams.ibb.provider.DataPacketProvider$PacketExtensionProvider</className>
|
||||
</extensionProvider>
|
||||
|
||||
<!-- Ad-Hoc Command -->
|
||||
|
|
|
@ -70,7 +70,7 @@ public class AMPExtensionTest {
|
|||
assertEquals(XmlPullParser.START_TAG, parser.next());
|
||||
assertEquals(AMPExtension.ELEMENT, parser.getName());
|
||||
|
||||
PacketExtension extension = ampProvider.parseExtension(parser);
|
||||
PacketExtension extension = ampProvider.parse(parser);
|
||||
assertTrue(extension instanceof AMPExtension);
|
||||
AMPExtension amp = (AMPExtension) extension;
|
||||
|
||||
|
@ -89,7 +89,7 @@ public class AMPExtensionTest {
|
|||
|
||||
assertEquals(XmlPullParser.START_TAG, parser.next());
|
||||
assertEquals(AMPExtension.ELEMENT, parser.getName());
|
||||
PacketExtension extension = ampProvider.parseExtension(parser);
|
||||
PacketExtension extension = ampProvider.parse(parser);
|
||||
assertTrue(extension instanceof AMPExtension);
|
||||
AMPExtension amp = (AMPExtension) extension;
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ public class OpenIQProviderTest {
|
|||
.asString(outputProperties);
|
||||
|
||||
OpenIQProvider oip = new OpenIQProvider();
|
||||
Open open = (Open) oip.parseIQ(getParser(control));
|
||||
Open open = oip.parse(getParser(control));
|
||||
|
||||
assertEquals(StanzaType.IQ, open.getStanza());
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class OpenIQProviderTest {
|
|||
.asString(outputProperties);
|
||||
|
||||
OpenIQProvider oip = new OpenIQProvider();
|
||||
Open open = (Open) oip.parseIQ(getParser(control));
|
||||
Open open = oip.parse(getParser(control));
|
||||
|
||||
assertEquals(StanzaType.MESSAGE, open.getStanza());
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
.asString(outputProperties);
|
||||
|
||||
parser = PacketParserUtils.getParserFor(control);
|
||||
delayInfo = (DelayInformation) p.parseExtension(parser);
|
||||
delayInfo = (DelayInformation) p.parse(parser);
|
||||
|
||||
assertEquals("capulet.com", delayInfo.getFrom());
|
||||
assertEquals(date, delayInfo.getStamp());
|
||||
|
@ -85,7 +85,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
.asString(outputProperties);
|
||||
|
||||
parser = PacketParserUtils.getParserFor(control);
|
||||
delayInfo = (DelayInformation) p.parseExtension(parser);
|
||||
delayInfo = (DelayInformation) p.parse(parser);
|
||||
|
||||
assertEquals("capulet.com", delayInfo.getFrom());
|
||||
assertEquals(date, delayInfo.getStamp());
|
||||
|
@ -109,7 +109,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
.a("stamp", "2002-09-10T23:08:25.12Z")
|
||||
.asString(outputProperties);
|
||||
|
||||
delayInfo = (DelayInformation) p.parseExtension(PacketParserUtils.getParserFor(control));
|
||||
delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control));
|
||||
|
||||
GregorianCalendar cal = (GregorianCalendar) calendar.clone();
|
||||
cal.add(Calendar.MILLISECOND, 12);
|
||||
|
@ -122,7 +122,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
.a("stamp", "2002-09-10T23:08:25Z")
|
||||
.asString(outputProperties);
|
||||
|
||||
delayInfo = (DelayInformation) p.parseExtension(PacketParserUtils.getParserFor(control));
|
||||
delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control));
|
||||
|
||||
assertEquals(calendar.getTime(), delayInfo.getStamp());
|
||||
|
||||
|
@ -133,7 +133,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
.a("stamp", "2002-9-10T23:08:25Z")
|
||||
.asString(outputProperties);
|
||||
|
||||
delayInfo = (DelayInformation) p.parseExtension(PacketParserUtils.getParserFor(control));
|
||||
delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control));
|
||||
|
||||
assertEquals(calendar.getTime(), delayInfo.getStamp());
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
.a("stamp", "20020910T23:08:25")
|
||||
.asString(outputProperties);
|
||||
|
||||
delayInfo = (DelayInformation) p.parseExtension(PacketParserUtils.getParserFor(control));
|
||||
delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control));
|
||||
|
||||
assertEquals(calendar.getTime(), delayInfo.getStamp());
|
||||
|
||||
|
@ -172,7 +172,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
.a("stamp", dateFormat.format(dateInPast.getTime()))
|
||||
.asString(outputProperties);
|
||||
|
||||
delayInfo = (DelayInformation) p.parseExtension(PacketParserUtils.getParserFor(control));
|
||||
delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control));
|
||||
|
||||
assertEquals(dateInPast.getTime(), delayInfo.getStamp());
|
||||
|
||||
|
@ -183,7 +183,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
.a("stamp", "200868T09:16:20")
|
||||
.asString(outputProperties);
|
||||
|
||||
delayInfo = (DelayInformation) p.parseExtension(PacketParserUtils.getParserFor(control));
|
||||
delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control));
|
||||
Date controlDate = XmppDateTime.parseDate("2008-06-08T09:16:20.0Z");
|
||||
|
||||
assertEquals(controlDate, delayInfo.getStamp());
|
||||
|
|
|
@ -47,7 +47,7 @@ public class ForwardedTest {
|
|||
.asString(outputProperties);
|
||||
|
||||
parser = PacketParserUtils.getParserFor(control);
|
||||
fwd = (Forwarded) new ForwardedProvider().parseExtension(parser);
|
||||
fwd = (Forwarded) new ForwardedProvider().parse(parser);
|
||||
|
||||
// no delay in packet
|
||||
assertEquals(null, fwd.getDelayInformation());
|
||||
|
@ -71,6 +71,6 @@ public class ForwardedTest {
|
|||
.asString(outputProperties);
|
||||
|
||||
parser = PacketParserUtils.getParserFor(control);
|
||||
new ForwardedProvider().parseExtension(parser);
|
||||
new ForwardedProvider().parse(parser);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class XHTMLExtensionProviderTest {
|
|||
parser.next();
|
||||
|
||||
XHTMLExtensionProvider provider = new XHTMLExtensionProvider();
|
||||
PacketExtension extension = provider.parseExtension(parser);
|
||||
PacketExtension extension = provider.parse(parser, parser.getDepth());
|
||||
|
||||
assertThat(extension, instanceOf(XHTMLExtension.class));
|
||||
XHTMLExtension attachmentsInfo = (XHTMLExtension) extension;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue