mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-24 23:32:05 +01:00
[smack-xmlparser] Allow override of used XmlPullParserFactory
This commit is contained in:
parent
3bef905ef5
commit
4adbd21a0f
1 changed files with 12 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2019 Florian Schmaus.
|
||||
* Copyright 2019-2021 Florian Schmaus.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -28,7 +28,14 @@ public class SmackXmlParser {
|
|||
xmlPullParserFactoryServiceLoader = ServiceLoader.load(XmlPullParserFactory.class);
|
||||
}
|
||||
|
||||
private static XmlPullParserFactory xmlPullParserFactory;
|
||||
|
||||
public static XmlPullParserFactory getXmlPullParserFactory() {
|
||||
final XmlPullParserFactory xmlPullParserFactory = SmackXmlParser.xmlPullParserFactory;
|
||||
if (xmlPullParserFactory != null) {
|
||||
return xmlPullParserFactory;
|
||||
}
|
||||
|
||||
Iterator<XmlPullParserFactory> iterator = xmlPullParserFactoryServiceLoader.iterator();
|
||||
if (!iterator.hasNext()) {
|
||||
throw new IllegalStateException(
|
||||
|
@ -37,6 +44,10 @@ public class SmackXmlParser {
|
|||
return iterator.next();
|
||||
}
|
||||
|
||||
public static void setXmlPullParserFactory(XmlPullParserFactory xmlPullParserFactory) {
|
||||
SmackXmlParser.xmlPullParserFactory = xmlPullParserFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new XmlPullParser suitable for parsing XMPP. This means in particular that
|
||||
* FEATURE_PROCESS_NAMESPACES is enabled.
|
||||
|
|
Loading…
Reference in a new issue