导航菜单

页面标题

页面副标题

Housing v14.7.8 - ChatStateExtension.java 源代码

正在查看: Housing v14.7.8 应用的 ChatStateExtension.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package org.jivesoftware.smackx.chatstates.packet;

import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smackx.chatstates.ChatState;
import org.xmlpull.v1.XmlPullParser;

public class ChatStateExtension implements ExtensionElement {
    public static final String NAMESPACE = "http://jabber.org/protocol/chatstates";
    private final ChatState state;

    public static class Provider extends ExtensionElementProvider<ChatStateExtension> {
        @Override
        public ChatStateExtension parse(XmlPullParser xmlPullParser, int i) {
            ChatState chatState;
            try {
                chatState = ChatState.valueOf(xmlPullParser.getName());
            } catch (Exception unused) {
                chatState = ChatState.active;
            }
            return new ChatStateExtension(chatState);
        }
    }

    public ChatStateExtension(ChatState chatState) {
        this.state = chatState;
    }

    public ChatState getChatState() {
        return this.state;
    }

    @Override
    public String getElementName() {
        return this.state.name();
    }

    @Override
    public String getNamespace() {
        return "http://jabber.org/protocol/chatstates";
    }

    @Override
    public XmlStringBuilder toXML() {
        XmlStringBuilder xmlStringBuilder = new XmlStringBuilder((ExtensionElement) this);
        xmlStringBuilder.closeEmptyElement();
        return xmlStringBuilder;
    }
}