1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 06:12:05 +01:00

Factor NickProvider in extra file and fill under correct package

This commit is contained in:
Florian Schmaus 2018-10-21 09:31:15 +02:00
parent 382057f520
commit 2ee621ed10
4 changed files with 59 additions and 18 deletions

View file

@ -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<Nick> {
@Override
public Nick parse(XmlPullParser parser, int initialDepth)
throws XmlPullParserException, IOException {
final String name = parser.nextText();
return new Nick(name);
}
}
}

View file

@ -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<Nick> {
@Override
public Nick parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
String name = parser.nextText();
return new Nick(name);
}
}

View file

@ -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;

View file

@ -411,7 +411,7 @@
<extensionProvider>
<elementName>nick</elementName>
<namespace>http://jabber.org/protocol/nick</namespace>
<className>org.jivesoftware.smackx.nick.packet.Nick$Provider</className>
<className>org.jivesoftware.smackx.nick.provider.NickProvider</className>
</extensionProvider>
<!-- Attention -->