导航菜单

页面标题

页面副标题

95爱播免登录版 v3.1.9 - DiscoverInfo.java 源代码

正在查看: 95爱播免登录版 v3.1.9 应用的 DiscoverInfo.java JAVA 源代码文件

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


package org.jivesoftware.smackx.packet;

import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.util.StringUtils;

public class DiscoverInfo extends IQ {
    public static final String NAMESPACE = "http://jabber.org/protocol/disco#info";
    private final List<Feature> features;
    private final List<Identity> identities;
    private String node;

    public static class Feature {
        private String variable;

        public Feature(String str) {
            if (str == null) {
                throw new IllegalArgumentException("variable cannot be null");
            }
            this.variable = str;
        }

        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (obj == this) {
                return true;
            }
            if (obj.getClass() != getClass()) {
                return false;
            }
            return this.variable.equals(((Feature) obj).variable);
        }

        public String getVar() {
            return this.variable;
        }

        public int hashCode() {
            return this.variable.hashCode() * 37;
        }

        public String toXML() {
            return "<feature var=\"" + StringUtils.escapeForXML(this.variable) + "\"/>";
        }
    }

    public static class Identity implements Comparable<Identity> {
        private String category;
        private String lang;
        private String name;
        private String type;

        public Identity(String str, String str2) {
            this.category = str;
            this.name = str2;
        }

        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (obj == this) {
                return true;
            }
            if (obj.getClass() != getClass()) {
                return false;
            }
            Identity identity = (Identity) obj;
            if (!this.category.equals(identity.category)) {
                return false;
            }
            String str = identity.lang;
            if (str == null) {
                str = "";
            }
            String str2 = this.lang;
            if (str2 == null) {
                str2 = "";
            }
            if (!str.equals(str2)) {
                return false;
            }
            String str3 = identity.type;
            if (str3 == null) {
                str3 = "";
            }
            String str4 = this.type;
            if (str4 == null) {
                str4 = "";
            }
            if (!str3.equals(str4)) {
                return false;
            }
            String str5 = identity.name;
            return (this.name != null ? str5 : "").equals(str5 == null ? "" : str5);
        }

        public String getCategory() {
            return this.category;
        }

        public String getLanguage() {
            return this.lang;
        }

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

        public String getType() {
            return this.type;
        }

        public int hashCode() {
            int hashCode = (this.category.hashCode() + 37) * 37;
            String str = this.lang;
            int hashCode2 = (hashCode + (str == null ? 0 : str.hashCode())) * 37;
            String str2 = this.type;
            int hashCode3 = (hashCode2 + (str2 == null ? 0 : str2.hashCode())) * 37;
            String str3 = this.name;
            return hashCode3 + (str3 != null ? str3.hashCode() : 0);
        }

        public void setLanguage(String str) {
            this.lang = str;
        }

        public void setType(String str) {
            this.type = str;
        }

        public String toXML() {
            StringBuilder sb = new StringBuilder();
            sb.append("<identity");
            if (this.lang != null) {
                sb.append(" xml:lang=\"");
                sb.append(StringUtils.escapeForXML(this.lang));
                sb.append("\"");
            }
            sb.append(" category=\"");
            sb.append(StringUtils.escapeForXML(this.category));
            sb.append("\"");
            sb.append(" name=\"");
            sb.append(StringUtils.escapeForXML(this.name));
            sb.append("\"");
            if (this.type != null) {
                sb.append(" type=\"");
                sb.append(StringUtils.escapeForXML(this.type));
                sb.append("\"");
            }
            sb.append("/>");
            return sb.toString();
        }

        @Override
        public int compareTo(Identity identity) {
            String str = identity.lang;
            if (str == null) {
                str = "";
            }
            String str2 = this.lang;
            if (str2 == null) {
                str2 = "";
            }
            String str3 = identity.type;
            if (str3 == null) {
                str3 = "";
            }
            String str4 = this.type;
            String str5 = str4 != null ? str4 : "";
            if (!this.category.equals(identity.category)) {
                return this.category.compareTo(identity.category);
            }
            if (!str5.equals(str3)) {
                return str5.compareTo(str3);
            }
            if (str2.equals(str)) {
                return 0;
            }
            return str2.compareTo(str);
        }

        public Identity(String str, String str2, String str3) {
            if (str != null && str3 != null) {
                this.category = str;
                this.name = str2;
                this.type = str3;
                return;
            }
            throw new IllegalArgumentException("category and type cannot be null");
        }
    }

    public DiscoverInfo() {
        this.features = new CopyOnWriteArrayList();
        this.identities = new CopyOnWriteArrayList();
    }

    public void addFeature(String str) {
        addFeature(new Feature(str));
    }

    public void addFeatures(Collection<String> collection) {
        if (collection == null) {
            return;
        }
        Iterator<String> it = collection.iterator();
        while (it.hasNext()) {
            addFeature(it.next());
        }
    }

    public void addIdentities(Collection<Identity> collection) {
        if (collection == null) {
            return;
        }
        synchronized (this.identities) {
            this.identities.addAll(collection);
        }
    }

    public void addIdentity(Identity identity) {
        synchronized (this.identities) {
            this.identities.add(identity);
        }
    }

    public boolean containsDuplicateFeatures() {
        LinkedList linkedList = new LinkedList();
        for (Feature feature : this.features) {
            Iterator it = linkedList.iterator();
            while (it.hasNext()) {
                if (feature.equals((Feature) it.next())) {
                    return true;
                }
            }
            linkedList.add(feature);
        }
        return false;
    }

    public boolean containsDuplicateIdentities() {
        LinkedList linkedList = new LinkedList();
        for (Identity identity : this.identities) {
            Iterator it = linkedList.iterator();
            while (it.hasNext()) {
                if (identity.equals((Identity) it.next())) {
                    return true;
                }
            }
            linkedList.add(identity);
        }
        return false;
    }

    public boolean containsFeature(String str) {
        Iterator<Feature> features = getFeatures();
        while (features.hasNext()) {
            if (str.equals(features.next().getVar())) {
                return true;
            }
        }
        return false;
    }

    public String getChildElementXML() {
        StringBuilder sb = new StringBuilder();
        sb.append("<query xmlns=\"http://jabber.org/protocol/disco#info\"");
        if (getNode() != null) {
            sb.append(" node=\"");
            sb.append(StringUtils.escapeForXML(getNode()));
            sb.append("\"");
        }
        sb.append(">");
        synchronized (this.identities) {
            Iterator<Identity> it = this.identities.iterator();
            while (it.hasNext()) {
                sb.append(it.next().toXML());
            }
        }
        synchronized (this.features) {
            Iterator<Feature> it2 = this.features.iterator();
            while (it2.hasNext()) {
                sb.append(it2.next().toXML());
            }
        }
        sb.append(getExtensionsXML());
        sb.append("</query>");
        return sb.toString();
    }

    public Iterator<Feature> getFeatures() {
        Iterator<Feature> it;
        synchronized (this.features) {
            it = Collections.unmodifiableList(this.features).iterator();
        }
        return it;
    }

    public Iterator<Identity> getIdentities() {
        Iterator<Identity> it;
        synchronized (this.identities) {
            it = Collections.unmodifiableList(this.identities).iterator();
        }
        return it;
    }

    public String getNode() {
        return this.node;
    }

    public void setNode(String str) {
        this.node = str;
    }

    private void addFeature(Feature feature) {
        synchronized (this.features) {
            this.features.add(feature);
        }
    }

    public DiscoverInfo(DiscoverInfo discoverInfo) {
        super(discoverInfo);
        this.features = new CopyOnWriteArrayList();
        this.identities = new CopyOnWriteArrayList();
        setNode(discoverInfo.getNode());
        synchronized (discoverInfo.features) {
            Iterator<Feature> it = discoverInfo.features.iterator();
            while (it.hasNext()) {
                addFeature(it.next());
            }
        }
        synchronized (discoverInfo.identities) {
            Iterator<Identity> it2 = discoverInfo.identities.iterator();
            while (it2.hasNext()) {
                addIdentity(it2.next());
            }
        }
    }
}