Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,106 @@
package com.thoughtworks.xstream.converters.collections;
import com.thoughtworks.xstream.converters.ConversionException;
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.ErrorWritingException;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.converters.reflection.ObjectAccessException;
import com.thoughtworks.xstream.core.util.HierarchicalStreams;
import com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriterHelper;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.mapper.Mapper;
/* loaded from: classes.dex */
public abstract class AbstractCollectionConverter implements Converter {
static /* synthetic */ Class class$com$thoughtworks$xstream$mapper$Mapper$Null;
private final Mapper mapper;
public AbstractCollectionConverter(Mapper mapper) {
this.mapper = mapper;
}
static /* synthetic */ Class class$(String str) {
try {
return Class.forName(str);
} catch (ClassNotFoundException e) {
throw new NoClassDefFoundError().initCause(e);
}
}
@Override // com.thoughtworks.xstream.converters.ConverterMatcher
public abstract boolean canConvert(Class cls);
protected Object createCollection(Class cls) {
ErrorWritingException conversionException;
Class defaultImplementationOf = mapper().defaultImplementationOf(cls);
try {
return defaultImplementationOf.newInstance();
} catch (IllegalAccessException e) {
conversionException = new ObjectAccessException("Cannot instantiate default collection", e);
conversionException.add("collection-type", cls.getName());
conversionException.add("default-type", defaultImplementationOf.getName());
throw conversionException;
} catch (InstantiationException e2) {
conversionException = new ConversionException("Cannot instantiate default collection", e2);
conversionException.add("collection-type", cls.getName());
conversionException.add("default-type", defaultImplementationOf.getName());
throw conversionException;
}
}
protected Mapper mapper() {
return this.mapper;
}
@Override // com.thoughtworks.xstream.converters.Converter
public abstract void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext);
protected Object readBareItem(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext, Object obj) {
return unmarshallingContext.convertAnother(obj, HierarchicalStreams.readClassType(hierarchicalStreamReader, mapper()));
}
protected Object readCompleteItem(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext, Object obj) {
hierarchicalStreamReader.moveDown();
Object readItem = readItem(hierarchicalStreamReader, unmarshallingContext, obj);
hierarchicalStreamReader.moveUp();
return readItem;
}
protected Object readItem(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext, Object obj) {
return readBareItem(hierarchicalStreamReader, unmarshallingContext, obj);
}
@Override // com.thoughtworks.xstream.converters.Converter
public abstract Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext);
protected void writeBareItem(Object obj, MarshallingContext marshallingContext, HierarchicalStreamWriter hierarchicalStreamWriter) {
marshallingContext.convertAnother(obj);
}
protected void writeCompleteItem(Object obj, MarshallingContext marshallingContext, HierarchicalStreamWriter hierarchicalStreamWriter) {
writeItem(obj, marshallingContext, hierarchicalStreamWriter);
}
protected void writeItem(Object obj, MarshallingContext marshallingContext, HierarchicalStreamWriter hierarchicalStreamWriter) {
if (obj == null) {
writeNullItem(marshallingContext, hierarchicalStreamWriter);
return;
}
ExtendedHierarchicalStreamWriterHelper.startNode(hierarchicalStreamWriter, mapper().serializedClass(obj.getClass()), obj.getClass());
writeBareItem(obj, marshallingContext, hierarchicalStreamWriter);
hierarchicalStreamWriter.endNode();
}
protected void writeNullItem(MarshallingContext marshallingContext, HierarchicalStreamWriter hierarchicalStreamWriter) {
String serializedClass = mapper().serializedClass(null);
Class cls = class$com$thoughtworks$xstream$mapper$Mapper$Null;
if (cls == null) {
cls = class$("com.thoughtworks.xstream.mapper.Mapper$Null");
class$com$thoughtworks$xstream$mapper$Mapper$Null = cls;
}
ExtendedHierarchicalStreamWriterHelper.startNode(hierarchicalStreamWriter, serializedClass, cls);
hierarchicalStreamWriter.endNode();
}
}

View File

