what-the-bank/sources/retrofit2/converter/simplexml/SimpleXmlResponseBodyConver...

44 lines
1.4 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package retrofit2.converter.simplexml;
import java.io.IOException;
import okhttp3.ResponseBody;
import org.simpleframework.xml.Serializer;
import retrofit2.Converter;
/* loaded from: classes.dex */
final class SimpleXmlResponseBodyConverter<T> implements Converter<ResponseBody, T> {
private final Class<T> cls;
private final Serializer serializer;
private final boolean strict;
/* JADX INFO: Access modifiers changed from: package-private */
public SimpleXmlResponseBodyConverter(Class<T> cls, Serializer serializer, boolean z) {
this.cls = cls;
this.serializer = serializer;
this.strict = z;
}
@Override // retrofit2.Converter
public final T convert(ResponseBody responseBody) throws IOException {
try {
try {
T t = (T) this.serializer.read((Class) this.cls, responseBody.charStream(), this.strict);
if (t != null) {
return t;
}
StringBuilder sb = new StringBuilder("Could not deserialize body as ");
sb.append(this.cls);
throw new IllegalStateException(sb.toString());
} catch (IOException e) {
throw e;
} catch (RuntimeException e2) {
throw e2;
} catch (Exception e3) {
throw new RuntimeException(e3);
}
} finally {
responseBody.close();
}
}
}