1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-29 09:42:06 +01:00

Remove DataFormProvider from extension.providers

XEP-141 Data Forms are never used as stand alone packet extension, there
is no need to register the provider with the ProviderManager.

This makes the parse method of DataFormProvider static.
This commit is contained in:
Florian Schmaus 2014-11-20 23:52:01 +01:00
parent ff977825da
commit bf557d498b
4 changed files with 5 additions and 25 deletions

View file

@ -68,7 +68,7 @@ public class DataFormProvider extends PacketExtensionProvider<DataForm> {
}
// See XEP-141 Data Forms Layout
else if (parser.getName().equals(DataLayout.ELEMENT) && parser.getNamespace().equals(DataLayout.NAMESPACE)) {
dataForm.addExtensionElement(DataLayoutProvider.INSTANCE.parse(parser));
dataForm.addExtensionElement(DataLayoutProvider.parse(parser));
}
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals(dataForm.getElementName())) {

View file

@ -20,7 +20,6 @@ import java.io.IOException;
import java.util.List;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.provider.PacketExtensionProvider;
import org.jivesoftware.smackx.xdatalayout.packet.DataLayout;
import org.jivesoftware.smackx.xdatalayout.packet.DataLayout.DataFormLayoutElement;
import org.jivesoftware.smackx.xdatalayout.packet.DataLayout.Fieldref;
@ -36,16 +35,9 @@ import org.xmlpull.v1.XmlPullParserException;
* @author Anno van Vliet
*
*/
public class DataLayoutProvider extends PacketExtensionProvider<DataLayout> {
public class DataLayoutProvider {
public static final DataLayoutProvider INSTANCE = new DataLayoutProvider();
/* (non-Javadoc)
* @see org.jivesoftware.smack.provider.Provider#parse(org.xmlpull.v1.XmlPullParser, int)
*/
@Override
public DataLayout parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException,
public static DataLayout parse(XmlPullParser parser) throws XmlPullParserException, IOException,
SmackException {
DataLayout dataLayout = new DataLayout(parser.getAttributeValue("", "label"));
parseLayout(dataLayout.getPageLayout(), parser);

View file

@ -481,12 +481,4 @@
<namespace>http://jabber.org/protocol/rsm</namespace>
<className>org.jivesoftware.smackx.rsm.provider.RSMSetProvider</className>
</extensionProvider>
<!-- XEP-141: Data Forms Layout-->
<extensionProvider>
<elementName>page</elementName>
<namespace>http://jabber.org/protocol/xdata-layout</namespace>
<className>org.jivesoftware.smackx.xdatalayout.provider.DataLayoutProvider</className>
</extensionProvider>
</smackProviders>

View file

@ -66,11 +66,9 @@ public class DataLayoutTest {
logger.finest(output);
assertEquals(TEST_OUTPUT_2, output);
DataLayoutProvider pr = DataLayoutProvider.INSTANCE;
XmlPullParser parser = getParser(output);
layout = pr.parse(parser);
layout = DataLayoutProvider.parse(parser);
assertEquals(3 , layout.getPageLayout().size());
assertEquals("Label", layout.getLabel());
@ -106,11 +104,9 @@ public class DataLayoutTest {
logger.finest(output);
assertEquals(TEST_OUTPUT_SPECIAL, output);
DataLayoutProvider pr = DataLayoutProvider.INSTANCE;
XmlPullParser parser = getParser(output);
layout = pr.parse(parser);
layout = DataLayoutProvider.parse(parser);
assertEquals(5 , layout.getPageLayout().size());
assertEquals("Label - & \u00E9 \u00E1 ", layout.getLabel());