2003-05-08 17:53:40 +02:00
|
|
|
/**
|
|
|
|
*
|
2007-02-12 01:59:05 +01:00
|
|
|
* Copyright 2003-2007 Jive Software.
|
2003-05-08 17:53:40 +02:00
|
|
|
*
|
2014-02-17 18:57:38 +01:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
2004-11-03 00:53:30 +01:00
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2003-05-08 17:53:40 +02:00
|
|
|
*
|
2004-11-03 00:53:30 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2003-05-08 17:53:40 +02:00
|
|
|
*
|
2004-11-03 00:53:30 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2003-05-08 17:53:40 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
package org.jivesoftware.smack.provider;
|
|
|
|
|
2019-10-29 11:14:55 +01:00
|
|
|
import java.io.IOException;
|
|
|
|
|
2003-05-08 17:53:40 +02:00
|
|
|
import org.jivesoftware.smack.packet.IQ;
|
2019-10-29 19:21:31 +01:00
|
|
|
import org.jivesoftware.smack.packet.IqData;
|
2019-10-29 11:14:55 +01:00
|
|
|
import org.jivesoftware.smack.packet.XmlEnvironment;
|
|
|
|
import org.jivesoftware.smack.parsing.SmackParsingException;
|
|
|
|
import org.jivesoftware.smack.util.ParserUtils;
|
|
|
|
import org.jivesoftware.smack.xml.XmlPullParser;
|
|
|
|
import org.jivesoftware.smack.xml.XmlPullParserException;
|
2003-05-08 17:53:40 +02:00
|
|
|
|
|
|
|
/**
|
2019-10-29 11:14:55 +01:00
|
|
|
* <p>
|
|
|
|
* <b>Deprecation Notice:</b> This class is deprecated, use {@link IQProvider} instead.
|
|
|
|
* </p>
|
2014-10-07 21:15:20 +02:00
|
|
|
* An abstract class for parsing custom IQ packets. Each IQProvider must be registered with
|
2003-05-08 17:53:40 +02:00
|
|
|
* the ProviderManager class for it to be used. Every implementation of this
|
2014-10-07 21:15:20 +02:00
|
|
|
* abstract class <b>must</b> have a public, no-argument constructor.
|
2003-05-08 17:53:40 +02:00
|
|
|
*
|
|
|
|
* @author Matt Tucker
|
|
|
|
*/
|
2019-10-29 11:14:55 +01:00
|
|
|
public abstract class IQProvider<I extends IQ> extends IqProvider<I> {
|
|
|
|
|
|
|
|
public final I parse(XmlPullParser parser) throws IOException, XmlPullParserException, SmackParsingException {
|
|
|
|
return parse(parser, (XmlEnvironment) null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final I parse(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws IOException, XmlPullParserException, SmackParsingException {
|
|
|
|
// XPP3 calling convention assert: Parser should be at start tag
|
|
|
|
ParserUtils.assertAtStartTag(parser);
|
|
|
|
|
|
|
|
final int initialDepth = parser.getDepth();
|
|
|
|
final XmlEnvironment xmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
|
|
|
|
|
|
|
|
I e = parse(parser, initialDepth, xmlEnvironment);
|
|
|
|
|
|
|
|
// XPP3 calling convention assert: Parser should be at end tag of the consumed/parsed element
|
|
|
|
ParserUtils.forwardToEndTagOfDepth(parser, initialDepth);
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-10-29 19:21:31 +01:00
|
|
|
public final I parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment)
|
2019-10-29 11:14:55 +01:00
|
|
|
throws XmlPullParserException, IOException, SmackParsingException {
|
|
|
|
// Old-style IQ parsers do not need IqData.
|
|
|
|
return parse(parser, initialDepth, xmlEnvironment);
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract I parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException;
|
2003-05-08 17:53:40 +02:00
|
|
|
|
2014-02-17 23:58:40 +01:00
|
|
|
}
|