@@ -0,0 +1,46 @@
package com.thoughtworks.xstream.converters.collections;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.mapper.Mapper;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Iterator;
/* loaded from: classes.dex */
public class ArrayConverter extends AbstractCollectionConverter {
public ArrayConverter(Mapper mapper) {
super(mapper);
}
@Override // com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter, com.thoughtworks.xstream.converters.ConverterMatcher
public boolean canConvert(Class cls) {
return cls != null && cls.isArray();
}
@Override // com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter, com.thoughtworks.xstream.converters.Converter
public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
int length = Array.getLength(obj);
for (int i = 0; i < length; i++) {
writeCompleteItem(Array.get(obj, i), marshallingContext, hierarchicalStreamWriter);
}
}
@Override // com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter, com.thoughtworks.xstream.converters.Converter
public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
ArrayList arrayList = new ArrayList();
while (hierarchicalStreamReader.hasMoreChildren()) {
arrayList.add(readCompleteItem(hierarchicalStreamReader, unmarshallingContext, null));
}
Object newInstance = Array.newInstance(unmarshallingContext.getRequiredType().getComponentType(), arrayList.size());
int i = 0;
Iterator it = arrayList.iterator();
while (it.hasNext()) {
Array.set(newInstance, i, it.next());
i++;
}
return newInstance;
}
}

View File

@@ -0,0 +1,60 @@
package com.thoughtworks.xstream.converters.collections;
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import java.util.BitSet;
import java.util.StringTokenizer;
/* loaded from: classes.dex */
public class BitSetConverter implements Converter {
static /* synthetic */ Class class$java$util$BitSet;
static /* synthetic */ Class class$(String str) {
try {
return Class.forName(str);
} catch (ClassNotFoundException e) {
throw new NoClassDefFoundError().initCause(e);
}
}
@Override // com.thoughtworks.xstream.converters.ConverterMatcher
public boolean canConvert(Class cls) {
Class cls2 = class$java$util$BitSet;
if (cls2 == null) {
cls2 = class$("java.util.BitSet");
class$java$util$BitSet = cls2;
}
return cls == cls2;
}
@Override // com.thoughtworks.xstream.converters.Converter
public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
BitSet bitSet = (BitSet) obj;
StringBuffer stringBuffer = new StringBuffer();
boolean z = false;
for (int i = 0; i < bitSet.length(); i++) {
if (bitSet.get(i)) {
if (z) {
stringBuffer.append(',');
} else {
z = true;
}
stringBuffer.append(i);
}
}
hierarchicalStreamWriter.setValue(stringBuffer.toString());
}
@Override // com.thoughtworks.xstream.converters.Converter
public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
BitSet bitSet = new BitSet();
StringTokenizer stringTokenizer = new StringTokenizer(hierarchicalStreamReader.getValue(), ",", false);
while (stringTokenizer.hasMoreTokens()) {
bitSet.set(Integer.parseInt(stringTokenizer.nextToken()));
}
return bitSet;
}
}

View File

@@ -0,0 +1,25 @@
package com.thoughtworks.xstream.converters.collections;
import com.thoughtworks.xstream.converters.Converter;
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 CharArrayConverter implements Converter {
@Override // com.thoughtworks.xstream.converters.ConverterMatcher
public boolean canConvert(Class cls) {
return cls != null && cls.isArray() && cls.getComponentType().equals(Character.TYPE);
}
@Override // com.thoughtworks.xstream.converters.Converter
public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
hierarchicalStreamWriter.setValue(new String((char[]) obj));
}
@Override // com.thoughtworks.xstream.converters.Converter
public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
return hierarchicalStreamReader.getValue().toCharArray();
}
}

View File

