From 2ee621ed10e4d55a46a9215f3148d39fc83c1cec Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 21 Oct 2018 09:31:15 +0200 Subject: [PATCH] Factor NickProvider in extra file and fill under correct package --- .../jivesoftware/smackx/nick/packet/Nick.java | 17 --------- .../smackx/nick/provider/NickProvider.java | 37 +++++++++++++++++++ .../smackx/nick/provider/package-info.java | 21 +++++++++++ .../extensions.providers | 2 +- 4 files changed, 59 insertions(+), 18 deletions(-) create mode 100644 smack-extensions/src/main/java/org/jivesoftware/smackx/nick/provider/NickProvider.java create mode 100644 smack-extensions/src/main/java/org/jivesoftware/smackx/nick/provider/package-info.java diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/nick/packet/Nick.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/nick/packet/Nick.java index c9cfd4486..78f7507d7 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/nick/packet/Nick.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/nick/packet/Nick.java @@ -16,16 +16,10 @@ */ package org.jivesoftware.smackx.nick.packet; -import java.io.IOException; - import org.jivesoftware.smack.packet.ExtensionElement; -import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smack.util.XmlStringBuilder; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - /** * A minimalistic implementation of a {@link ExtensionElement} for nicknames. * @@ -73,15 +67,4 @@ public class Nick implements ExtensionElement { xml.closeElement(this); return xml; } - - public static class Provider extends ExtensionElementProvider { - - @Override - public Nick parse(XmlPullParser parser, int initialDepth) - throws XmlPullParserException, IOException { - final String name = parser.nextText(); - - return new Nick(name); - } - } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/nick/provider/NickProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/nick/provider/NickProvider.java new file mode 100644 index 000000000..8267b283e --- /dev/null +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/nick/provider/NickProvider.java @@ -0,0 +1,37 @@ +/** + * + * Copyright 2003-2007 Jive Software, 2018 Florian Schmaus. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + */ +package org.jivesoftware.smackx.nick.provider; + +import java.io.IOException; + +import org.jivesoftware.smack.provider.ExtensionElementProvider; + +import org.jivesoftware.smackx.nick.packet.Nick; + +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; + +public class NickProvider extends ExtensionElementProvider { + + @Override + public Nick parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { + String name = parser.nextText(); + + return new Nick(name); + } + +} diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/nick/provider/package-info.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/nick/provider/package-info.java new file mode 100644 index 000000000..c11f0db69 --- /dev/null +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/nick/provider/package-info.java @@ -0,0 +1,21 @@ +/** + * + * Copyright 2018 Florian Schmaus + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + */ + +/** + * Providers for XEP-0172: User Nickname. + */ +package org.jivesoftware.smackx.nick.provider; diff --git a/smack-extensions/src/main/resources/org.jivesoftware.smack.extensions/extensions.providers b/smack-extensions/src/main/resources/org.jivesoftware.smack.extensions/extensions.providers index fd1ca42de..806686f50 100644 --- a/smack-extensions/src/main/resources/org.jivesoftware.smack.extensions/extensions.providers +++ b/smack-extensions/src/main/resources/org.jivesoftware.smack.extensions/extensions.providers @@ -411,7 +411,7 @@ nick http://jabber.org/protocol/nick - org.jivesoftware.smackx.nick.packet.Nick$Provider + org.jivesoftware.smackx.nick.provider.NickProvider