CarrotChat v2.8.60.240131版本的 MD5 值为:2baf8b9f31830b86b5c5a85ae6b47e05
以下内容为反编译后的 JivePropertiesExtension.java 源代码,内容仅作参考
package org.jivesoftware.smackx.jiveproperties.packet;
import androidx.constraintlayout.core.motion.utils.TypedValues;
import java.io.ByteArrayOutputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smack.util.stringencoder.Base64;
public class JivePropertiesExtension implements ExtensionElement {
public static final String ELEMENT = "properties";
private static final Logger LOGGER = Logger.getLogger(JivePropertiesExtension.class.getName());
public static final String NAMESPACE = "http://www.jivesoftware.com/xmlns/xmpp/properties";
private final Map<String, Object> properties;
public JivePropertiesExtension() {
this.properties = new HashMap();
}
public static JivePropertiesExtension from(Message message) {
return (JivePropertiesExtension) message.getExtension(ELEMENT, NAMESPACE);
}
public synchronized void deleteProperty(String str) {
Map<String, Object> map = this.properties;
if (map == null) {
return;
}
map.remove(str);
}
@Override
public String getElementName() {
return ELEMENT;
}
@Override
public String getNamespace() {
return NAMESPACE;
}
public synchronized Map<String, Object> getProperties() {
if (this.properties == null) {
return Collections.emptyMap();
}
return Collections.unmodifiableMap(new HashMap(this.properties));
}
public synchronized Object getProperty(String str) {
Map<String, Object> map = this.properties;
if (map == null) {
return null;
}
return map.get(str);
}
public synchronized Collection<String> getPropertyNames() {
if (this.properties == null) {
return Collections.emptySet();
}
return Collections.unmodifiableSet(new HashSet(this.properties.keySet()));
}
public synchronized void setProperty(String str, Object obj) {
if (obj instanceof Serializable) {
this.properties.put(str, obj);
} else {
throw new IllegalArgumentException("Value must be serializable");
}
}
@Override
public CharSequence toXML() {
ByteArrayOutputStream byteArrayOutputStream;
ObjectOutputStream objectOutputStream;
String str;
XmlStringBuilder xmlStringBuilder = new XmlStringBuilder((ExtensionElement) this);
xmlStringBuilder.rightAngleBracket();
for (String str2 : getPropertyNames()) {
Object property = getProperty(str2);
xmlStringBuilder.openElement("property");
xmlStringBuilder.element("name", str2);
xmlStringBuilder.halfOpenElement("value");
String str3 = "java-object";
if (property instanceof Integer) {
str = Integer.toString(((Integer) property).intValue());
str3 = TypedValues.Custom.S_INT;
} else if (property instanceof Long) {
str = Long.toString(((Long) property).longValue());
str3 = "long";
} else if (property instanceof Float) {
str = Float.toString(((Float) property).floatValue());
str3 = TypedValues.Custom.S_FLOAT;
} else if (property instanceof Double) {
str = Double.toString(((Double) property).doubleValue());
str3 = "double";
} else if (property instanceof Boolean) {
str = Boolean.toString(((Boolean) property).booleanValue());
str3 = TypedValues.Custom.S_BOOLEAN;
} else if (property instanceof String) {
str = (String) property;
str3 = TypedValues.Custom.S_STRING;
} else {
ObjectOutputStream objectOutputStream2 = null;
objectOutputStream2 = null;
ByteArrayOutputStream byteArrayOutputStream2 = null;
try {
byteArrayOutputStream = new ByteArrayOutputStream();
} catch (Exception e2) {
e = e2;
objectOutputStream = null;
} catch (Throwable th) {
th = th;
byteArrayOutputStream = null;
}
try {
objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
try {
objectOutputStream.writeObject(property);
Base64.encodeToString(byteArrayOutputStream.toByteArray());
try {
objectOutputStream.close();
} catch (Exception unused) {
}
byteArrayOutputStream.close();
} catch (Exception e3) {
e = e3;
byteArrayOutputStream2 = byteArrayOutputStream;
try {
LOGGER.log(Level.SEVERE, "Error encoding java object", (Throwable) e);
str = "Serializing error: " + e.getMessage();
if (objectOutputStream != null) {
try {
objectOutputStream.close();
} catch (Exception unused2) {
}
}
if (byteArrayOutputStream2 != null) {
try {
byteArrayOutputStream2.close();
} catch (Exception unused3) {
}
}
xmlStringBuilder.attribute("type", str3);
xmlStringBuilder.rightAngleBracket();
xmlStringBuilder.escape(str);
xmlStringBuilder.closeElement("value");
xmlStringBuilder.closeElement("property");
} catch (Throwable th2) {
th = th2;
byteArrayOutputStream = byteArrayOutputStream2;
objectOutputStream2 = objectOutputStream;
if (objectOutputStream2 != null) {
try {
objectOutputStream2.close();
} catch (Exception unused4) {
}
}
if (byteArrayOutputStream != null) {
try {
byteArrayOutputStream.close();
} catch (Exception unused5) {
}
}
throw th;
}
} catch (Throwable th3) {
th = th3;
objectOutputStream2 = objectOutputStream;
if (objectOutputStream2 != null) {
}
if (byteArrayOutputStream != null) {
}
throw th;
}
} catch (Exception e4) {
e = e4;
objectOutputStream = null;
} catch (Throwable th4) {
th = th4;
if (objectOutputStream2 != null) {
}
if (byteArrayOutputStream != null) {
}
throw th;
}
}
xmlStringBuilder.attribute("type", str3);
xmlStringBuilder.rightAngleBracket();
xmlStringBuilder.escape(str);
xmlStringBuilder.closeElement("value");
xmlStringBuilder.closeElement("property");
}
xmlStringBuilder.closeElement(this);
return xmlStringBuilder;
}
public JivePropertiesExtension(Map<String, Object> map) {
this.properties = map;
}
}