@@ -0,0 +1,142 @@
package com.thoughtworks.xstream.converters.collections;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.mapper.Mapper;
import java.util.Collection;
import java.util.Iterator;
/* loaded from: classes.dex */
public class CollectionConverter extends AbstractCollectionConverter {
static /* synthetic */ Class class$java$util$ArrayList;
static /* synthetic */ Class class$java$util$Collection;
static /* synthetic */ Class class$java$util$HashSet;
static /* synthetic */ Class class$java$util$LinkedHashSet;
static /* synthetic */ Class class$java$util$LinkedList;
static /* synthetic */ Class class$java$util$Vector;
private final Class type;
public CollectionConverter(Mapper mapper) {
this(mapper, null);
}
static /* synthetic */ Class class$(String str) {
try {
return Class.forName(str);
} catch (ClassNotFoundException e) {
throw new NoClassDefFoundError().initCause(e);
}
}
protected void addCurrentElementToCollection(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext, Collection collection, Collection collection2) {
collection2.add(readItem(hierarchicalStreamReader, unmarshallingContext, collection));
}
@Override // com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter, com.thoughtworks.xstream.converters.ConverterMatcher
public boolean canConvert(Class cls) {
Object obj = this.type;
if (obj != null) {
return cls.equals(obj);
}
Class cls2 = class$java$util$ArrayList;
if (cls2 == null) {
cls2 = class$("java.util.ArrayList");
class$java$util$ArrayList = cls2;
}
if (!cls.equals(cls2)) {
Class cls3 = class$java$util$HashSet;
if (cls3 == null) {
cls3 = class$("java.util.HashSet");
class$java$util$HashSet = cls3;
}
if (!cls.equals(cls3)) {
Class cls4 = class$java$util$LinkedList;
if (cls4 == null) {
cls4 = class$("java.util.LinkedList");
class$java$util$LinkedList = cls4;
}
if (!cls.equals(cls4)) {
Class cls5 = class$java$util$Vector;
if (cls5 == null) {
cls5 = class$("java.util.Vector");
class$java$util$Vector = cls5;
}
if (!cls.equals(cls5)) {
Class cls6 = class$java$util$LinkedHashSet;
if (cls6 == null) {
cls6 = class$("java.util.LinkedHashSet");
class$java$util$LinkedHashSet = cls6;
}
if (!cls.equals(cls6)) {
return false;
}
}
}
}
}
return true;
}
@Override // com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter
protected Object createCollection(Class cls) {
Class cls2 = this.type;
if (cls2 != null) {
cls = cls2;
}
return super.createCollection(cls);
}
@Override // com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter, com.thoughtworks.xstream.converters.Converter
public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
Iterator it = ((Collection) obj).iterator();
while (it.hasNext()) {
writeCompleteItem(it.next(), marshallingContext, hierarchicalStreamWriter);
}
}
protected void populateCollection(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext, Collection collection) {
populateCollection(hierarchicalStreamReader, unmarshallingContext, collection, collection);
}
@Override // com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter, com.thoughtworks.xstream.converters.Converter
public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
Collection collection = (Collection) createCollection(unmarshallingContext.getRequiredType());
populateCollection(hierarchicalStreamReader, unmarshallingContext, collection);
return collection;
}
public CollectionConverter(Mapper mapper, Class cls) {
super(mapper);
this.type = cls;
if (cls != null) {
Class cls2 = class$java$util$Collection;
if (cls2 == null) {
cls2 = class$("java.util.Collection");
class$java$util$Collection = cls2;
}
if (cls2.isAssignableFrom(cls)) {
return;
}
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(cls);
stringBuffer.append(" not of type ");
Class cls3 = class$java$util$Collection;
if (cls3 == null) {
cls3 = class$("java.util.Collection");
class$java$util$Collection = cls3;
}
stringBuffer.append(cls3);
throw new IllegalArgumentException(stringBuffer.toString());
}
}
protected void populateCollection(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext, Collection collection, Collection collection2) {
while (hierarchicalStreamReader.hasMoreChildren()) {
hierarchicalStreamReader.moveDown();
addCurrentElementToCollection(hierarchicalStreamReader, unmarshallingContext, collection, collection2);
hierarchicalStreamReader.moveUp();
}
}
}

View File

