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

81 lines
2.8 KiB
Java

package com.thoughtworks.xstream.converters.extended;
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.ConverterLookup;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
/* loaded from: classes.dex */
public class ThrowableConverter implements Converter {
static /* synthetic */ Class class$java$lang$Object;
static /* synthetic */ Class class$java$lang$Throwable;
private Converter defaultConverter;
private final ConverterLookup lookup;
public ThrowableConverter(Converter converter) {
this.defaultConverter = converter;
this.lookup = null;
}
static /* synthetic */ Class class$(String str) {
try {
return Class.forName(str);
} catch (ClassNotFoundException e) {
throw new NoClassDefFoundError().initCause(e);
}
}
private Converter getConverter() {
Converter converter = this.defaultConverter;
if (converter != null) {
return converter;
}
ConverterLookup converterLookup = this.lookup;
Class cls = class$java$lang$Object;
if (cls == null) {
cls = class$("java.lang.Object");
class$java$lang$Object = cls;
}
return converterLookup.lookupConverterForType(cls);
}
@Override // com.thoughtworks.xstream.converters.ConverterMatcher
public boolean canConvert(Class cls) {
if (cls != null) {
Class cls2 = class$java$lang$Throwable;
if (cls2 == null) {
cls2 = class$("java.lang.Throwable");
class$java$lang$Throwable = cls2;
}
if (cls2.isAssignableFrom(cls)) {
return true;
}
}
return false;
}
@Override // com.thoughtworks.xstream.converters.Converter
public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
Throwable th = (Throwable) obj;
if (th.getCause() == null) {
try {
th.initCause(null);
} catch (IllegalStateException unused) {
}
}
th.getStackTrace();
getConverter().marshal(th, hierarchicalStreamWriter, marshallingContext);
}
@Override // com.thoughtworks.xstream.converters.Converter
public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
return getConverter().unmarshal(hierarchicalStreamReader, unmarshallingContext);
}
public ThrowableConverter(ConverterLookup converterLookup) {
this.lookup = converterLookup;
}
}