导航菜单

页面标题

页面副标题

bbinstant v6.24.0 - StreamInitiation.java 源代码

正在查看: bbinstant v6.24.0 应用的 StreamInitiation.java JAVA 源代码文件

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


package org.jivesoftware.smackx.si.packet;

import java.util.Date;
import org.apache.commons.text.lookup.StringLookupFactory;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.filetransfer.FileTransferNegotiator;
import org.jivesoftware.smackx.message_correct.element.MessageCorrectExtension;
import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jxmpp.util.XmppDateTime;

public class StreamInitiation extends IQ {
    public static final String ELEMENT = "si";
    public static final String NAMESPACE = "http://jabber.org/protocol/si";
    private Feature featureNegotiation;
    private File file;
    private String id;
    private String mimeType;

    static class AnonymousClass1 {
        static final int[] $SwitchMap$org$jivesoftware$smack$packet$IQ$Type;

        static {
            int[] iArr = new int[IQ.Type.values().length];
            $SwitchMap$org$jivesoftware$smack$packet$IQ$Type = iArr;
            try {
                iArr[IQ.Type.set.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                $SwitchMap$org$jivesoftware$smack$packet$IQ$Type[IQ.Type.result.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
        }
    }

    public static class Feature implements ExtensionElement {
        private final DataForm data;

        public Feature(DataForm dataForm) {
            this.data = dataForm;
        }

        public DataForm getData() {
            return this.data;
        }

        @Override
        public String getElementName() {
            return "feature";
        }

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

        @Override
        public String toXML() {
            return "<feature xmlns=\"http://jabber.org/protocol/feature-neg\">" + ((CharSequence) this.data.toXML()) + "</feature>";
        }
    }

    public static class File implements ExtensionElement {
        private Date date;
        private String desc;
        private String hash;
        private boolean isRanged;
        private final String name;
        private final long size;

        public File(String str, long j) {
            if (str == null) {
                throw new NullPointerException("name cannot be null");
            }
            this.name = str;
            this.size = j;
        }

        public Date getDate() {
            return this.date;
        }

        public String getDesc() {
            return this.desc;
        }

        @Override
        public String getElementName() {
            return StringLookupFactory.KEY_FILE;
        }

        public String getHash() {
            return this.hash;
        }

        public String getName() {
            return this.name;
        }

        @Override
        public String getNamespace() {
            return FileTransferNegotiator.SI_PROFILE_FILE_TRANSFER_NAMESPACE;
        }

        public long getSize() {
            return this.size;
        }

        public boolean isRanged() {
            return this.isRanged;
        }

        public void setDate(Date date) {
            this.date = date;
        }

        public void setDesc(String str) {
            this.desc = str;
        }

        public void setHash(String str) {
            this.hash = str;
        }

        public void setRanged(boolean z) {
            this.isRanged = z;
        }

        @Override
        public String toXML() {
            StringBuilder sb = new StringBuilder();
            sb.append('<');
            sb.append(getElementName());
            sb.append(" xmlns=\"");
            sb.append(getNamespace());
            sb.append("\" ");
            if (getName() != null) {
                sb.append("name=\"");
                sb.append(StringUtils.escapeForXmlAttribute(getName()));
                sb.append("\" ");
            }
            if (getSize() > 0) {
                sb.append("size=\"");
                sb.append(getSize());
                sb.append("\" ");
            }
            if (getDate() != null) {
                sb.append("date=\"");
                sb.append(XmppDateTime.formatXEP0082Date(this.date));
                sb.append("\" ");
            }
            if (getHash() != null) {
                sb.append("hash=\"");
                sb.append(getHash());
                sb.append("\" ");
            }
            String str = this.desc;
            if ((str == null || str.length() <= 0) && !this.isRanged) {
                sb.append("/>");
            } else {
                sb.append('>');
                if (getDesc() != null && this.desc.length() > 0) {
                    sb.append("<desc>");
                    sb.append(StringUtils.escapeForXmlText(getDesc()));
                    sb.append("</desc>");
                }
                if (isRanged()) {
                    sb.append("<range/>");
                }
                sb.append("</");
                sb.append(getElementName());
                sb.append('>');
            }
            return sb.toString();
        }
    }

    public StreamInitiation() {
        super(ELEMENT, "http://jabber.org/protocol/si");
    }

    public DataForm getFeatureNegotiationForm() {
        return this.featureNegotiation.getData();
    }

    public File getFile() {
        return this.file;
    }

    @Override
    protected IQ.IQChildElementXmlStringBuilder getIQChildElementBuilder(IQ.IQChildElementXmlStringBuilder iQChildElementXmlStringBuilder) {
        int i = AnonymousClass1.$SwitchMap$org$jivesoftware$smack$packet$IQ$Type[getType().ordinal()];
        if (i == 1) {
            iQChildElementXmlStringBuilder.optAttribute(MessageCorrectExtension.ID_TAG, getSessionID());
            iQChildElementXmlStringBuilder.optAttribute("mime-type", getMimeType());
            iQChildElementXmlStringBuilder.attribute("profile", FileTransferNegotiator.SI_PROFILE_FILE_TRANSFER_NAMESPACE);
            iQChildElementXmlStringBuilder.rightAngleBracket();
            iQChildElementXmlStringBuilder.optAppend(this.file.toXML());
        } else {
            if (i != 2) {
                throw new IllegalArgumentException("IQ Type not understood");
            }
            iQChildElementXmlStringBuilder.rightAngleBracket();
        }
        Feature feature = this.featureNegotiation;
        if (feature != null) {
            iQChildElementXmlStringBuilder.append((CharSequence) feature.toXML());
        }
        return iQChildElementXmlStringBuilder;
    }

    public String getMimeType() {
        return this.mimeType;
    }

    public String getSessionID() {
        return this.id;
    }

    public void setFeatureNegotiationForm(DataForm dataForm) {
        this.featureNegotiation = new Feature(dataForm);
    }

    public void setFile(File file) {
        this.file = file;
    }

    public void setMimeType(String str) {
        this.mimeType = str;
    }

    public void setSessionID(String str) {
        this.id = str;
    }
}