@@ -0,0 +1,129 @@
package com.thoughtworks.xstream.converters.collections;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriterHelper;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.mapper.Mapper;
import java.util.Map;
/* loaded from: classes.dex */
public class MapConverter extends AbstractCollectionConverter {
static /* synthetic */ Class class$java$util$HashMap;
static /* synthetic */ Class class$java$util$Hashtable;
static /* synthetic */ Class class$java$util$Map;
static /* synthetic */ Class class$java$util$Map$Entry;
private final Class type;
public MapConverter(Mapper mapper) {
this(mapper, null);
}
static /* synthetic */ Class class$(String str) {
try {
return Class.forName(str);
} catch (ClassNotFoundException e) {
throw new NoClassDefFoundError().initCause(e);
}
}
@Override // com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter, com.thoughtworks.xstream.converters.ConverterMatcher
public boolean canConvert(Class cls) {
Object obj = this.type;
if (obj != null) {
return cls.equals(obj);
}
Class cls2 = class$java$util$HashMap;
if (cls2 == null) {
cls2 = class$("java.util.HashMap");
class$java$util$HashMap = cls2;
}
if (!cls.equals(cls2)) {
Class cls3 = class$java$util$Hashtable;
if (cls3 == null) {
cls3 = class$("java.util.Hashtable");
class$java$util$Hashtable = cls3;
}
if (!cls.equals(cls3) && !cls.getName().equals("java.util.LinkedHashMap") && !cls.getName().equals("java.util.concurrent.ConcurrentHashMap") && !cls.getName().equals("sun.font.AttributeMap")) {
return false;
}
}
return true;
}
@Override // com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter
protected Object createCollection(Class cls) {
Class cls2 = this.type;
if (cls2 != null) {
cls = cls2;
}
return super.createCollection(cls);
}
@Override // com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter, com.thoughtworks.xstream.converters.Converter
public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
Map map = (Map) obj;
Mapper mapper = mapper();
Class cls = class$java$util$Map$Entry;
if (cls == null) {
cls = class$("java.util.Map$Entry");
class$java$util$Map$Entry = cls;
}
String serializedClass = mapper.serializedClass(cls);
for (Map.Entry entry : map.entrySet()) {
ExtendedHierarchicalStreamWriterHelper.startNode(hierarchicalStreamWriter, serializedClass, entry.getClass());
writeCompleteItem(entry.getKey(), marshallingContext, hierarchicalStreamWriter);
writeCompleteItem(entry.getValue(), marshallingContext, hierarchicalStreamWriter);
hierarchicalStreamWriter.endNode();
}
}
protected void populateMap(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext, Map map) {
populateMap(hierarchicalStreamReader, unmarshallingContext, map, map);
}
protected void putCurrentEntryIntoMap(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext, Map map, Map map2) {
map2.put(readCompleteItem(hierarchicalStreamReader, unmarshallingContext, map), readCompleteItem(hierarchicalStreamReader, unmarshallingContext, map));
}
@Override // com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter, com.thoughtworks.xstream.converters.Converter
public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
Map map = (Map) createCollection(unmarshallingContext.getRequiredType());
populateMap(hierarchicalStreamReader, unmarshallingContext, map);
return map;
}
public MapConverter(Mapper mapper, Class cls) {
super(mapper);
this.type = cls;
if (cls != null) {
Class cls2 = class$java$util$Map;
if (cls2 == null) {
cls2 = class$("java.util.Map");
class$java$util$Map = cls2;
}
if (cls2.isAssignableFrom(cls)) {
return;
}
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(cls);
stringBuffer.append(" not of type ");
Class cls3 = class$java$util$Map;
if (cls3 == null) {
cls3 = class$("java.util.Map");
class$java$util$Map = cls3;
}
stringBuffer.append(cls3);
throw new IllegalArgumentException(stringBuffer.toString());
}
}
protected void populateMap(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext, Map map, Map map2) {
while (hierarchicalStreamReader.hasMoreChildren()) {
hierarchicalStreamReader.moveDown();
putCurrentEntryIntoMap(hierarchicalStreamReader, unmarshallingContext, map, map2);
hierarchicalStreamReader.moveUp();
}
}
}

View File

