曹妃甸核酸检测平台.apk(点击下载) / Packet.java


package asmack.org.jivesoftware.smack.packet;

import asmack.org.jivesoftware.smack.util.StringUtils;
import java.io.ByteArrayOutputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import java.util.concurrent.CopyOnWriteArrayList;

public abstract class Packet {
    protected static final String DEFAULT_LANGUAGE = Locale.getDefault().getLanguage().toLowerCase();
    private static String DEFAULT_XML_NS = null;
    public static final String ID_NOT_AVAILABLE = "ID_NOT_AVAILABLE";
    public static final DateFormat XEP_0082_UTC_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
    private static long id = 0;
    private static String prefix = (String.valueOf(StringUtils.randomString(5)) + "-");
    private XMPPError error = null;
    private String from = null;
    private final List<PacketExtension> packetExtensions = new CopyOnWriteArrayList();
    private String packetID = null;
    private final Map<String, Object> properties = new HashMap();
    private String to = null;
    private String xmlns = DEFAULT_XML_NS;

    static {
        XEP_0082_UTC_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
    }

    public static String getDefaultLanguage() {
        return DEFAULT_LANGUAGE;
    }

    public static synchronized String nextID() {
        String sb;
        synchronized (Packet.class) {
            StringBuilder sb2 = new StringBuilder(String.valueOf(prefix));
            long j = id;
            id = 1 + j;
            sb2.append(Long.toString(j));
            sb = sb2.toString();
        }
        return sb;
    }

    public static void setDefaultXmlns(String str) {
        DEFAULT_XML_NS = str;
    }

    public void addExtension(PacketExtension packetExtension) {
        this.packetExtensions.add(packetExtension);
    }

