jimu-decompiled/sources/com/thoughtworks/xstream/converters/ErrorWritingException.java
2025-05-13 19:24:51 +02:00

116 lines
3.7 KiB
Java

package com.thoughtworks.xstream.converters;
import com.thoughtworks.xstream.XStreamException;
import com.thoughtworks.xstream.core.util.OrderRetainingMap;
import java.util.Iterator;
import java.util.Map;
/* loaded from: classes.dex */
public abstract class ErrorWritingException extends XStreamException implements ErrorWriter {
private static final String SEPARATOR = "\n-------------------------------";
private final Map stuff;
public ErrorWritingException(String str) {
super(str);
this.stuff = new OrderRetainingMap();
addData(str, null);
}
private void addData(String str, Throwable th) {
if (str != null) {
add("message", str);
}
if (th != null) {
add("cause-exception", th.getClass().getName());
add("cause-message", th instanceof ErrorWritingException ? ((ErrorWritingException) th).getShortMessage() : th.getMessage());
}
}
@Override // com.thoughtworks.xstream.converters.ErrorWriter
public void add(String str, String str2) {
String str3 = str;
int i = 0;
while (this.stuff.containsKey(str3)) {
if (str2.equals((String) this.stuff.get(str3))) {
return;
}
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(str);
stringBuffer.append("[");
i++;
stringBuffer.append(i);
stringBuffer.append("]");
str3 = stringBuffer.toString();
}
this.stuff.put(str3, str2);
}
@Override // com.thoughtworks.xstream.converters.ErrorWriter
public String get(String str) {
return (String) this.stuff.get(str);
}
@Override // java.lang.Throwable
public String getMessage() {
StringBuffer stringBuffer = new StringBuffer();
if (super.getMessage() != null) {
stringBuffer.append(super.getMessage());
}
if (!stringBuffer.toString().endsWith(SEPARATOR)) {
stringBuffer.append("\n---- Debugging information ----");
}
Iterator keys = keys();
while (keys.hasNext()) {
String str = (String) keys.next();
String str2 = get(str);
stringBuffer.append('\n');
stringBuffer.append(str);
stringBuffer.append(" ".substring(Math.min(20, str.length())));
stringBuffer.append(": ");
stringBuffer.append(str2);
}
stringBuffer.append(SEPARATOR);
return stringBuffer.toString();
}
public String getShortMessage() {
return super.getMessage();
}
@Override // com.thoughtworks.xstream.converters.ErrorWriter
public Iterator keys() {
return this.stuff.keySet().iterator();
}
@Override // com.thoughtworks.xstream.converters.ErrorWriter
public void set(String str, String str2) {
this.stuff.put(str, str2);
String str3 = str;
int i = 0;
while (this.stuff.containsKey(str3)) {
if (i != 0) {
this.stuff.remove(str3);
}
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(str);
stringBuffer.append("[");
i++;
stringBuffer.append(i);
stringBuffer.append("]");
str3 = stringBuffer.toString();
}
}
public ErrorWritingException(Throwable th) {
super(th);
this.stuff = new OrderRetainingMap();
addData(null, th);
}
public ErrorWritingException(String str, Throwable th) {
super(str, th);
this.stuff = new OrderRetainingMap();
addData(str, th);
}
}