@@ -0,0 +1,100 @@
package com.thoughtworks.xstream.converters.collections;
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.core.util.Fields;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.unity3d.ads.metadata.MediationMetaData;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
/* loaded from: classes.dex */
public class PropertiesConverter implements Converter {
static /* synthetic */ Class class$java$util$Properties;
private static final Field defaultsField;
private final boolean sort;
static {
Class cls = class$java$util$Properties;
if (cls == null) {
cls = class$("java.util.Properties");
class$java$util$Properties = cls;
}
Class cls2 = class$java$util$Properties;
if (cls2 == null) {
cls2 = class$("java.util.Properties");
class$java$util$Properties = cls2;
}
defaultsField = Fields.locate(cls, cls2, false);
}
public PropertiesConverter() {
this(false);
}
static /* synthetic */ Class class$(String str) {
try {
return Class.forName(str);
} catch (ClassNotFoundException e) {
throw new NoClassDefFoundError().initCause(e);
}
}
@Override // com.thoughtworks.xstream.converters.ConverterMatcher
public boolean canConvert(Class cls) {
Class cls2 = class$java$util$Properties;
if (cls2 == null) {
cls2 = class$("java.util.Properties");
class$java$util$Properties = cls2;
}
return cls2 == cls;
}
@Override // com.thoughtworks.xstream.converters.Converter
public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
Properties properties;
Properties properties2 = (Properties) obj;
for (Map.Entry entry : (this.sort ? new TreeMap(properties2) : properties2).entrySet()) {
hierarchicalStreamWriter.startNode("property");
hierarchicalStreamWriter.addAttribute(MediationMetaData.KEY_NAME, entry.getKey().toString());
hierarchicalStreamWriter.addAttribute("value", entry.getValue().toString());
hierarchicalStreamWriter.endNode();
}
Field field = defaultsField;
if (field == null || (properties = (Properties) Fields.read(field, properties2)) == null) {
return;
}
hierarchicalStreamWriter.startNode("defaults");
marshal(properties, hierarchicalStreamWriter, marshallingContext);
hierarchicalStreamWriter.endNode();
}
@Override // com.thoughtworks.xstream.converters.Converter
public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
Properties properties = new Properties();
Properties properties2 = null;
while (hierarchicalStreamReader.hasMoreChildren()) {
hierarchicalStreamReader.moveDown();
if (hierarchicalStreamReader.getNodeName().equals("defaults")) {
properties2 = (Properties) unmarshal(hierarchicalStreamReader, unmarshallingContext);
} else {
properties.setProperty(hierarchicalStreamReader.getAttribute(MediationMetaData.KEY_NAME), hierarchicalStreamReader.getAttribute("value"));
}
hierarchicalStreamReader.moveUp();
}
if (properties2 == null) {
return properties;
}
Properties properties3 = new Properties(properties2);
properties3.putAll(properties);
return properties3;
}
public PropertiesConverter(boolean z) {
this.sort = z;
}
}

View File

@@ -0,0 +1,27 @@
package com.thoughtworks.xstream.converters.collections;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.mapper.Mapper;
import java.util.Collections;
/* loaded from: classes.dex */
public class SingletonCollectionConverter extends CollectionConverter {
private static final Class LIST = Collections.singletonList(Boolean.TRUE).getClass();
private static final Class SET = Collections.singleton(Boolean.TRUE).getClass();
public SingletonCollectionConverter(Mapper mapper) {
super(mapper);
}
@Override // com.thoughtworks.xstream.converters.collections.CollectionConverter, com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter, com.thoughtworks.xstream.converters.ConverterMatcher
public boolean canConvert(Class cls) {
return LIST == cls || SET == cls;
}
@Override // com.thoughtworks.xstream.converters.collections.CollectionConverter, com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter, com.thoughtworks.xstream.converters.Converter
public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
Object readCompleteItem = readCompleteItem(hierarchicalStreamReader, unmarshallingContext, null);
return unmarshallingContext.getRequiredType() == LIST ? Collections.singletonList(readCompleteItem) : Collections.singleton(readCompleteItem);
}
}

View File

@@ -0,0 +1,29 @@
package com.thoughtworks.xstream.converters.collections;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.mapper.Mapper;
import java.util.Collections;
/* loaded from: classes.dex */
public class SingletonMapConverter extends MapConverter {
private static final Class MAP = Collections.singletonMap(Boolean.TRUE, null).getClass();
public SingletonMapConverter(Mapper mapper) {
super(mapper);
}
@Override // com.thoughtworks.xstream.converters.collections.MapConverter, com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter, com.thoughtworks.xstream.converters.ConverterMatcher
public boolean canConvert(Class cls) {
return MAP == cls;
}
@Override // com.thoughtworks.xstream.converters.collections.MapConverter, com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter, com.thoughtworks.xstream.converters.Converter
public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
hierarchicalStreamReader.moveDown();
Object readCompleteItem = readCompleteItem(hierarchicalStreamReader, unmarshallingContext, null);
Object readCompleteItem2 = readCompleteItem(hierarchicalStreamReader, unmarshallingContext, null);
hierarchicalStreamReader.moveUp();
return Collections.singletonMap(readCompleteItem, readCompleteItem2);
}
}

View File