    public synchronized void deleteProperty(String str) {
        if (this.properties != null) {
            this.properties.remove(str);
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:51:0x008b A[ORIG_RETURN, RETURN, SYNTHETIC] */
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        Packet packet = (Packet) obj;
        XMPPError xMPPError = this.error;
        if (xMPPError == null ? packet.error != null : !xMPPError.equals(packet.error)) {
            return false;
        }
        String str = this.from;
        if (str == null ? packet.from != null : !str.equals(packet.from)) {
            return false;
        }
        if (!this.packetExtensions.equals(packet.packetExtensions)) {
            return false;
        }
        String str2 = this.packetID;
        if (str2 == null ? packet.packetID != null : !str2.equals(packet.packetID)) {
            return false;
        }
        Map<String, Object> map = this.properties;
        if (map == null ? packet.properties != null : !map.equals(packet.properties)) {
            return false;
        }
        String str3 = this.to;
        if (str3 == null ? packet.to != null : !str3.equals(packet.to)) {
            return false;
        }
        String str4 = this.xmlns;
        if (str4 != null) {
            return str4.equals(packet.xmlns);
        }
        if (packet.xmlns == null) {
            return true;
        }
    }

    public XMPPError getError() {
        return this.error;
    }

    public PacketExtension getExtension(String str) {
        return getExtension(null, str);
    }

    public PacketExtension getExtension(String str, String str2) {
        if (str2 == null) {
            return null;
        }
        for (PacketExtension packetExtension : this.packetExtensions) {
            if ((str == null || str.equals(packetExtension.getElementName())) && str2.equals(packetExtension.getNamespace())) {
                return packetExtension;
            }
        }
        return null;
    }

    public <PE extends PacketExtension> PE getExtension1(String str, String str2) {
        if (str2 == null) {
            return null;
        }
        Iterator<PacketExtension> it2 = this.packetExtensions.iterator();
        while (it2.hasNext()) {
            PE pe = (PE) it2.next();
            if ((str == null || str.equals(pe.getElementName())) && str2.equals(pe.getNamespace())) {
                return pe;
            }
        }
        return null;
    }

    public synchronized Collection<PacketExtension> getExtensions() {
        if (this.packetExtensions == null) {
            return Collections.emptyList();
        }
        return Collections.unmodifiableList(new ArrayList(this.packetExtensions));
    }

    /* access modifiers changed from: protected */
    /* JADX WARNING: Can't wrap try/catch for region: R(6:32|(8:33|34|35|36|37|38|39|40)|41|42|83|60) */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing exception handler attribute for start block: B:41:0x00e9 */
    /* JADX WARNING: Removed duplicated region for block: B:56:0x0102 A[SYNTHETIC, Splitter:B:56:0x0102] */
    /* JADX WARNING: Removed duplicated region for block: B:64:0x0114 A[SYNTHETIC, Splitter:B:64:0x0114] */
    /* JADX WARNING: Removed duplicated region for block: B:68:0x011b A[SYNTHETIC, Splitter:B:68:0x011b] */
    /* JADX WARNING: Removed duplicated region for block: B:82:0x010a A[SYNTHETIC] */
    public synchronized String getExtensionsXML() {
        StringBuilder sb;
        ObjectOutputStream objectOutputStream;
        ByteArrayOutputStream byteArrayOutputStream;
        Throwable th;
        Exception e2;
        Exception e3;
        String str;
        sb = new StringBuilder();
        for (PacketExtension packetExtension : getExtensions()) {
            sb.append(packetExtension.toXML());
        }
        if (this.properties != null && !this.properties.isEmpty()) {
            sb.append("<properties xmlns=\"http://www.jivesoftware.com/xmlns/xmpp/properties\">");
            for (String str2 : getPropertyNames()) {
                Object property = getProperty(str2);
                sb.append("<property>");
                sb.append("<name>");
                sb.append(StringUtils.escapeForXML(str2));
                sb.append("</name>");
                sb.append("<value type=\"");
                if (property instanceof Integer) {
                    sb.append("integer\">");
                    sb.append(property);
                    str = "</value>";
                } else if (property instanceof Long) {
                    sb.append("long\">");
                    sb.append(property);
                    str = "</value>";
                } else if (property instanceof Float) {
                    sb.append("float\">");
                    sb.append(property);
                    str = "</value>";
                } else if (property instanceof Double) {
                    sb.append("double\">");
                    sb.append(property);
                    str = "</value>";
                } else if (property instanceof Boolean) {
                    sb.append("boolean\">");
                    sb.append(property);
                    str = "</value>";
                } else if (property instanceof String) {
                    sb.append("string\">");
                    sb.append(StringUtils.escapeForXML((String) property));
                    str = "</value>";
                } else {
                    try {
                        byteArrayOutputStream = new ByteArrayOutputStream();
                        try {
                            objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
                            try {
                                objectOutputStream.writeObject(property);
                                sb.append("java-object\">");
                                sb.append(StringUtils.encodeBase64(byteArrayOutputStream.toByteArray()));
                                sb.append("</value>");
                                objectOutputStream.close();
                            } catch (Exception e4) {
                                e2 = e4;
                                try {
                                    e2.printStackTrace();
                                    if (objectOutputStream != null) {
                                        try {
                                            objectOutputStream.close();
                                        } catch (Exception unused) {
                                        }
                                    }
                                    if (byteArrayOutputStream == null) {
                                        sb.append("</property>");
                                    }
                                    byteArrayOutputStream.close();
                                    sb.append("</property>");
                                } catch (Throwable th2) {
                                    th = th2;
                                    if (objectOutputStream != null) {
                                        try {
                                            objectOutputStream.close();
                                        } catch (Exception unused2) {
                                        }
                                    }
                                    if (byteArrayOutputStream != null) {
                                        try {
                                            byteArrayOutputStream.close();
                                        } catch (Exception unused3) {
                                        }
                                    }
                                    throw th;
                                }
                            }
                        } catch (Exception e5) {
                            e3 = e5;
                            objectOutputStream = null;
                            e2 = e3;
                            e2.printStackTrace();
                            if (objectOutputStream != null) {
                            }
                            if (byteArrayOutputStream == null) {
                            }
                            byteArrayOutputStream.close();
                            sb.append("</property>");
                        } catch (Throwable th3) {
                            th = th3;
                            objectOutputStream = null;
                            if (objectOutputStream != null) {
                            }
                            if (byteArrayOutputStream != null) {
                            }
                            throw th;
                        }
                    } catch (Exception e6) {
                        e3 = e6;
                        byteArrayOutputStream = null;
                        objectOutputStream = null;
                        e2 = e3;
                        e2.printStackTrace();
                        if (objectOutputStream != null) {
                        }
                        if (byteArrayOutputStream == null) {
                        }
                        byteArrayOutputStream.close();
                        sb.append("</property>");
                    } catch (Throwable th4) {
                        th = th4;
                        byteArrayOutputStream = null;
                        objectOutputStream = null;
                        if (objectOutputStream != null) {
                        }
                        if (byteArrayOutputStream != null) {
                        }
                        throw th;
                    }
                    byteArrayOutputStream.close();
                    sb.append("</property>");
                }
                sb.append(str);
                sb.append("</property>");
            }
            sb.append("</properties>");
        }
        return sb.toString();
    }

    public String getFrom() {
        return this.from;
    }

    public String getPacketID() {
        if (ID_NOT_AVAILABLE.equals(this.packetID)) {
            return null;
        }
        if (this.packetID == null) {
            this.packetID = nextID();
        }
        return this.packetID;
    }

    public synchronized Object getProperty(String str) {
        if (this.properties == null) {
            return null;
        }
        return this.properties.get(str);
    }

    public synchronized Collection<String> getPropertyNames() {
        if (this.properties == null) {
            return Collections.emptySet();
        }
        return Collections.unmodifiableSet(new HashSet(this.properties.keySet()));
    }

    public String getTo() {
        return this.to;
    }

    public String getXmlns() {
        return this.xmlns;
    }

    public int hashCode() {
        String str = this.xmlns;
        int i = 0;
        int hashCode = (str != null ? str.hashCode() : 0) * 31;
        String str2 = this.packetID;
        int hashCode2 = (hashCode + (str2 != null ? str2.hashCode() : 0)) * 31;
        String str3 = this.to;
        int hashCode3 = (hashCode2 + (str3 != null ? str3.hashCode() : 0)) * 31;
        String str4 = this.from;
        int hashCode4 = (((((hashCode3 + (str4 != null ? str4.hashCode() : 0)) * 31) + this.packetExtensions.hashCode()) * 31) + this.properties.hashCode()) * 31;
        XMPPError xMPPError = this.error;
        if (xMPPError != null) {
            i = xMPPError.hashCode();
        }
        return hashCode4 + i;
    }

    public void removeExtension(PacketExtension packetExtension) {
        this.packetExtensions.remove(packetExtension);
    }

    public void setError(XMPPError xMPPError) {
        this.error = xMPPError;
    }

    public void setFrom(String str) {
        this.from = str;
    }

    public void setPacketID(String str) {
        this.packetID = str;
    }

    public synchronized void setProperty(String str, Object obj) {
        if (obj instanceof Serializable) {
            this.properties.put(str, obj);
        } else {
            throw new IllegalArgumentException("Value must be serialiazble");
        }
    }

    public void setTo(String str) {
        this.to = str;
    }

    public abstract String toXML();
}