@@ -0,0 +1,151 @@
package com.thoughtworks.xstream.converters.collections;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.converters.reflection.ObjectAccessException;
import com.thoughtworks.xstream.core.JVM;
import com.thoughtworks.xstream.core.util.Fields;
import com.thoughtworks.xstream.core.util.HierarchicalStreams;
import com.thoughtworks.xstream.core.util.PresortedMap;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.mapper.Mapper;
import java.lang.reflect.Field;
import java.util.Comparator;
import java.util.SortedMap;
import java.util.TreeMap;
/* loaded from: classes.dex */
public class TreeMapConverter extends MapConverter {
private static final Comparator NULL_MARKER = new NullComparator();
static /* synthetic */ Class class$java$util$Comparator;
static /* synthetic */ Class class$java$util$TreeMap;
private static final Field comparatorField;
private static final class NullComparator extends Mapper.Null implements Comparator {
private NullComparator() {
}
@Override // java.util.Comparator
public int compare(Object obj, Object obj2) {
return ((Comparable) obj).compareTo(obj2);
}
}
static {
Class cls = class$java$util$TreeMap;
if (cls == null) {
cls = class$("java.util.TreeMap");
class$java$util$TreeMap = cls;
}
Class cls2 = class$java$util$Comparator;
if (cls2 == null) {
cls2 = class$("java.util.Comparator");
class$java$util$Comparator = cls2;
}
comparatorField = Fields.locate(cls, cls2, false);
}
/* JADX WARN: Illegal instructions before constructor call */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
public TreeMapConverter(com.thoughtworks.xstream.mapper.Mapper r2) {
/*
r1 = this;
java.lang.Class r0 = com.thoughtworks.xstream.converters.collections.TreeMapConverter.class$java$util$TreeMap
if (r0 != 0) goto Lc
java.lang.String r0 = "java.util.TreeMap"
java.lang.Class r0 = class$(r0)
com.thoughtworks.xstream.converters.collections.TreeMapConverter.class$java$util$TreeMap = r0
Lc:
r1.<init>(r2, r0)
return
*/
throw new UnsupportedOperationException("Method not decompiled: com.thoughtworks.xstream.converters.collections.TreeMapConverter.<init>(com.thoughtworks.xstream.mapper.Mapper):void");
}
static /* synthetic */ Class class$(String str) {
try {
return Class.forName(str);
} catch (ClassNotFoundException e) {
throw new NoClassDefFoundError().initCause(e);
}
}
@Override // com.thoughtworks.xstream.converters.collections.MapConverter, com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter, com.thoughtworks.xstream.converters.Converter
public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
marshalComparator(((SortedMap) obj).comparator(), hierarchicalStreamWriter, marshallingContext);
super.marshal(obj, hierarchicalStreamWriter, marshallingContext);
}
protected void marshalComparator(Comparator comparator, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
if (comparator != null) {
hierarchicalStreamWriter.startNode("comparator");
hierarchicalStreamWriter.addAttribute(mapper().aliasForSystemAttribute("class"), mapper().serializedClass(comparator.getClass()));
marshallingContext.convertAnother(comparator);
hierarchicalStreamWriter.endNode();
}
}
protected void populateTreeMap(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext, TreeMap treeMap, Comparator comparator) {
boolean z = comparator == NULL_MARKER;
Comparator comparator2 = null;
if (z) {
comparator = null;
}
if (comparator != null && JVM.hasOptimizedTreeMapPutAll()) {
comparator2 = comparator;
}
PresortedMap presortedMap = new PresortedMap(comparator2);
if (z) {
putCurrentEntryIntoMap(hierarchicalStreamReader, unmarshallingContext, treeMap, presortedMap);
hierarchicalStreamReader.moveUp();
}
populateMap(hierarchicalStreamReader, unmarshallingContext, treeMap, presortedMap);
try {
if (JVM.hasOptimizedTreeMapPutAll()) {
if (comparator != null && comparatorField != null) {
comparatorField.set(treeMap, comparator);
}
treeMap.putAll(presortedMap);
return;
}
if (comparatorField == null) {
treeMap.putAll(presortedMap);
return;
}
comparatorField.set(treeMap, presortedMap.comparator());
treeMap.putAll(presortedMap);
comparatorField.set(treeMap, comparator);
} catch (IllegalAccessException e) {
throw new ObjectAccessException("Cannot set comparator of TreeMap", e);
}
}
@Override // com.thoughtworks.xstream.converters.collections.MapConverter, com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter, com.thoughtworks.xstream.converters.Converter
public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
TreeMap treeMap = comparatorField != null ? new TreeMap() : null;
Comparator unmarshalComparator = unmarshalComparator(hierarchicalStreamReader, unmarshallingContext, treeMap);
if (treeMap == null) {
treeMap = (unmarshalComparator == null || unmarshalComparator == NULL_MARKER) ? new TreeMap() : new TreeMap(unmarshalComparator);
}
populateTreeMap(hierarchicalStreamReader, unmarshallingContext, treeMap, unmarshalComparator);
return treeMap;
}
protected Comparator unmarshalComparator(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext, TreeMap treeMap) {
Comparator comparator = null;
if (hierarchicalStreamReader.hasMoreChildren()) {
hierarchicalStreamReader.moveDown();
if (hierarchicalStreamReader.getNodeName().equals("comparator")) {
comparator = (Comparator) unmarshallingContext.convertAnother(treeMap, HierarchicalStreams.readClassType(hierarchicalStreamReader, mapper()));
} else if (!hierarchicalStreamReader.getNodeName().equals("no-comparator")) {
return NULL_MARKER;
}
hierarchicalStreamReader.moveUp();
}
return comparator;
}
}

View File

@@ -0,0 +1,205 @@
package com.thoughtworks.xstream.converters.collections;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.converters.reflection.ObjectAccessException;
import com.thoughtworks.xstream.core.JVM;
import com.thoughtworks.xstream.core.util.Fields;
import com.thoughtworks.xstream.core.util.PresortedSet;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.mapper.Mapper;
import java.lang.reflect.Field;
import java.util.AbstractList;
import java.util.Comparator;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
/* loaded from: classes.dex */
public class TreeSetConverter extends CollectionConverter {
static /* synthetic */ Class class$java$lang$Object;
static /* synthetic */ Class class$java$util$SortedMap;
static /* synthetic */ Class class$java$util$TreeSet;
private static final Object constantValue;
private static final Field sortedMapField;
private transient TreeMapConverter treeMapConverter;
static {
Field field;
Map map;
Object obj = null;
if (JVM.hasOptimizedTreeSetAddAll()) {
Class cls = class$java$util$TreeSet;
if (cls == null) {
cls = class$("java.util.TreeSet");
class$java$util$TreeSet = cls;
}
Class cls2 = class$java$util$SortedMap;
if (cls2 == null) {
cls2 = class$("java.util.SortedMap");
class$java$util$SortedMap = cls2;
}
field = Fields.locate(cls, cls2, false);
} else {
field = null;
}
sortedMapField = field;
if (sortedMapField != null) {
TreeSet treeSet = new TreeSet();
treeSet.add("1");
treeSet.add("2");
try {
map = (Map) sortedMapField.get(treeSet);
} catch (IllegalAccessException unused) {
map = null;
}
if (map != null) {
Object[] array = map.values().toArray();
if (array[0] == array[1]) {
obj = array[0];
}
}
} else {
Class cls3 = class$java$util$TreeSet;
if (cls3 == null) {
cls3 = class$("java.util.TreeSet");
class$java$util$TreeSet = cls3;
}
Class cls4 = class$java$lang$Object;
if (cls4 == null) {
cls4 = class$("java.lang.Object");
class$java$lang$Object = cls4;
}
Field locate = Fields.locate(cls3, cls4, true);
if (locate != null) {
try {
obj = locate.get(null);
} catch (IllegalAccessException unused2) {
}
}
}
constantValue = obj;
}
/* JADX WARN: Illegal instructions before constructor call */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
public TreeSetConverter(com.thoughtworks.xstream.mapper.Mapper r2) {
/*
r1 = this;
java.lang.Class r0 = com.thoughtworks.xstream.converters.collections.TreeSetConverter.class$java$util$TreeSet
if (r0 != 0) goto Lc
java.lang.String r0 = "java.util.TreeSet"
java.lang.Class r0 = class$(r0)
com.thoughtworks.xstream.converters.collections.TreeSetConverter.class$java$util$TreeSet = r0
Lc:
r1.<init>(r2, r0)
r1.readResolve()
return
*/
throw new UnsupportedOperationException("Method not decompiled: com.thoughtworks.xstream.converters.collections.TreeSetConverter.<init>(com.thoughtworks.xstream.mapper.Mapper):void");
}
static /* synthetic */ Class class$(String str) {
try {
return Class.forName(str);
} catch (ClassNotFoundException e) {
throw new NoClassDefFoundError().initCause(e);
}
}
private Object readResolve() {
this.treeMapConverter = new TreeMapConverter(mapper()) { // from class: com.thoughtworks.xstream.converters.collections.TreeSetConverter.1
@Override // com.thoughtworks.xstream.converters.collections.MapConverter
protected void populateMap(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext, Map map, final Map map2) {
TreeSetConverter.this.populateCollection(hierarchicalStreamReader, unmarshallingContext, new AbstractList() { // from class: com.thoughtworks.xstream.converters.collections.TreeSetConverter.1.1
@Override // java.util.AbstractList, java.util.AbstractCollection, java.util.Collection, java.util.List
public boolean add(Object obj) {
return map2.put(obj, TreeSetConverter.constantValue != null ? TreeSetConverter.constantValue : obj) != null;
}
@Override // java.util.AbstractList, java.util.List
public Object get(int i) {
return null;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
public int size() {
return map2.size();
}
});
}
@Override // com.thoughtworks.xstream.converters.collections.MapConverter
protected void putCurrentEntryIntoMap(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext, Map map, Map map2) {
Object readItem = readItem(hierarchicalStreamReader, unmarshallingContext, map);
map2.put(readItem, readItem);
}
};
return this;
}
@Override // com.thoughtworks.xstream.converters.collections.CollectionConverter, com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter, com.thoughtworks.xstream.converters.Converter
public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
this.treeMapConverter.marshalComparator(((SortedSet) obj).comparator(), hierarchicalStreamWriter, marshallingContext);
super.marshal(obj, hierarchicalStreamWriter, marshallingContext);
}
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Type inference failed for: r4v10, types: [java.util.TreeSet] */
/* JADX WARN: Type inference failed for: r4v4, types: [java.util.Collection, java.util.TreeSet] */
/* JADX WARN: Type inference failed for: r4v5, types: [java.lang.Object, java.util.TreeSet] */
/* JADX WARN: Type inference failed for: r4v9, types: [java.util.TreeSet] */
/* JADX WARN: Type inference failed for: r5v0, types: [java.lang.reflect.Field] */
/* JADX WARN: Type inference failed for: r7v0, types: [com.thoughtworks.xstream.converters.collections.CollectionConverter, com.thoughtworks.xstream.converters.collections.TreeSetConverter] */
@Override // com.thoughtworks.xstream.converters.collections.CollectionConverter, com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter, com.thoughtworks.xstream.converters.Converter
public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
TreeMap treeMap;
TreeMap treeMap2;
TreeMap treeMap3;
TreeMap treeMap4 = null;
Comparator unmarshalComparator = this.treeMapConverter.unmarshalComparator(hierarchicalStreamReader, unmarshallingContext, null);
boolean z = unmarshalComparator instanceof Mapper.Null;
Comparator comparator = z ? null : unmarshalComparator;
if (sortedMapField != null) {
?? treeSet = comparator == null ? new TreeSet() : new TreeSet(comparator);
try {
Object obj = sortedMapField.get(treeSet);
if (obj instanceof TreeMap) {
treeMap3 = (TreeMap) obj;
treeMap4 = treeSet;
} else {
treeMap3 = null;
}
treeMap = treeMap4;
treeMap4 = treeMap3;
} catch (IllegalAccessException e) {
throw new ObjectAccessException("Cannot get backing map of TreeSet", e);
}
} else {
treeMap = null;
}
if (treeMap4 == null) {
PresortedSet presortedSet = new PresortedSet(comparator);
?? treeSet2 = comparator == null ? new TreeSet() : new TreeSet(comparator);
if (z) {
addCurrentElementToCollection(hierarchicalStreamReader, unmarshallingContext, treeSet2, presortedSet);
hierarchicalStreamReader.moveUp();
}
populateCollection(hierarchicalStreamReader, unmarshallingContext, treeSet2, presortedSet);
treeMap2 = treeSet2;
if (presortedSet.size() > 0) {
treeSet2.addAll(presortedSet);
treeMap2 = treeSet2;
}
} else {
this.treeMapConverter.populateTreeMap(hierarchicalStreamReader, unmarshallingContext, treeMap4, unmarshalComparator);
treeMap2 = treeMap;
}
return treeMap2;
}
}