Initial commit
This commit is contained in:
71
sources/com/google/gson/internal/bind/ArrayTypeAdapter.java
Normal file
71
sources/com/google/gson/internal/bind/ArrayTypeAdapter.java
Normal file
@@ -0,0 +1,71 @@
|
||||
package com.google.gson.internal.bind;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.internal.C$Gson$Types;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.GenericArrayType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class ArrayTypeAdapter<E> extends TypeAdapter<Object> {
|
||||
public static final TypeAdapterFactory FACTORY = new TypeAdapterFactory() { // from class: com.google.gson.internal.bind.ArrayTypeAdapter.1
|
||||
@Override // com.google.gson.TypeAdapterFactory
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
|
||||
Type type = typeToken.getType();
|
||||
if (!(type instanceof GenericArrayType) && (!(type instanceof Class) || !((Class) type).isArray())) {
|
||||
return null;
|
||||
}
|
||||
Type arrayComponentType = C$Gson$Types.getArrayComponentType(type);
|
||||
return new ArrayTypeAdapter(gson, gson.getAdapter(TypeToken.get(arrayComponentType)), C$Gson$Types.getRawType(arrayComponentType));
|
||||
}
|
||||
};
|
||||
private final Class<E> componentType;
|
||||
private final TypeAdapter<E> componentTypeAdapter;
|
||||
|
||||
public ArrayTypeAdapter(Gson gson, TypeAdapter<E> typeAdapter, Class<E> cls) {
|
||||
this.componentTypeAdapter = new TypeAdapterRuntimeTypeWrapper(gson, typeAdapter, cls);
|
||||
this.componentType = cls;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public Object read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() == JsonToken.NULL) {
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
jsonReader.beginArray();
|
||||
while (jsonReader.hasNext()) {
|
||||
arrayList.add(this.componentTypeAdapter.read(jsonReader));
|
||||
}
|
||||
jsonReader.endArray();
|
||||
int size = arrayList.size();
|
||||
Object newInstance = Array.newInstance((Class<?>) this.componentType, size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
Array.set(newInstance, i, arrayList.get(i));
|
||||
}
|
||||
return newInstance;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, Object obj) throws IOException {
|
||||
if (obj == null) {
|
||||
jsonWriter.nullValue();
|
||||
return;
|
||||
}
|
||||
jsonWriter.beginArray();
|
||||
int length = Array.getLength(obj);
|
||||
for (int i = 0; i < length; i++) {
|
||||
this.componentTypeAdapter.write(jsonWriter, Array.get(obj, i));
|
||||
}
|
||||
jsonWriter.endArray();
|
||||
}
|
||||
}
|
@@ -0,0 +1,75 @@
|
||||
package com.google.gson.internal.bind;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.internal.C$Gson$Types;
|
||||
import com.google.gson.internal.ConstructorConstructor;
|
||||
import com.google.gson.internal.ObjectConstructor;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class CollectionTypeAdapterFactory implements TypeAdapterFactory {
|
||||
private final ConstructorConstructor constructorConstructor;
|
||||
|
||||
private static final class Adapter<E> extends TypeAdapter<Collection<E>> {
|
||||
private final ObjectConstructor<? extends Collection<E>> constructor;
|
||||
private final TypeAdapter<E> elementTypeAdapter;
|
||||
|
||||
public Adapter(Gson gson, Type type, TypeAdapter<E> typeAdapter, ObjectConstructor<? extends Collection<E>> objectConstructor) {
|
||||
this.elementTypeAdapter = new TypeAdapterRuntimeTypeWrapper(gson, typeAdapter, type);
|
||||
this.constructor = objectConstructor;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public Collection<E> read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() == JsonToken.NULL) {
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
Collection<E> construct = this.constructor.construct();
|
||||
jsonReader.beginArray();
|
||||
while (jsonReader.hasNext()) {
|
||||
construct.add(this.elementTypeAdapter.read(jsonReader));
|
||||
}
|
||||
jsonReader.endArray();
|
||||
return construct;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, Collection<E> collection) throws IOException {
|
||||
if (collection == null) {
|
||||
jsonWriter.nullValue();
|
||||
return;
|
||||
}
|
||||
jsonWriter.beginArray();
|
||||
Iterator<E> it = collection.iterator();
|
||||
while (it.hasNext()) {
|
||||
this.elementTypeAdapter.write(jsonWriter, it.next());
|
||||
}
|
||||
jsonWriter.endArray();
|
||||
}
|
||||
}
|
||||
|
||||
public CollectionTypeAdapterFactory(ConstructorConstructor constructorConstructor) {
|
||||
this.constructorConstructor = constructorConstructor;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapterFactory
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
|
||||
Type type = typeToken.getType();
|
||||
Class<? super T> rawType = typeToken.getRawType();
|
||||
if (!Collection.class.isAssignableFrom(rawType)) {
|
||||
return null;
|
||||
}
|
||||
Type collectionElementType = C$Gson$Types.getCollectionElementType(type, rawType);
|
||||
return new Adapter(gson, collectionElementType, gson.getAdapter(TypeToken.get(collectionElementType)), this.constructorConstructor.get(typeToken));
|
||||
}
|
||||
}
|
66
sources/com/google/gson/internal/bind/DateTypeAdapter.java
Normal file
66
sources/com/google/gson/internal/bind/DateTypeAdapter.java
Normal file
@@ -0,0 +1,66 @@
|
||||
package com.google.gson.internal.bind;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.internal.bind.util.ISO8601Utils;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class DateTypeAdapter extends TypeAdapter<Date> {
|
||||
public static final TypeAdapterFactory FACTORY = new TypeAdapterFactory() { // from class: com.google.gson.internal.bind.DateTypeAdapter.1
|
||||
@Override // com.google.gson.TypeAdapterFactory
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
|
||||
if (typeToken.getRawType() == Date.class) {
|
||||
return new DateTypeAdapter();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
private final DateFormat enUsFormat = DateFormat.getDateTimeInstance(2, 2, Locale.US);
|
||||
private final DateFormat localFormat = DateFormat.getDateTimeInstance(2, 2);
|
||||
|
||||
private synchronized Date deserializeToDate(String str) {
|
||||
try {
|
||||
try {
|
||||
try {
|
||||
} catch (ParseException unused) {
|
||||
return this.enUsFormat.parse(str);
|
||||
}
|
||||
} catch (ParseException unused2) {
|
||||
return ISO8601Utils.parse(str, new ParsePosition(0));
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
throw new JsonSyntaxException(str, e);
|
||||
}
|
||||
return this.localFormat.parse(str);
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public Date read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() != JsonToken.NULL) {
|
||||
return deserializeToDate(jsonReader.nextString());
|
||||
}
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public synchronized void write(JsonWriter jsonWriter, Date date) throws IOException {
|
||||
if (date == null) {
|
||||
jsonWriter.nullValue();
|
||||
} else {
|
||||
jsonWriter.value(this.enUsFormat.format(date));
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
package com.google.gson.internal.bind;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.internal.ConstructorConstructor;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class JsonAdapterAnnotationTypeAdapterFactory implements TypeAdapterFactory {
|
||||
private final ConstructorConstructor constructorConstructor;
|
||||
|
||||
public JsonAdapterAnnotationTypeAdapterFactory(ConstructorConstructor constructorConstructor) {
|
||||
this.constructorConstructor = constructorConstructor;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapterFactory
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
|
||||
JsonAdapter jsonAdapter = (JsonAdapter) typeToken.getRawType().getAnnotation(JsonAdapter.class);
|
||||
if (jsonAdapter == null) {
|
||||
return null;
|
||||
}
|
||||
return (TypeAdapter<T>) getTypeAdapter(this.constructorConstructor, gson, typeToken, jsonAdapter);
|
||||
}
|
||||
|
||||
TypeAdapter<?> getTypeAdapter(ConstructorConstructor constructorConstructor, Gson gson, TypeToken<?> typeToken, JsonAdapter jsonAdapter) {
|
||||
TypeAdapter<?> treeTypeAdapter;
|
||||
Object construct = constructorConstructor.get(TypeToken.get((Class) jsonAdapter.value())).construct();
|
||||
if (construct instanceof TypeAdapter) {
|
||||
treeTypeAdapter = (TypeAdapter) construct;
|
||||
} else if (construct instanceof TypeAdapterFactory) {
|
||||
treeTypeAdapter = ((TypeAdapterFactory) construct).create(gson, typeToken);
|
||||
} else {
|
||||
boolean z = construct instanceof JsonSerializer;
|
||||
if (!z && !(construct instanceof JsonDeserializer)) {
|
||||
throw new IllegalArgumentException("Invalid attempt to bind an instance of " + construct.getClass().getName() + " as a @JsonAdapter for " + typeToken.toString() + ". @JsonAdapter value must be a TypeAdapter, TypeAdapterFactory, JsonSerializer or JsonDeserializer.");
|
||||
}
|
||||
treeTypeAdapter = new TreeTypeAdapter<>(z ? (JsonSerializer) construct : null, construct instanceof JsonDeserializer ? (JsonDeserializer) construct : null, gson, typeToken, null);
|
||||
}
|
||||
return (treeTypeAdapter == null || !jsonAdapter.nullSafe()) ? treeTypeAdapter : treeTypeAdapter.nullSafe();
|
||||
}
|
||||
}
|
349
sources/com/google/gson/internal/bind/JsonTreeReader.java
Normal file
349
sources/com/google/gson/internal/bind/JsonTreeReader.java
Normal file
@@ -0,0 +1,349 @@
|
||||
package com.google.gson.internal.bind;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonNull;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class JsonTreeReader extends JsonReader {
|
||||
private int[] pathIndices;
|
||||
private String[] pathNames;
|
||||
private Object[] stack;
|
||||
private int stackSize;
|
||||
private static final Reader UNREADABLE_READER = new Reader() { // from class: com.google.gson.internal.bind.JsonTreeReader.1
|
||||
@Override // java.io.Reader, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() throws IOException {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@Override // java.io.Reader
|
||||
public int read(char[] cArr, int i, int i2) throws IOException {
|
||||
throw new AssertionError();
|
||||
}
|
||||
};
|
||||
private static final Object SENTINEL_CLOSED = new Object();
|
||||
|
||||
public JsonTreeReader(JsonElement jsonElement) {
|
||||
super(UNREADABLE_READER);
|
||||
this.stack = new Object[32];
|
||||
this.stackSize = 0;
|
||||
this.pathNames = new String[32];
|
||||
this.pathIndices = new int[32];
|
||||
push(jsonElement);
|
||||
}
|
||||
|
||||
private void expect(JsonToken jsonToken) throws IOException {
|
||||
if (peek() == jsonToken) {
|
||||
return;
|
||||
}
|
||||
throw new IllegalStateException("Expected " + jsonToken + " but was " + peek() + locationString());
|
||||
}
|
||||
|
||||
private String locationString() {
|
||||
return " at path " + getPath();
|
||||
}
|
||||
|
||||
private Object peekStack() {
|
||||
return this.stack[this.stackSize - 1];
|
||||
}
|
||||
|
||||
private Object popStack() {
|
||||
Object[] objArr = this.stack;
|
||||
int i = this.stackSize - 1;
|
||||
this.stackSize = i;
|
||||
Object obj = objArr[i];
|
||||
objArr[this.stackSize] = null;
|
||||
return obj;
|
||||
}
|
||||
|
||||
private void push(Object obj) {
|
||||
int i = this.stackSize;
|
||||
Object[] objArr = this.stack;
|
||||
if (i == objArr.length) {
|
||||
Object[] objArr2 = new Object[i * 2];
|
||||
int[] iArr = new int[i * 2];
|
||||
String[] strArr = new String[i * 2];
|
||||
System.arraycopy(objArr, 0, objArr2, 0, i);
|
||||
System.arraycopy(this.pathIndices, 0, iArr, 0, this.stackSize);
|
||||
System.arraycopy(this.pathNames, 0, strArr, 0, this.stackSize);
|
||||
this.stack = objArr2;
|
||||
this.pathIndices = iArr;
|
||||
this.pathNames = strArr;
|
||||
}
|
||||
Object[] objArr3 = this.stack;
|
||||
int i2 = this.stackSize;
|
||||
this.stackSize = i2 + 1;
|
||||
objArr3[i2] = obj;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonReader
|
||||
public void beginArray() throws IOException {
|
||||
expect(JsonToken.BEGIN_ARRAY);
|
||||
push(((JsonArray) peekStack()).iterator());
|
||||
this.pathIndices[this.stackSize - 1] = 0;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonReader
|
||||
public void beginObject() throws IOException {
|
||||
expect(JsonToken.BEGIN_OBJECT);
|
||||
push(((JsonObject) peekStack()).entrySet().iterator());
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonReader, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() throws IOException {
|
||||
this.stack = new Object[]{SENTINEL_CLOSED};
|
||||
this.stackSize = 1;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonReader
|
||||
public void endArray() throws IOException {
|
||||
expect(JsonToken.END_ARRAY);
|
||||
popStack();
|
||||
popStack();
|
||||
int i = this.stackSize;
|
||||
if (i > 0) {
|
||||
int[] iArr = this.pathIndices;
|
||||
int i2 = i - 1;
|
||||
iArr[i2] = iArr[i2] + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonReader
|
||||
public void endObject() throws IOException {
|
||||
expect(JsonToken.END_OBJECT);
|
||||
popStack();
|
||||
popStack();
|
||||
int i = this.stackSize;
|
||||
if (i > 0) {
|
||||
int[] iArr = this.pathIndices;
|
||||
int i2 = i - 1;
|
||||
iArr[i2] = iArr[i2] + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonReader
|
||||
public String getPath() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append('$');
|
||||
int i = 0;
|
||||
while (i < this.stackSize) {
|
||||
Object[] objArr = this.stack;
|
||||
if (objArr[i] instanceof JsonArray) {
|
||||
i++;
|
||||
if (objArr[i] instanceof Iterator) {
|
||||
sb.append('[');
|
||||
sb.append(this.pathIndices[i]);
|
||||
sb.append(']');
|
||||
}
|
||||
} else if (objArr[i] instanceof JsonObject) {
|
||||
i++;
|
||||
if (objArr[i] instanceof Iterator) {
|
||||
sb.append('.');
|
||||
String[] strArr = this.pathNames;
|
||||
if (strArr[i] != null) {
|
||||
sb.append(strArr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonReader
|
||||
public boolean hasNext() throws IOException {
|
||||
JsonToken peek = peek();
|
||||
return (peek == JsonToken.END_OBJECT || peek == JsonToken.END_ARRAY) ? false : true;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonReader
|
||||
public boolean nextBoolean() throws IOException {
|
||||
expect(JsonToken.BOOLEAN);
|
||||
boolean asBoolean = ((JsonPrimitive) popStack()).getAsBoolean();
|
||||
int i = this.stackSize;
|
||||
if (i > 0) {
|
||||
int[] iArr = this.pathIndices;
|
||||
int i2 = i - 1;
|
||||
iArr[i2] = iArr[i2] + 1;
|
||||
}
|
||||
return asBoolean;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonReader
|
||||
public double nextDouble() throws IOException {
|
||||
JsonToken peek = peek();
|
||||
if (peek != JsonToken.NUMBER && peek != JsonToken.STRING) {
|
||||
throw new IllegalStateException("Expected " + JsonToken.NUMBER + " but was " + peek + locationString());
|
||||
}
|
||||
double asDouble = ((JsonPrimitive) peekStack()).getAsDouble();
|
||||
if (!isLenient() && (Double.isNaN(asDouble) || Double.isInfinite(asDouble))) {
|
||||
throw new NumberFormatException("JSON forbids NaN and infinities: " + asDouble);
|
||||
}
|
||||
popStack();
|
||||
int i = this.stackSize;
|
||||
if (i > 0) {
|
||||
int[] iArr = this.pathIndices;
|
||||
int i2 = i - 1;
|
||||
iArr[i2] = iArr[i2] + 1;
|
||||
}
|
||||
return asDouble;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonReader
|
||||
public int nextInt() throws IOException {
|
||||
JsonToken peek = peek();
|
||||
if (peek != JsonToken.NUMBER && peek != JsonToken.STRING) {
|
||||
throw new IllegalStateException("Expected " + JsonToken.NUMBER + " but was " + peek + locationString());
|
||||
}
|
||||
int asInt = ((JsonPrimitive) peekStack()).getAsInt();
|
||||
popStack();
|
||||
int i = this.stackSize;
|
||||
if (i > 0) {
|
||||
int[] iArr = this.pathIndices;
|
||||
int i2 = i - 1;
|
||||
iArr[i2] = iArr[i2] + 1;
|
||||
}
|
||||
return asInt;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonReader
|
||||
public long nextLong() throws IOException {
|
||||
JsonToken peek = peek();
|
||||
if (peek != JsonToken.NUMBER && peek != JsonToken.STRING) {
|
||||
throw new IllegalStateException("Expected " + JsonToken.NUMBER + " but was " + peek + locationString());
|
||||
}
|
||||
long asLong = ((JsonPrimitive) peekStack()).getAsLong();
|
||||
popStack();
|
||||
int i = this.stackSize;
|
||||
if (i > 0) {
|
||||
int[] iArr = this.pathIndices;
|
||||
int i2 = i - 1;
|
||||
iArr[i2] = iArr[i2] + 1;
|
||||
}
|
||||
return asLong;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonReader
|
||||
public String nextName() throws IOException {
|
||||
expect(JsonToken.NAME);
|
||||
Map.Entry entry = (Map.Entry) ((Iterator) peekStack()).next();
|
||||
String str = (String) entry.getKey();
|
||||
this.pathNames[this.stackSize - 1] = str;
|
||||
push(entry.getValue());
|
||||
return str;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonReader
|
||||
public void nextNull() throws IOException {
|
||||
expect(JsonToken.NULL);
|
||||
popStack();
|
||||
int i = this.stackSize;
|
||||
if (i > 0) {
|
||||
int[] iArr = this.pathIndices;
|
||||
int i2 = i - 1;
|
||||
iArr[i2] = iArr[i2] + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonReader
|
||||
public String nextString() throws IOException {
|
||||
JsonToken peek = peek();
|
||||
if (peek == JsonToken.STRING || peek == JsonToken.NUMBER) {
|
||||
String asString = ((JsonPrimitive) popStack()).getAsString();
|
||||
int i = this.stackSize;
|
||||
if (i > 0) {
|
||||
int[] iArr = this.pathIndices;
|
||||
int i2 = i - 1;
|
||||
iArr[i2] = iArr[i2] + 1;
|
||||
}
|
||||
return asString;
|
||||
}
|
||||
throw new IllegalStateException("Expected " + JsonToken.STRING + " but was " + peek + locationString());
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonReader
|
||||
public JsonToken peek() throws IOException {
|
||||
if (this.stackSize == 0) {
|
||||
return JsonToken.END_DOCUMENT;
|
||||
}
|
||||
Object peekStack = peekStack();
|
||||
if (peekStack instanceof Iterator) {
|
||||
boolean z = this.stack[this.stackSize - 2] instanceof JsonObject;
|
||||
Iterator it = (Iterator) peekStack;
|
||||
if (!it.hasNext()) {
|
||||
return z ? JsonToken.END_OBJECT : JsonToken.END_ARRAY;
|
||||
}
|
||||
if (z) {
|
||||
return JsonToken.NAME;
|
||||
}
|
||||
push(it.next());
|
||||
return peek();
|
||||
}
|
||||
if (peekStack instanceof JsonObject) {
|
||||
return JsonToken.BEGIN_OBJECT;
|
||||
}
|
||||
if (peekStack instanceof JsonArray) {
|
||||
return JsonToken.BEGIN_ARRAY;
|
||||
}
|
||||
if (!(peekStack instanceof JsonPrimitive)) {
|
||||
if (peekStack instanceof JsonNull) {
|
||||
return JsonToken.NULL;
|
||||
}
|
||||
if (peekStack == SENTINEL_CLOSED) {
|
||||
throw new IllegalStateException("JsonReader is closed");
|
||||
}
|
||||
throw new AssertionError();
|
||||
}
|
||||
JsonPrimitive jsonPrimitive = (JsonPrimitive) peekStack;
|
||||
if (jsonPrimitive.isString()) {
|
||||
return JsonToken.STRING;
|
||||
}
|
||||
if (jsonPrimitive.isBoolean()) {
|
||||
return JsonToken.BOOLEAN;
|
||||
}
|
||||
if (jsonPrimitive.isNumber()) {
|
||||
return JsonToken.NUMBER;
|
||||
}
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
public void promoteNameToValue() throws IOException {
|
||||
expect(JsonToken.NAME);
|
||||
Map.Entry entry = (Map.Entry) ((Iterator) peekStack()).next();
|
||||
push(entry.getValue());
|
||||
push(new JsonPrimitive((String) entry.getKey()));
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonReader
|
||||
public void skipValue() throws IOException {
|
||||
if (peek() == JsonToken.NAME) {
|
||||
nextName();
|
||||
this.pathNames[this.stackSize - 2] = "null";
|
||||
} else {
|
||||
popStack();
|
||||
int i = this.stackSize;
|
||||
if (i > 0) {
|
||||
this.pathNames[i - 1] = "null";
|
||||
}
|
||||
}
|
||||
int i2 = this.stackSize;
|
||||
if (i2 > 0) {
|
||||
int[] iArr = this.pathIndices;
|
||||
int i3 = i2 - 1;
|
||||
iArr[i3] = iArr[i3] + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonReader
|
||||
public String toString() {
|
||||
return JsonTreeReader.class.getSimpleName();
|
||||
}
|
||||
}
|
196
sources/com/google/gson/internal/bind/JsonTreeWriter.java
Normal file
196
sources/com/google/gson/internal/bind/JsonTreeWriter.java
Normal file
@@ -0,0 +1,196 @@
|
||||
package com.google.gson.internal.bind;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonNull;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class JsonTreeWriter extends JsonWriter {
|
||||
private String pendingName;
|
||||
private JsonElement product;
|
||||
private final List<JsonElement> stack;
|
||||
private static final Writer UNWRITABLE_WRITER = new Writer() { // from class: com.google.gson.internal.bind.JsonTreeWriter.1
|
||||
@Override // java.io.Writer, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() throws IOException {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@Override // java.io.Writer, java.io.Flushable
|
||||
public void flush() throws IOException {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@Override // java.io.Writer
|
||||
public void write(char[] cArr, int i, int i2) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
};
|
||||
private static final JsonPrimitive SENTINEL_CLOSED = new JsonPrimitive("closed");
|
||||
|
||||
public JsonTreeWriter() {
|
||||
super(UNWRITABLE_WRITER);
|
||||
this.stack = new ArrayList();
|
||||
this.product = JsonNull.INSTANCE;
|
||||
}
|
||||
|
||||
private JsonElement peek() {
|
||||
return this.stack.get(r0.size() - 1);
|
||||
}
|
||||
|
||||
private void put(JsonElement jsonElement) {
|
||||
if (this.pendingName != null) {
|
||||
if (!jsonElement.isJsonNull() || getSerializeNulls()) {
|
||||
((JsonObject) peek()).add(this.pendingName, jsonElement);
|
||||
}
|
||||
this.pendingName = null;
|
||||
return;
|
||||
}
|
||||
if (this.stack.isEmpty()) {
|
||||
this.product = jsonElement;
|
||||
return;
|
||||
}
|
||||
JsonElement peek = peek();
|
||||
if (!(peek instanceof JsonArray)) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
((JsonArray) peek).add(jsonElement);
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonWriter
|
||||
public JsonWriter beginArray() throws IOException {
|
||||
JsonArray jsonArray = new JsonArray();
|
||||
put(jsonArray);
|
||||
this.stack.add(jsonArray);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonWriter
|
||||
public JsonWriter beginObject() throws IOException {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
put(jsonObject);
|
||||
this.stack.add(jsonObject);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonWriter, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() throws IOException {
|
||||
if (!this.stack.isEmpty()) {
|
||||
throw new IOException("Incomplete document");
|
||||
}
|
||||
this.stack.add(SENTINEL_CLOSED);
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonWriter
|
||||
public JsonWriter endArray() throws IOException {
|
||||
if (this.stack.isEmpty() || this.pendingName != null) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
if (!(peek() instanceof JsonArray)) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
this.stack.remove(r0.size() - 1);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonWriter
|
||||
public JsonWriter endObject() throws IOException {
|
||||
if (this.stack.isEmpty() || this.pendingName != null) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
if (!(peek() instanceof JsonObject)) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
this.stack.remove(r0.size() - 1);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonWriter, java.io.Flushable
|
||||
public void flush() throws IOException {
|
||||
}
|
||||
|
||||
public JsonElement get() {
|
||||
if (this.stack.isEmpty()) {
|
||||
return this.product;
|
||||
}
|
||||
throw new IllegalStateException("Expected one JSON element but was " + this.stack);
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonWriter
|
||||
public JsonWriter name(String str) throws IOException {
|
||||
if (this.stack.isEmpty() || this.pendingName != null) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
if (!(peek() instanceof JsonObject)) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
this.pendingName = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonWriter
|
||||
public JsonWriter nullValue() throws IOException {
|
||||
put(JsonNull.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonWriter
|
||||
public JsonWriter value(String str) throws IOException {
|
||||
if (str == null) {
|
||||
return nullValue();
|
||||
}
|
||||
put(new JsonPrimitive(str));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonWriter
|
||||
public JsonWriter value(boolean z) throws IOException {
|
||||
put(new JsonPrimitive(Boolean.valueOf(z)));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonWriter
|
||||
public JsonWriter value(Boolean bool) throws IOException {
|
||||
if (bool == null) {
|
||||
return nullValue();
|
||||
}
|
||||
put(new JsonPrimitive(bool));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonWriter
|
||||
public JsonWriter value(double d) throws IOException {
|
||||
if (!isLenient() && (Double.isNaN(d) || Double.isInfinite(d))) {
|
||||
throw new IllegalArgumentException("JSON forbids NaN and infinities: " + d);
|
||||
}
|
||||
put(new JsonPrimitive((Number) Double.valueOf(d)));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonWriter
|
||||
public JsonWriter value(long j) throws IOException {
|
||||
put(new JsonPrimitive((Number) Long.valueOf(j)));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.stream.JsonWriter
|
||||
public JsonWriter value(Number number) throws IOException {
|
||||
if (number == null) {
|
||||
return nullValue();
|
||||
}
|
||||
if (!isLenient()) {
|
||||
double doubleValue = number.doubleValue();
|
||||
if (Double.isNaN(doubleValue) || Double.isInfinite(doubleValue)) {
|
||||
throw new IllegalArgumentException("JSON forbids NaN and infinities: " + number);
|
||||
}
|
||||
}
|
||||
put(new JsonPrimitive(number));
|
||||
return this;
|
||||
}
|
||||
}
|
159
sources/com/google/gson/internal/bind/MapTypeAdapterFactory.java
Normal file
159
sources/com/google/gson/internal/bind/MapTypeAdapterFactory.java
Normal file
@@ -0,0 +1,159 @@
|
||||
package com.google.gson.internal.bind;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.internal.C$Gson$Types;
|
||||
import com.google.gson.internal.ConstructorConstructor;
|
||||
import com.google.gson.internal.JsonReaderInternalAccess;
|
||||
import com.google.gson.internal.ObjectConstructor;
|
||||
import com.google.gson.internal.Streams;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class MapTypeAdapterFactory implements TypeAdapterFactory {
|
||||
final boolean complexMapKeySerialization;
|
||||
private final ConstructorConstructor constructorConstructor;
|
||||
|
||||
private final class Adapter<K, V> extends TypeAdapter<Map<K, V>> {
|
||||
private final ObjectConstructor<? extends Map<K, V>> constructor;
|
||||
private final TypeAdapter<K> keyTypeAdapter;
|
||||
private final TypeAdapter<V> valueTypeAdapter;
|
||||
|
||||
public Adapter(Gson gson, Type type, TypeAdapter<K> typeAdapter, Type type2, TypeAdapter<V> typeAdapter2, ObjectConstructor<? extends Map<K, V>> objectConstructor) {
|
||||
this.keyTypeAdapter = new TypeAdapterRuntimeTypeWrapper(gson, typeAdapter, type);
|
||||
this.valueTypeAdapter = new TypeAdapterRuntimeTypeWrapper(gson, typeAdapter2, type2);
|
||||
this.constructor = objectConstructor;
|
||||
}
|
||||
|
||||
private String keyToString(JsonElement jsonElement) {
|
||||
if (!jsonElement.isJsonPrimitive()) {
|
||||
if (jsonElement.isJsonNull()) {
|
||||
return "null";
|
||||
}
|
||||
throw new AssertionError();
|
||||
}
|
||||
JsonPrimitive asJsonPrimitive = jsonElement.getAsJsonPrimitive();
|
||||
if (asJsonPrimitive.isNumber()) {
|
||||
return String.valueOf(asJsonPrimitive.getAsNumber());
|
||||
}
|
||||
if (asJsonPrimitive.isBoolean()) {
|
||||
return Boolean.toString(asJsonPrimitive.getAsBoolean());
|
||||
}
|
||||
if (asJsonPrimitive.isString()) {
|
||||
return asJsonPrimitive.getAsString();
|
||||
}
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public Map<K, V> read(JsonReader jsonReader) throws IOException {
|
||||
JsonToken peek = jsonReader.peek();
|
||||
if (peek == JsonToken.NULL) {
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
Map<K, V> construct = this.constructor.construct();
|
||||
if (peek == JsonToken.BEGIN_ARRAY) {
|
||||
jsonReader.beginArray();
|
||||
while (jsonReader.hasNext()) {
|
||||
jsonReader.beginArray();
|
||||
K read = this.keyTypeAdapter.read(jsonReader);
|
||||
if (construct.put(read, this.valueTypeAdapter.read(jsonReader)) != null) {
|
||||
throw new JsonSyntaxException("duplicate key: " + read);
|
||||
}
|
||||
jsonReader.endArray();
|
||||
}
|
||||
jsonReader.endArray();
|
||||
} else {
|
||||
jsonReader.beginObject();
|
||||
while (jsonReader.hasNext()) {
|
||||
JsonReaderInternalAccess.INSTANCE.promoteNameToValue(jsonReader);
|
||||
K read2 = this.keyTypeAdapter.read(jsonReader);
|
||||
if (construct.put(read2, this.valueTypeAdapter.read(jsonReader)) != null) {
|
||||
throw new JsonSyntaxException("duplicate key: " + read2);
|
||||
}
|
||||
}
|
||||
jsonReader.endObject();
|
||||
}
|
||||
return construct;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, Map<K, V> map) throws IOException {
|
||||
if (map == null) {
|
||||
jsonWriter.nullValue();
|
||||
return;
|
||||
}
|
||||
if (!MapTypeAdapterFactory.this.complexMapKeySerialization) {
|
||||
jsonWriter.beginObject();
|
||||
for (Map.Entry<K, V> entry : map.entrySet()) {
|
||||
jsonWriter.name(String.valueOf(entry.getKey()));
|
||||
this.valueTypeAdapter.write(jsonWriter, entry.getValue());
|
||||
}
|
||||
jsonWriter.endObject();
|
||||
return;
|
||||
}
|
||||
ArrayList arrayList = new ArrayList(map.size());
|
||||
ArrayList arrayList2 = new ArrayList(map.size());
|
||||
int i = 0;
|
||||
boolean z = false;
|
||||
for (Map.Entry<K, V> entry2 : map.entrySet()) {
|
||||
JsonElement jsonTree = this.keyTypeAdapter.toJsonTree(entry2.getKey());
|
||||
arrayList.add(jsonTree);
|
||||
arrayList2.add(entry2.getValue());
|
||||
z |= jsonTree.isJsonArray() || jsonTree.isJsonObject();
|
||||
}
|
||||
if (!z) {
|
||||
jsonWriter.beginObject();
|
||||
int size = arrayList.size();
|
||||
while (i < size) {
|
||||
jsonWriter.name(keyToString((JsonElement) arrayList.get(i)));
|
||||
this.valueTypeAdapter.write(jsonWriter, arrayList2.get(i));
|
||||
i++;
|
||||
}
|
||||
jsonWriter.endObject();
|
||||
return;
|
||||
}
|
||||
jsonWriter.beginArray();
|
||||
int size2 = arrayList.size();
|
||||
while (i < size2) {
|
||||
jsonWriter.beginArray();
|
||||
Streams.write((JsonElement) arrayList.get(i), jsonWriter);
|
||||
this.valueTypeAdapter.write(jsonWriter, arrayList2.get(i));
|
||||
jsonWriter.endArray();
|
||||
i++;
|
||||
}
|
||||
jsonWriter.endArray();
|
||||
}
|
||||
}
|
||||
|
||||
public MapTypeAdapterFactory(ConstructorConstructor constructorConstructor, boolean z) {
|
||||
this.constructorConstructor = constructorConstructor;
|
||||
this.complexMapKeySerialization = z;
|
||||
}
|
||||
|
||||
private TypeAdapter<?> getKeyAdapter(Gson gson, Type type) {
|
||||
return (type == Boolean.TYPE || type == Boolean.class) ? TypeAdapters.BOOLEAN_AS_STRING : gson.getAdapter(TypeToken.get(type));
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapterFactory
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
|
||||
Type type = typeToken.getType();
|
||||
if (!Map.class.isAssignableFrom(typeToken.getRawType())) {
|
||||
return null;
|
||||
}
|
||||
Type[] mapKeyAndValueTypes = C$Gson$Types.getMapKeyAndValueTypes(type, C$Gson$Types.getRawType(type));
|
||||
return new Adapter(gson, mapKeyAndValueTypes[0], getKeyAdapter(gson, mapKeyAndValueTypes[0]), mapKeyAndValueTypes[1], gson.getAdapter(TypeToken.get(mapKeyAndValueTypes[1])), this.constructorConstructor.get(typeToken));
|
||||
}
|
||||
}
|
110
sources/com/google/gson/internal/bind/ObjectTypeAdapter.java
Normal file
110
sources/com/google/gson/internal/bind/ObjectTypeAdapter.java
Normal file
@@ -0,0 +1,110 @@
|
||||
package com.google.gson.internal.bind;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.internal.LinkedTreeMap;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class ObjectTypeAdapter extends TypeAdapter<Object> {
|
||||
public static final TypeAdapterFactory FACTORY = new TypeAdapterFactory() { // from class: com.google.gson.internal.bind.ObjectTypeAdapter.1
|
||||
@Override // com.google.gson.TypeAdapterFactory
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
|
||||
if (typeToken.getRawType() == Object.class) {
|
||||
return new ObjectTypeAdapter(gson);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
private final Gson gson;
|
||||
|
||||
/* renamed from: com.google.gson.internal.bind.ObjectTypeAdapter$2, reason: invalid class name */
|
||||
static /* synthetic */ class AnonymousClass2 {
|
||||
static final /* synthetic */ int[] $SwitchMap$com$google$gson$stream$JsonToken = new int[JsonToken.values().length];
|
||||
|
||||
static {
|
||||
try {
|
||||
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.BEGIN_ARRAY.ordinal()] = 1;
|
||||
} catch (NoSuchFieldError unused) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.BEGIN_OBJECT.ordinal()] = 2;
|
||||
} catch (NoSuchFieldError unused2) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.STRING.ordinal()] = 3;
|
||||
} catch (NoSuchFieldError unused3) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.NUMBER.ordinal()] = 4;
|
||||
} catch (NoSuchFieldError unused4) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.BOOLEAN.ordinal()] = 5;
|
||||
} catch (NoSuchFieldError unused5) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.NULL.ordinal()] = 6;
|
||||
} catch (NoSuchFieldError unused6) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ObjectTypeAdapter(Gson gson) {
|
||||
this.gson = gson;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public Object read(JsonReader jsonReader) throws IOException {
|
||||
switch (AnonymousClass2.$SwitchMap$com$google$gson$stream$JsonToken[jsonReader.peek().ordinal()]) {
|
||||
case 1:
|
||||
ArrayList arrayList = new ArrayList();
|
||||
jsonReader.beginArray();
|
||||
while (jsonReader.hasNext()) {
|
||||
arrayList.add(read(jsonReader));
|
||||
}
|
||||
jsonReader.endArray();
|
||||
return arrayList;
|
||||
case 2:
|
||||
LinkedTreeMap linkedTreeMap = new LinkedTreeMap();
|
||||
jsonReader.beginObject();
|
||||
while (jsonReader.hasNext()) {
|
||||
linkedTreeMap.put(jsonReader.nextName(), read(jsonReader));
|
||||
}
|
||||
jsonReader.endObject();
|
||||
return linkedTreeMap;
|
||||
case 3:
|
||||
return jsonReader.nextString();
|
||||
case 4:
|
||||
return Double.valueOf(jsonReader.nextDouble());
|
||||
case 5:
|
||||
return Boolean.valueOf(jsonReader.nextBoolean());
|
||||
case 6:
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
default:
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, Object obj) throws IOException {
|
||||
if (obj == null) {
|
||||
jsonWriter.nullValue();
|
||||
return;
|
||||
}
|
||||
TypeAdapter adapter = this.gson.getAdapter(obj.getClass());
|
||||
if (!(adapter instanceof ObjectTypeAdapter)) {
|
||||
adapter.write(jsonWriter, obj);
|
||||
} else {
|
||||
jsonWriter.beginObject();
|
||||
jsonWriter.endObject();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,233 @@
|
||||
package com.google.gson.internal.bind;
|
||||
|
||||
import com.google.gson.FieldNamingStrategy;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.internal.C$Gson$Types;
|
||||
import com.google.gson.internal.ConstructorConstructor;
|
||||
import com.google.gson.internal.Excluder;
|
||||
import com.google.gson.internal.ObjectConstructor;
|
||||
import com.google.gson.internal.Primitives;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class ReflectiveTypeAdapterFactory implements TypeAdapterFactory {
|
||||
private final ConstructorConstructor constructorConstructor;
|
||||
private final Excluder excluder;
|
||||
private final FieldNamingStrategy fieldNamingPolicy;
|
||||
private final JsonAdapterAnnotationTypeAdapterFactory jsonAdapterFactory;
|
||||
|
||||
public static final class Adapter<T> extends TypeAdapter<T> {
|
||||
private final Map<String, BoundField> boundFields;
|
||||
private final ObjectConstructor<T> constructor;
|
||||
|
||||
Adapter(ObjectConstructor<T> objectConstructor, Map<String, BoundField> map) {
|
||||
this.constructor = objectConstructor;
|
||||
this.boundFields = map;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public T read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() == JsonToken.NULL) {
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
T construct = this.constructor.construct();
|
||||
try {
|
||||
jsonReader.beginObject();
|
||||
while (jsonReader.hasNext()) {
|
||||
BoundField boundField = this.boundFields.get(jsonReader.nextName());
|
||||
if (boundField != null && boundField.deserialized) {
|
||||
boundField.read(jsonReader, construct);
|
||||
}
|
||||
jsonReader.skipValue();
|
||||
}
|
||||
jsonReader.endObject();
|
||||
return construct;
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new AssertionError(e);
|
||||
} catch (IllegalStateException e2) {
|
||||
throw new JsonSyntaxException(e2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, T t) throws IOException {
|
||||
if (t == null) {
|
||||
jsonWriter.nullValue();
|
||||
return;
|
||||
}
|
||||
jsonWriter.beginObject();
|
||||
try {
|
||||
for (BoundField boundField : this.boundFields.values()) {
|
||||
if (boundField.writeField(t)) {
|
||||
jsonWriter.name(boundField.name);
|
||||
boundField.write(jsonWriter, t);
|
||||
}
|
||||
}
|
||||
jsonWriter.endObject();
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static abstract class BoundField {
|
||||
final boolean deserialized;
|
||||
final String name;
|
||||
final boolean serialized;
|
||||
|
||||
protected BoundField(String str, boolean z, boolean z2) {
|
||||
this.name = str;
|
||||
this.serialized = z;
|
||||
this.deserialized = z2;
|
||||
}
|
||||
|
||||
abstract void read(JsonReader jsonReader, Object obj) throws IOException, IllegalAccessException;
|
||||
|
||||
abstract void write(JsonWriter jsonWriter, Object obj) throws IOException, IllegalAccessException;
|
||||
|
||||
abstract boolean writeField(Object obj) throws IOException, IllegalAccessException;
|
||||
}
|
||||
|
||||
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor, FieldNamingStrategy fieldNamingStrategy, Excluder excluder, JsonAdapterAnnotationTypeAdapterFactory jsonAdapterAnnotationTypeAdapterFactory) {
|
||||
this.constructorConstructor = constructorConstructor;
|
||||
this.fieldNamingPolicy = fieldNamingStrategy;
|
||||
this.excluder = excluder;
|
||||
this.jsonAdapterFactory = jsonAdapterAnnotationTypeAdapterFactory;
|
||||
}
|
||||
|
||||
private BoundField createBoundField(final Gson gson, final Field field, String str, final TypeToken<?> typeToken, boolean z, boolean z2) {
|
||||
final boolean isPrimitive = Primitives.isPrimitive(typeToken.getRawType());
|
||||
JsonAdapter jsonAdapter = (JsonAdapter) field.getAnnotation(JsonAdapter.class);
|
||||
TypeAdapter<?> typeAdapter = jsonAdapter != null ? this.jsonAdapterFactory.getTypeAdapter(this.constructorConstructor, gson, typeToken, jsonAdapter) : null;
|
||||
final boolean z3 = typeAdapter != null;
|
||||
if (typeAdapter == null) {
|
||||
typeAdapter = gson.getAdapter(typeToken);
|
||||
}
|
||||
final TypeAdapter<?> typeAdapter2 = typeAdapter;
|
||||
return new BoundField(str, z, z2) { // from class: com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.1
|
||||
@Override // com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.BoundField
|
||||
void read(JsonReader jsonReader, Object obj) throws IOException, IllegalAccessException {
|
||||
Object read = typeAdapter2.read(jsonReader);
|
||||
if (read == null && isPrimitive) {
|
||||
return;
|
||||
}
|
||||
field.set(obj, read);
|
||||
}
|
||||
|
||||
@Override // com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.BoundField
|
||||
void write(JsonWriter jsonWriter, Object obj) throws IOException, IllegalAccessException {
|
||||
(z3 ? typeAdapter2 : new TypeAdapterRuntimeTypeWrapper(gson, typeAdapter2, typeToken.getType())).write(jsonWriter, field.get(obj));
|
||||
}
|
||||
|
||||
@Override // com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.BoundField
|
||||
public boolean writeField(Object obj) throws IOException, IllegalAccessException {
|
||||
return this.serialized && field.get(obj) != obj;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private Map<String, BoundField> getBoundFields(Gson gson, TypeToken<?> typeToken, Class<?> cls) {
|
||||
LinkedHashMap linkedHashMap = new LinkedHashMap();
|
||||
if (cls.isInterface()) {
|
||||
return linkedHashMap;
|
||||
}
|
||||
Type type = typeToken.getType();
|
||||
TypeToken<?> typeToken2 = typeToken;
|
||||
Class<?> cls2 = cls;
|
||||
while (cls2 != Object.class) {
|
||||
Field[] declaredFields = cls2.getDeclaredFields();
|
||||
int length = declaredFields.length;
|
||||
boolean z = false;
|
||||
int i = 0;
|
||||
while (i < length) {
|
||||
Field field = declaredFields[i];
|
||||
boolean excludeField = excludeField(field, true);
|
||||
boolean excludeField2 = excludeField(field, z);
|
||||
if (excludeField || excludeField2) {
|
||||
field.setAccessible(true);
|
||||
Type resolve = C$Gson$Types.resolve(typeToken2.getType(), cls2, field.getGenericType());
|
||||
List<String> fieldNames = getFieldNames(field);
|
||||
int size = fieldNames.size();
|
||||
BoundField boundField = null;
|
||||
int i2 = 0;
|
||||
while (i2 < size) {
|
||||
String str = fieldNames.get(i2);
|
||||
boolean z2 = i2 != 0 ? false : excludeField;
|
||||
BoundField boundField2 = boundField;
|
||||
int i3 = i2;
|
||||
int i4 = size;
|
||||
List<String> list = fieldNames;
|
||||
Field field2 = field;
|
||||
boundField = boundField2 == null ? (BoundField) linkedHashMap.put(str, createBoundField(gson, field, str, TypeToken.get(resolve), z2, excludeField2)) : boundField2;
|
||||
i2 = i3 + 1;
|
||||
excludeField = z2;
|
||||
fieldNames = list;
|
||||
size = i4;
|
||||
field = field2;
|
||||
}
|
||||
BoundField boundField3 = boundField;
|
||||
if (boundField3 != null) {
|
||||
throw new IllegalArgumentException(type + " declares multiple JSON fields named " + boundField3.name);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
z = false;
|
||||
}
|
||||
typeToken2 = TypeToken.get(C$Gson$Types.resolve(typeToken2.getType(), cls2, cls2.getGenericSuperclass()));
|
||||
cls2 = typeToken2.getRawType();
|
||||
}
|
||||
return linkedHashMap;
|
||||
}
|
||||
|
||||
private List<String> getFieldNames(Field field) {
|
||||
SerializedName serializedName = (SerializedName) field.getAnnotation(SerializedName.class);
|
||||
if (serializedName == null) {
|
||||
return Collections.singletonList(this.fieldNamingPolicy.translateName(field));
|
||||
}
|
||||
String value = serializedName.value();
|
||||
String[] alternate = serializedName.alternate();
|
||||
if (alternate.length == 0) {
|
||||
return Collections.singletonList(value);
|
||||
}
|
||||
ArrayList arrayList = new ArrayList(alternate.length + 1);
|
||||
arrayList.add(value);
|
||||
for (String str : alternate) {
|
||||
arrayList.add(str);
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapterFactory
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
|
||||
Class<? super T> rawType = typeToken.getRawType();
|
||||
if (Object.class.isAssignableFrom(rawType)) {
|
||||
return new Adapter(this.constructorConstructor.get(typeToken), getBoundFields(gson, typeToken, rawType));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean excludeField(Field field, boolean z) {
|
||||
return excludeField(field, z, this.excluder);
|
||||
}
|
||||
|
||||
static boolean excludeField(Field field, boolean z, Excluder excluder) {
|
||||
return (excluder.excludeClass(field.getType(), z) || excluder.excludeField(field, z)) ? false : true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
package com.google.gson.internal.bind;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.sql.Date;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class SqlDateTypeAdapter extends TypeAdapter<Date> {
|
||||
public static final TypeAdapterFactory FACTORY = new TypeAdapterFactory() { // from class: com.google.gson.internal.bind.SqlDateTypeAdapter.1
|
||||
@Override // com.google.gson.TypeAdapterFactory
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
|
||||
if (typeToken.getRawType() == Date.class) {
|
||||
return new SqlDateTypeAdapter();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
private final DateFormat format = new SimpleDateFormat("MMM d, yyyy");
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public synchronized Date read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() == JsonToken.NULL) {
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return new Date(this.format.parse(jsonReader.nextString()).getTime());
|
||||
} catch (ParseException e) {
|
||||
throw new JsonSyntaxException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public synchronized void write(JsonWriter jsonWriter, Date date) throws IOException {
|
||||
jsonWriter.value(date == null ? null : this.format.format((java.util.Date) date));
|
||||
}
|
||||
}
|
48
sources/com/google/gson/internal/bind/TimeTypeAdapter.java
Normal file
48
sources/com/google/gson/internal/bind/TimeTypeAdapter.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package com.google.gson.internal.bind;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.sql.Time;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class TimeTypeAdapter extends TypeAdapter<Time> {
|
||||
public static final TypeAdapterFactory FACTORY = new TypeAdapterFactory() { // from class: com.google.gson.internal.bind.TimeTypeAdapter.1
|
||||
@Override // com.google.gson.TypeAdapterFactory
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
|
||||
if (typeToken.getRawType() == Time.class) {
|
||||
return new TimeTypeAdapter();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
private final DateFormat format = new SimpleDateFormat("hh:mm:ss a");
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public synchronized Time read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() == JsonToken.NULL) {
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return new Time(this.format.parse(jsonReader.nextString()).getTime());
|
||||
} catch (ParseException e) {
|
||||
throw new JsonSyntaxException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public synchronized void write(JsonWriter jsonWriter, Time time) throws IOException {
|
||||
jsonWriter.value(time == null ? null : this.format.format((Date) time));
|
||||
}
|
||||
}
|
129
sources/com/google/gson/internal/bind/TreeTypeAdapter.java
Normal file
129
sources/com/google/gson/internal/bind/TreeTypeAdapter.java
Normal file
@@ -0,0 +1,129 @@
|
||||
package com.google.gson.internal.bind;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.internal.C$Gson$Preconditions;
|
||||
import com.google.gson.internal.Streams;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class TreeTypeAdapter<T> extends TypeAdapter<T> {
|
||||
private final TreeTypeAdapter<T>.GsonContextImpl context = new GsonContextImpl();
|
||||
private TypeAdapter<T> delegate;
|
||||
private final JsonDeserializer<T> deserializer;
|
||||
final Gson gson;
|
||||
private final JsonSerializer<T> serializer;
|
||||
private final TypeAdapterFactory skipPast;
|
||||
private final TypeToken<T> typeToken;
|
||||
|
||||
private final class GsonContextImpl implements JsonSerializationContext, JsonDeserializationContext {
|
||||
private GsonContextImpl() {
|
||||
}
|
||||
|
||||
@Override // com.google.gson.JsonDeserializationContext
|
||||
public <R> R deserialize(JsonElement jsonElement, Type type) throws JsonParseException {
|
||||
return (R) TreeTypeAdapter.this.gson.fromJson(jsonElement, type);
|
||||
}
|
||||
|
||||
@Override // com.google.gson.JsonSerializationContext
|
||||
public JsonElement serialize(Object obj) {
|
||||
return TreeTypeAdapter.this.gson.toJsonTree(obj);
|
||||
}
|
||||
|
||||
@Override // com.google.gson.JsonSerializationContext
|
||||
public JsonElement serialize(Object obj, Type type) {
|
||||
return TreeTypeAdapter.this.gson.toJsonTree(obj, type);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class SingleTypeFactory implements TypeAdapterFactory {
|
||||
private final JsonDeserializer<?> deserializer;
|
||||
private final TypeToken<?> exactType;
|
||||
private final Class<?> hierarchyType;
|
||||
private final boolean matchRawType;
|
||||
private final JsonSerializer<?> serializer;
|
||||
|
||||
SingleTypeFactory(Object obj, TypeToken<?> typeToken, boolean z, Class<?> cls) {
|
||||
this.serializer = obj instanceof JsonSerializer ? (JsonSerializer) obj : null;
|
||||
this.deserializer = obj instanceof JsonDeserializer ? (JsonDeserializer) obj : null;
|
||||
C$Gson$Preconditions.checkArgument((this.serializer == null && this.deserializer == null) ? false : true);
|
||||
this.exactType = typeToken;
|
||||
this.matchRawType = z;
|
||||
this.hierarchyType = cls;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapterFactory
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
|
||||
TypeToken<?> typeToken2 = this.exactType;
|
||||
if (typeToken2 != null ? typeToken2.equals(typeToken) || (this.matchRawType && this.exactType.getType() == typeToken.getRawType()) : this.hierarchyType.isAssignableFrom(typeToken.getRawType())) {
|
||||
return new TreeTypeAdapter(this.serializer, this.deserializer, gson, typeToken, this);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public TreeTypeAdapter(JsonSerializer<T> jsonSerializer, JsonDeserializer<T> jsonDeserializer, Gson gson, TypeToken<T> typeToken, TypeAdapterFactory typeAdapterFactory) {
|
||||
this.serializer = jsonSerializer;
|
||||
this.deserializer = jsonDeserializer;
|
||||
this.gson = gson;
|
||||
this.typeToken = typeToken;
|
||||
this.skipPast = typeAdapterFactory;
|
||||
}
|
||||
|
||||
private TypeAdapter<T> delegate() {
|
||||
TypeAdapter<T> typeAdapter = this.delegate;
|
||||
if (typeAdapter != null) {
|
||||
return typeAdapter;
|
||||
}
|
||||
TypeAdapter<T> delegateAdapter = this.gson.getDelegateAdapter(this.skipPast, this.typeToken);
|
||||
this.delegate = delegateAdapter;
|
||||
return delegateAdapter;
|
||||
}
|
||||
|
||||
public static TypeAdapterFactory newFactory(TypeToken<?> typeToken, Object obj) {
|
||||
return new SingleTypeFactory(obj, typeToken, false, null);
|
||||
}
|
||||
|
||||
public static TypeAdapterFactory newFactoryWithMatchRawType(TypeToken<?> typeToken, Object obj) {
|
||||
return new SingleTypeFactory(obj, typeToken, typeToken.getType() == typeToken.getRawType(), null);
|
||||
}
|
||||
|
||||
public static TypeAdapterFactory newTypeHierarchyFactory(Class<?> cls, Object obj) {
|
||||
return new SingleTypeFactory(obj, null, false, cls);
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public T read(JsonReader jsonReader) throws IOException {
|
||||
if (this.deserializer == null) {
|
||||
return delegate().read(jsonReader);
|
||||
}
|
||||
JsonElement parse = Streams.parse(jsonReader);
|
||||
if (parse.isJsonNull()) {
|
||||
return null;
|
||||
}
|
||||
return this.deserializer.deserialize(parse, this.typeToken.getType(), this.context);
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, T t) throws IOException {
|
||||
JsonSerializer<T> jsonSerializer = this.serializer;
|
||||
if (jsonSerializer == null) {
|
||||
delegate().write(jsonWriter, t);
|
||||
} else if (t == null) {
|
||||
jsonWriter.nullValue();
|
||||
} else {
|
||||
Streams.write(jsonSerializer.serialize(t, this.typeToken.getType(), this.context), jsonWriter);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
package com.google.gson.internal.bind;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.internal.bind.ReflectiveTypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.lang.reflect.TypeVariable;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class TypeAdapterRuntimeTypeWrapper<T> extends TypeAdapter<T> {
|
||||
private final Gson context;
|
||||
private final TypeAdapter<T> delegate;
|
||||
private final Type type;
|
||||
|
||||
TypeAdapterRuntimeTypeWrapper(Gson gson, TypeAdapter<T> typeAdapter, Type type) {
|
||||
this.context = gson;
|
||||
this.delegate = typeAdapter;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
private Type getRuntimeTypeIfMoreSpecific(Type type, Object obj) {
|
||||
return obj != null ? (type == Object.class || (type instanceof TypeVariable) || (type instanceof Class)) ? obj.getClass() : type : type;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public T read(JsonReader jsonReader) throws IOException {
|
||||
return this.delegate.read(jsonReader);
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, T t) throws IOException {
|
||||
TypeAdapter<T> typeAdapter = this.delegate;
|
||||
Type runtimeTypeIfMoreSpecific = getRuntimeTypeIfMoreSpecific(this.type, t);
|
||||
if (runtimeTypeIfMoreSpecific != this.type) {
|
||||
typeAdapter = this.context.getAdapter(TypeToken.get(runtimeTypeIfMoreSpecific));
|
||||
if (typeAdapter instanceof ReflectiveTypeAdapterFactory.Adapter) {
|
||||
TypeAdapter<T> typeAdapter2 = this.delegate;
|
||||
if (!(typeAdapter2 instanceof ReflectiveTypeAdapterFactory.Adapter)) {
|
||||
typeAdapter = typeAdapter2;
|
||||
}
|
||||
}
|
||||
}
|
||||
typeAdapter.write(jsonWriter, t);
|
||||
}
|
||||
}
|
961
sources/com/google/gson/internal/bind/TypeAdapters.java
Normal file
961
sources/com/google/gson/internal/bind/TypeAdapters.java
Normal file
@@ -0,0 +1,961 @@
|
||||
package com.google.gson.internal.bind;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonIOException;
|
||||
import com.google.gson.JsonNull;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.internal.LazilyParsedNumber;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.net.InetAddress;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
import java.util.Calendar;
|
||||
import java.util.Currency;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicIntegerArray;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class TypeAdapters {
|
||||
public static final TypeAdapter<Class> CLASS = new TypeAdapter<Class>() { // from class: com.google.gson.internal.bind.TypeAdapters.1
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public Class read(JsonReader jsonReader) throws IOException {
|
||||
throw new UnsupportedOperationException("Attempted to deserialize a java.lang.Class. Forgot to register a type adapter?");
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, Class cls) throws IOException {
|
||||
throw new UnsupportedOperationException("Attempted to serialize java.lang.Class: " + cls.getName() + ". Forgot to register a type adapter?");
|
||||
}
|
||||
}.nullSafe();
|
||||
public static final TypeAdapterFactory CLASS_FACTORY = newFactory(Class.class, CLASS);
|
||||
public static final TypeAdapter<BitSet> BIT_SET = new TypeAdapter<BitSet>() { // from class: com.google.gson.internal.bind.TypeAdapters.2
|
||||
/* JADX WARN: Code restructure failed: missing block: B:13:0x002b, code lost:
|
||||
|
||||
if (java.lang.Integer.parseInt(r1) != 0) goto L23;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:14:0x002e, code lost:
|
||||
|
||||
r5 = false;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:29:0x0067, code lost:
|
||||
|
||||
if (r8.nextInt() != 0) goto L23;
|
||||
*/
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public java.util.BitSet read(com.google.gson.stream.JsonReader r8) throws java.io.IOException {
|
||||
/*
|
||||
r7 = this;
|
||||
java.util.BitSet r0 = new java.util.BitSet
|
||||
r0.<init>()
|
||||
r8.beginArray()
|
||||
com.google.gson.stream.JsonToken r1 = r8.peek()
|
||||
r2 = 0
|
||||
r3 = 0
|
||||
Le:
|
||||
com.google.gson.stream.JsonToken r4 = com.google.gson.stream.JsonToken.END_ARRAY
|
||||
if (r1 == r4) goto L75
|
||||
int[] r4 = com.google.gson.internal.bind.TypeAdapters.AnonymousClass36.$SwitchMap$com$google$gson$stream$JsonToken
|
||||
int r5 = r1.ordinal()
|
||||
r4 = r4[r5]
|
||||
r5 = 1
|
||||
if (r4 == r5) goto L63
|
||||
r6 = 2
|
||||
if (r4 == r6) goto L5e
|
||||
r6 = 3
|
||||
if (r4 != r6) goto L47
|
||||
java.lang.String r1 = r8.nextString()
|
||||
int r1 = java.lang.Integer.parseInt(r1) // Catch: java.lang.NumberFormatException -> L30
|
||||
if (r1 == 0) goto L2e
|
||||
goto L69
|
||||
L2e:
|
||||
r5 = 0
|
||||
goto L69
|
||||
L30:
|
||||
com.google.gson.JsonSyntaxException r8 = new com.google.gson.JsonSyntaxException
|
||||
java.lang.StringBuilder r0 = new java.lang.StringBuilder
|
||||
r0.<init>()
|
||||
java.lang.String r2 = "Error: Expecting: bitset number value (1, 0), Found: "
|
||||
r0.append(r2)
|
||||
r0.append(r1)
|
||||
java.lang.String r0 = r0.toString()
|
||||
r8.<init>(r0)
|
||||
throw r8
|
||||
L47:
|
||||
com.google.gson.JsonSyntaxException r8 = new com.google.gson.JsonSyntaxException
|
||||
java.lang.StringBuilder r0 = new java.lang.StringBuilder
|
||||
r0.<init>()
|
||||
java.lang.String r2 = "Invalid bitset value type: "
|
||||
r0.append(r2)
|
||||
r0.append(r1)
|
||||
java.lang.String r0 = r0.toString()
|
||||
r8.<init>(r0)
|
||||
throw r8
|
||||
L5e:
|
||||
boolean r5 = r8.nextBoolean()
|
||||
goto L69
|
||||
L63:
|
||||
int r1 = r8.nextInt()
|
||||
if (r1 == 0) goto L2e
|
||||
L69:
|
||||
if (r5 == 0) goto L6e
|
||||
r0.set(r3)
|
||||
L6e:
|
||||
int r3 = r3 + 1
|
||||
com.google.gson.stream.JsonToken r1 = r8.peek()
|
||||
goto Le
|
||||
L75:
|
||||
r8.endArray()
|
||||
return r0
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.google.gson.internal.bind.TypeAdapters.AnonymousClass2.read(com.google.gson.stream.JsonReader):java.util.BitSet");
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, BitSet bitSet) throws IOException {
|
||||
jsonWriter.beginArray();
|
||||
int length = bitSet.length();
|
||||
for (int i = 0; i < length; i++) {
|
||||
jsonWriter.value(bitSet.get(i) ? 1L : 0L);
|
||||
}
|
||||
jsonWriter.endArray();
|
||||
}
|
||||
}.nullSafe();
|
||||
public static final TypeAdapterFactory BIT_SET_FACTORY = newFactory(BitSet.class, BIT_SET);
|
||||
public static final TypeAdapter<Boolean> BOOLEAN = new TypeAdapter<Boolean>() { // from class: com.google.gson.internal.bind.TypeAdapters.3
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public Boolean read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() != JsonToken.NULL) {
|
||||
return jsonReader.peek() == JsonToken.STRING ? Boolean.valueOf(Boolean.parseBoolean(jsonReader.nextString())) : Boolean.valueOf(jsonReader.nextBoolean());
|
||||
}
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, Boolean bool) throws IOException {
|
||||
jsonWriter.value(bool);
|
||||
}
|
||||
};
|
||||
public static final TypeAdapter<Boolean> BOOLEAN_AS_STRING = new TypeAdapter<Boolean>() { // from class: com.google.gson.internal.bind.TypeAdapters.4
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public Boolean read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() != JsonToken.NULL) {
|
||||
return Boolean.valueOf(jsonReader.nextString());
|
||||
}
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, Boolean bool) throws IOException {
|
||||
jsonWriter.value(bool == null ? "null" : bool.toString());
|
||||
}
|
||||
};
|
||||
public static final TypeAdapterFactory BOOLEAN_FACTORY = newFactory(Boolean.TYPE, Boolean.class, BOOLEAN);
|
||||
public static final TypeAdapter<Number> BYTE = new TypeAdapter<Number>() { // from class: com.google.gson.internal.bind.TypeAdapters.5
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public Number read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() == JsonToken.NULL) {
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return Byte.valueOf((byte) jsonReader.nextInt());
|
||||
} catch (NumberFormatException e) {
|
||||
throw new JsonSyntaxException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, Number number) throws IOException {
|
||||
jsonWriter.value(number);
|
||||
}
|
||||
};
|
||||
public static final TypeAdapterFactory BYTE_FACTORY = newFactory(Byte.TYPE, Byte.class, BYTE);
|
||||
public static final TypeAdapter<Number> SHORT = new TypeAdapter<Number>() { // from class: com.google.gson.internal.bind.TypeAdapters.6
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public Number read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() == JsonToken.NULL) {
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return Short.valueOf((short) jsonReader.nextInt());
|
||||
} catch (NumberFormatException e) {
|
||||
throw new JsonSyntaxException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, Number number) throws IOException {
|
||||
jsonWriter.value(number);
|
||||
}
|
||||
};
|
||||
public static final TypeAdapterFactory SHORT_FACTORY = newFactory(Short.TYPE, Short.class, SHORT);
|
||||
public static final TypeAdapter<Number> INTEGER = new TypeAdapter<Number>() { // from class: com.google.gson.internal.bind.TypeAdapters.7
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public Number read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() == JsonToken.NULL) {
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return Integer.valueOf(jsonReader.nextInt());
|
||||
} catch (NumberFormatException e) {
|
||||
throw new JsonSyntaxException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, Number number) throws IOException {
|
||||
jsonWriter.value(number);
|
||||
}
|
||||
};
|
||||
public static final TypeAdapterFactory INTEGER_FACTORY = newFactory(Integer.TYPE, Integer.class, INTEGER);
|
||||
public static final TypeAdapter<AtomicInteger> ATOMIC_INTEGER = new TypeAdapter<AtomicInteger>() { // from class: com.google.gson.internal.bind.TypeAdapters.8
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public AtomicInteger read(JsonReader jsonReader) throws IOException {
|
||||
try {
|
||||
return new AtomicInteger(jsonReader.nextInt());
|
||||
} catch (NumberFormatException e) {
|
||||
throw new JsonSyntaxException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, AtomicInteger atomicInteger) throws IOException {
|
||||
jsonWriter.value(atomicInteger.get());
|
||||
}
|
||||
}.nullSafe();
|
||||
public static final TypeAdapterFactory ATOMIC_INTEGER_FACTORY = newFactory(AtomicInteger.class, ATOMIC_INTEGER);
|
||||
public static final TypeAdapter<AtomicBoolean> ATOMIC_BOOLEAN = new TypeAdapter<AtomicBoolean>() { // from class: com.google.gson.internal.bind.TypeAdapters.9
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public AtomicBoolean read(JsonReader jsonReader) throws IOException {
|
||||
return new AtomicBoolean(jsonReader.nextBoolean());
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, AtomicBoolean atomicBoolean) throws IOException {
|
||||
jsonWriter.value(atomicBoolean.get());
|
||||
}
|
||||
}.nullSafe();
|
||||
public static final TypeAdapterFactory ATOMIC_BOOLEAN_FACTORY = newFactory(AtomicBoolean.class, ATOMIC_BOOLEAN);
|
||||
public static final TypeAdapter<AtomicIntegerArray> ATOMIC_INTEGER_ARRAY = new TypeAdapter<AtomicIntegerArray>() { // from class: com.google.gson.internal.bind.TypeAdapters.10
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public AtomicIntegerArray read(JsonReader jsonReader) throws IOException {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
jsonReader.beginArray();
|
||||
while (jsonReader.hasNext()) {
|
||||
try {
|
||||
arrayList.add(Integer.valueOf(jsonReader.nextInt()));
|
||||
} catch (NumberFormatException e) {
|
||||
throw new JsonSyntaxException(e);
|
||||
}
|
||||
}
|
||||
jsonReader.endArray();
|
||||
int size = arrayList.size();
|
||||
AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
atomicIntegerArray.set(i, ((Integer) arrayList.get(i)).intValue());
|
||||
}
|
||||
return atomicIntegerArray;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, AtomicIntegerArray atomicIntegerArray) throws IOException {
|
||||
jsonWriter.beginArray();
|
||||
int length = atomicIntegerArray.length();
|
||||
for (int i = 0; i < length; i++) {
|
||||
jsonWriter.value(atomicIntegerArray.get(i));
|
||||
}
|
||||
jsonWriter.endArray();
|
||||
}
|
||||
}.nullSafe();
|
||||
public static final TypeAdapterFactory ATOMIC_INTEGER_ARRAY_FACTORY = newFactory(AtomicIntegerArray.class, ATOMIC_INTEGER_ARRAY);
|
||||
public static final TypeAdapter<Number> LONG = new TypeAdapter<Number>() { // from class: com.google.gson.internal.bind.TypeAdapters.11
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public Number read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() == JsonToken.NULL) {
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return Long.valueOf(jsonReader.nextLong());
|
||||
} catch (NumberFormatException e) {
|
||||
throw new JsonSyntaxException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, Number number) throws IOException {
|
||||
jsonWriter.value(number);
|
||||
}
|
||||
};
|
||||
public static final TypeAdapter<Number> FLOAT = new TypeAdapter<Number>() { // from class: com.google.gson.internal.bind.TypeAdapters.12
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public Number read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() != JsonToken.NULL) {
|
||||
return Float.valueOf((float) jsonReader.nextDouble());
|
||||
}
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, Number number) throws IOException {
|
||||
jsonWriter.value(number);
|
||||
}
|
||||
};
|
||||
public static final TypeAdapter<Number> DOUBLE = new TypeAdapter<Number>() { // from class: com.google.gson.internal.bind.TypeAdapters.13
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public Number read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() != JsonToken.NULL) {
|
||||
return Double.valueOf(jsonReader.nextDouble());
|
||||
}
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, Number number) throws IOException {
|
||||
jsonWriter.value(number);
|
||||
}
|
||||
};
|
||||
public static final TypeAdapter<Number> NUMBER = new TypeAdapter<Number>() { // from class: com.google.gson.internal.bind.TypeAdapters.14
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public Number read(JsonReader jsonReader) throws IOException {
|
||||
JsonToken peek = jsonReader.peek();
|
||||
int i = AnonymousClass36.$SwitchMap$com$google$gson$stream$JsonToken[peek.ordinal()];
|
||||
if (i == 1 || i == 3) {
|
||||
return new LazilyParsedNumber(jsonReader.nextString());
|
||||
}
|
||||
if (i == 4) {
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
throw new JsonSyntaxException("Expecting number, got: " + peek);
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, Number number) throws IOException {
|
||||
jsonWriter.value(number);
|
||||
}
|
||||
};
|
||||
public static final TypeAdapterFactory NUMBER_FACTORY = newFactory(Number.class, NUMBER);
|
||||
public static final TypeAdapter<Character> CHARACTER = new TypeAdapter<Character>() { // from class: com.google.gson.internal.bind.TypeAdapters.15
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public Character read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() == JsonToken.NULL) {
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
String nextString = jsonReader.nextString();
|
||||
if (nextString.length() == 1) {
|
||||
return Character.valueOf(nextString.charAt(0));
|
||||
}
|
||||
throw new JsonSyntaxException("Expecting character, got: " + nextString);
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, Character ch) throws IOException {
|
||||
jsonWriter.value(ch == null ? null : String.valueOf(ch));
|
||||
}
|
||||
};
|
||||
public static final TypeAdapterFactory CHARACTER_FACTORY = newFactory(Character.TYPE, Character.class, CHARACTER);
|
||||
public static final TypeAdapter<String> STRING = new TypeAdapter<String>() { // from class: com.google.gson.internal.bind.TypeAdapters.16
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public String read(JsonReader jsonReader) throws IOException {
|
||||
JsonToken peek = jsonReader.peek();
|
||||
if (peek != JsonToken.NULL) {
|
||||
return peek == JsonToken.BOOLEAN ? Boolean.toString(jsonReader.nextBoolean()) : jsonReader.nextString();
|
||||
}
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, String str) throws IOException {
|
||||
jsonWriter.value(str);
|
||||
}
|
||||
};
|
||||
public static final TypeAdapter<BigDecimal> BIG_DECIMAL = new TypeAdapter<BigDecimal>() { // from class: com.google.gson.internal.bind.TypeAdapters.17
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public BigDecimal read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() == JsonToken.NULL) {
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return new BigDecimal(jsonReader.nextString());
|
||||
} catch (NumberFormatException e) {
|
||||
throw new JsonSyntaxException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, BigDecimal bigDecimal) throws IOException {
|
||||
jsonWriter.value(bigDecimal);
|
||||
}
|
||||
};
|
||||
public static final TypeAdapter<BigInteger> BIG_INTEGER = new TypeAdapter<BigInteger>() { // from class: com.google.gson.internal.bind.TypeAdapters.18
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public BigInteger read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() == JsonToken.NULL) {
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return new BigInteger(jsonReader.nextString());
|
||||
} catch (NumberFormatException e) {
|
||||
throw new JsonSyntaxException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, BigInteger bigInteger) throws IOException {
|
||||
jsonWriter.value(bigInteger);
|
||||
}
|
||||
};
|
||||
public static final TypeAdapterFactory STRING_FACTORY = newFactory(String.class, STRING);
|
||||
public static final TypeAdapter<StringBuilder> STRING_BUILDER = new TypeAdapter<StringBuilder>() { // from class: com.google.gson.internal.bind.TypeAdapters.19
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public StringBuilder read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() != JsonToken.NULL) {
|
||||
return new StringBuilder(jsonReader.nextString());
|
||||
}
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, StringBuilder sb) throws IOException {
|
||||
jsonWriter.value(sb == null ? null : sb.toString());
|
||||
}
|
||||
};
|
||||
public static final TypeAdapterFactory STRING_BUILDER_FACTORY = newFactory(StringBuilder.class, STRING_BUILDER);
|
||||
public static final TypeAdapter<StringBuffer> STRING_BUFFER = new TypeAdapter<StringBuffer>() { // from class: com.google.gson.internal.bind.TypeAdapters.20
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public StringBuffer read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() != JsonToken.NULL) {
|
||||
return new StringBuffer(jsonReader.nextString());
|
||||
}
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, StringBuffer stringBuffer) throws IOException {
|
||||
jsonWriter.value(stringBuffer == null ? null : stringBuffer.toString());
|
||||
}
|
||||
};
|
||||
public static final TypeAdapterFactory STRING_BUFFER_FACTORY = newFactory(StringBuffer.class, STRING_BUFFER);
|
||||
public static final TypeAdapter<URL> URL = new TypeAdapter<URL>() { // from class: com.google.gson.internal.bind.TypeAdapters.21
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public URL read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() == JsonToken.NULL) {
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
String nextString = jsonReader.nextString();
|
||||
if ("null".equals(nextString)) {
|
||||
return null;
|
||||
}
|
||||
return new URL(nextString);
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, URL url) throws IOException {
|
||||
jsonWriter.value(url == null ? null : url.toExternalForm());
|
||||
}
|
||||
};
|
||||
public static final TypeAdapterFactory URL_FACTORY = newFactory(URL.class, URL);
|
||||
public static final TypeAdapter<URI> URI = new TypeAdapter<URI>() { // from class: com.google.gson.internal.bind.TypeAdapters.22
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public URI read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() == JsonToken.NULL) {
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
String nextString = jsonReader.nextString();
|
||||
if ("null".equals(nextString)) {
|
||||
return null;
|
||||
}
|
||||
return new URI(nextString);
|
||||
} catch (URISyntaxException e) {
|
||||
throw new JsonIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, URI uri) throws IOException {
|
||||
jsonWriter.value(uri == null ? null : uri.toASCIIString());
|
||||
}
|
||||
};
|
||||
public static final TypeAdapterFactory URI_FACTORY = newFactory(URI.class, URI);
|
||||
public static final TypeAdapter<InetAddress> INET_ADDRESS = new TypeAdapter<InetAddress>() { // from class: com.google.gson.internal.bind.TypeAdapters.23
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public InetAddress read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() != JsonToken.NULL) {
|
||||
return InetAddress.getByName(jsonReader.nextString());
|
||||
}
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, InetAddress inetAddress) throws IOException {
|
||||
jsonWriter.value(inetAddress == null ? null : inetAddress.getHostAddress());
|
||||
}
|
||||
};
|
||||
public static final TypeAdapterFactory INET_ADDRESS_FACTORY = newTypeHierarchyFactory(InetAddress.class, INET_ADDRESS);
|
||||
public static final TypeAdapter<UUID> UUID = new TypeAdapter<UUID>() { // from class: com.google.gson.internal.bind.TypeAdapters.24
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public UUID read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() != JsonToken.NULL) {
|
||||
return UUID.fromString(jsonReader.nextString());
|
||||
}
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, UUID uuid) throws IOException {
|
||||
jsonWriter.value(uuid == null ? null : uuid.toString());
|
||||
}
|
||||
};
|
||||
public static final TypeAdapterFactory UUID_FACTORY = newFactory(UUID.class, UUID);
|
||||
public static final TypeAdapter<Currency> CURRENCY = new TypeAdapter<Currency>() { // from class: com.google.gson.internal.bind.TypeAdapters.25
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public Currency read(JsonReader jsonReader) throws IOException {
|
||||
return Currency.getInstance(jsonReader.nextString());
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, Currency currency) throws IOException {
|
||||
jsonWriter.value(currency.getCurrencyCode());
|
||||
}
|
||||
}.nullSafe();
|
||||
public static final TypeAdapterFactory CURRENCY_FACTORY = newFactory(Currency.class, CURRENCY);
|
||||
public static final TypeAdapterFactory TIMESTAMP_FACTORY = new TypeAdapterFactory() { // from class: com.google.gson.internal.bind.TypeAdapters.26
|
||||
@Override // com.google.gson.TypeAdapterFactory
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
|
||||
if (typeToken.getRawType() != Timestamp.class) {
|
||||
return null;
|
||||
}
|
||||
final TypeAdapter<T> adapter = gson.getAdapter(Date.class);
|
||||
return (TypeAdapter<T>) new TypeAdapter<Timestamp>() { // from class: com.google.gson.internal.bind.TypeAdapters.26.1
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public Timestamp read(JsonReader jsonReader) throws IOException {
|
||||
Date date = (Date) adapter.read(jsonReader);
|
||||
if (date != null) {
|
||||
return new Timestamp(date.getTime());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, Timestamp timestamp) throws IOException {
|
||||
adapter.write(jsonWriter, timestamp);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
public static final TypeAdapter<Calendar> CALENDAR = new TypeAdapter<Calendar>() { // from class: com.google.gson.internal.bind.TypeAdapters.27
|
||||
private static final String DAY_OF_MONTH = "dayOfMonth";
|
||||
private static final String HOUR_OF_DAY = "hourOfDay";
|
||||
private static final String MINUTE = "minute";
|
||||
private static final String MONTH = "month";
|
||||
private static final String SECOND = "second";
|
||||
private static final String YEAR = "year";
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public Calendar read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() == JsonToken.NULL) {
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
jsonReader.beginObject();
|
||||
int i = 0;
|
||||
int i2 = 0;
|
||||
int i3 = 0;
|
||||
int i4 = 0;
|
||||
int i5 = 0;
|
||||
int i6 = 0;
|
||||
while (jsonReader.peek() != JsonToken.END_OBJECT) {
|
||||
String nextName = jsonReader.nextName();
|
||||
int nextInt = jsonReader.nextInt();
|
||||
if (YEAR.equals(nextName)) {
|
||||
i = nextInt;
|
||||
} else if (MONTH.equals(nextName)) {
|
||||
i2 = nextInt;
|
||||
} else if (DAY_OF_MONTH.equals(nextName)) {
|
||||
i3 = nextInt;
|
||||
} else if (HOUR_OF_DAY.equals(nextName)) {
|
||||
i4 = nextInt;
|
||||
} else if (MINUTE.equals(nextName)) {
|
||||
i5 = nextInt;
|
||||
} else if (SECOND.equals(nextName)) {
|
||||
i6 = nextInt;
|
||||
}
|
||||
}
|
||||
jsonReader.endObject();
|
||||
return new GregorianCalendar(i, i2, i3, i4, i5, i6);
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, Calendar calendar) throws IOException {
|
||||
if (calendar == null) {
|
||||
jsonWriter.nullValue();
|
||||
return;
|
||||
}
|
||||
jsonWriter.beginObject();
|
||||
jsonWriter.name(YEAR);
|
||||
jsonWriter.value(calendar.get(1));
|
||||
jsonWriter.name(MONTH);
|
||||
jsonWriter.value(calendar.get(2));
|
||||
jsonWriter.name(DAY_OF_MONTH);
|
||||
jsonWriter.value(calendar.get(5));
|
||||
jsonWriter.name(HOUR_OF_DAY);
|
||||
jsonWriter.value(calendar.get(11));
|
||||
jsonWriter.name(MINUTE);
|
||||
jsonWriter.value(calendar.get(12));
|
||||
jsonWriter.name(SECOND);
|
||||
jsonWriter.value(calendar.get(13));
|
||||
jsonWriter.endObject();
|
||||
}
|
||||
};
|
||||
public static final TypeAdapterFactory CALENDAR_FACTORY = newFactoryForMultipleTypes(Calendar.class, GregorianCalendar.class, CALENDAR);
|
||||
public static final TypeAdapter<Locale> LOCALE = new TypeAdapter<Locale>() { // from class: com.google.gson.internal.bind.TypeAdapters.28
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public Locale read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() == JsonToken.NULL) {
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
StringTokenizer stringTokenizer = new StringTokenizer(jsonReader.nextString(), "_");
|
||||
String nextToken = stringTokenizer.hasMoreElements() ? stringTokenizer.nextToken() : null;
|
||||
String nextToken2 = stringTokenizer.hasMoreElements() ? stringTokenizer.nextToken() : null;
|
||||
String nextToken3 = stringTokenizer.hasMoreElements() ? stringTokenizer.nextToken() : null;
|
||||
return (nextToken2 == null && nextToken3 == null) ? new Locale(nextToken) : nextToken3 == null ? new Locale(nextToken, nextToken2) : new Locale(nextToken, nextToken2, nextToken3);
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, Locale locale) throws IOException {
|
||||
jsonWriter.value(locale == null ? null : locale.toString());
|
||||
}
|
||||
};
|
||||
public static final TypeAdapterFactory LOCALE_FACTORY = newFactory(Locale.class, LOCALE);
|
||||
public static final TypeAdapter<JsonElement> JSON_ELEMENT = new TypeAdapter<JsonElement>() { // from class: com.google.gson.internal.bind.TypeAdapters.29
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public JsonElement read(JsonReader jsonReader) throws IOException {
|
||||
switch (AnonymousClass36.$SwitchMap$com$google$gson$stream$JsonToken[jsonReader.peek().ordinal()]) {
|
||||
case 1:
|
||||
return new JsonPrimitive((Number) new LazilyParsedNumber(jsonReader.nextString()));
|
||||
case 2:
|
||||
return new JsonPrimitive(Boolean.valueOf(jsonReader.nextBoolean()));
|
||||
case 3:
|
||||
return new JsonPrimitive(jsonReader.nextString());
|
||||
case 4:
|
||||
jsonReader.nextNull();
|
||||
return JsonNull.INSTANCE;
|
||||
case 5:
|
||||
JsonArray jsonArray = new JsonArray();
|
||||
jsonReader.beginArray();
|
||||
while (jsonReader.hasNext()) {
|
||||
jsonArray.add(read(jsonReader));
|
||||
}
|
||||
jsonReader.endArray();
|
||||
return jsonArray;
|
||||
case 6:
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonReader.beginObject();
|
||||
while (jsonReader.hasNext()) {
|
||||
jsonObject.add(jsonReader.nextName(), read(jsonReader));
|
||||
}
|
||||
jsonReader.endObject();
|
||||
return jsonObject;
|
||||
default:
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null || jsonElement.isJsonNull()) {
|
||||
jsonWriter.nullValue();
|
||||
return;
|
||||
}
|
||||
if (jsonElement.isJsonPrimitive()) {
|
||||
JsonPrimitive asJsonPrimitive = jsonElement.getAsJsonPrimitive();
|
||||
if (asJsonPrimitive.isNumber()) {
|
||||
jsonWriter.value(asJsonPrimitive.getAsNumber());
|
||||
return;
|
||||
} else if (asJsonPrimitive.isBoolean()) {
|
||||
jsonWriter.value(asJsonPrimitive.getAsBoolean());
|
||||
return;
|
||||
} else {
|
||||
jsonWriter.value(asJsonPrimitive.getAsString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (jsonElement.isJsonArray()) {
|
||||
jsonWriter.beginArray();
|
||||
Iterator<JsonElement> it = jsonElement.getAsJsonArray().iterator();
|
||||
while (it.hasNext()) {
|
||||
write(jsonWriter, it.next());
|
||||
}
|
||||
jsonWriter.endArray();
|
||||
return;
|
||||
}
|
||||
if (!jsonElement.isJsonObject()) {
|
||||
throw new IllegalArgumentException("Couldn't write " + jsonElement.getClass());
|
||||
}
|
||||
jsonWriter.beginObject();
|
||||
for (Map.Entry<String, JsonElement> entry : jsonElement.getAsJsonObject().entrySet()) {
|
||||
jsonWriter.name(entry.getKey());
|
||||
write(jsonWriter, entry.getValue());
|
||||
}
|
||||
jsonWriter.endObject();
|
||||
}
|
||||
};
|
||||
public static final TypeAdapterFactory JSON_ELEMENT_FACTORY = newTypeHierarchyFactory(JsonElement.class, JSON_ELEMENT);
|
||||
public static final TypeAdapterFactory ENUM_FACTORY = new TypeAdapterFactory() { // from class: com.google.gson.internal.bind.TypeAdapters.30
|
||||
@Override // com.google.gson.TypeAdapterFactory
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
|
||||
Class<? super T> rawType = typeToken.getRawType();
|
||||
if (!Enum.class.isAssignableFrom(rawType) || rawType == Enum.class) {
|
||||
return null;
|
||||
}
|
||||
if (!rawType.isEnum()) {
|
||||
rawType = rawType.getSuperclass();
|
||||
}
|
||||
return new EnumTypeAdapter(rawType);
|
||||
}
|
||||
};
|
||||
|
||||
/* renamed from: com.google.gson.internal.bind.TypeAdapters$36, reason: invalid class name */
|
||||
static /* synthetic */ class AnonymousClass36 {
|
||||
static final /* synthetic */ int[] $SwitchMap$com$google$gson$stream$JsonToken = new int[JsonToken.values().length];
|
||||
|
||||
static {
|
||||
try {
|
||||
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.NUMBER.ordinal()] = 1;
|
||||
} catch (NoSuchFieldError unused) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.BOOLEAN.ordinal()] = 2;
|
||||
} catch (NoSuchFieldError unused2) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.STRING.ordinal()] = 3;
|
||||
} catch (NoSuchFieldError unused3) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.NULL.ordinal()] = 4;
|
||||
} catch (NoSuchFieldError unused4) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.BEGIN_ARRAY.ordinal()] = 5;
|
||||
} catch (NoSuchFieldError unused5) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.BEGIN_OBJECT.ordinal()] = 6;
|
||||
} catch (NoSuchFieldError unused6) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.END_DOCUMENT.ordinal()] = 7;
|
||||
} catch (NoSuchFieldError unused7) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.NAME.ordinal()] = 8;
|
||||
} catch (NoSuchFieldError unused8) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.END_OBJECT.ordinal()] = 9;
|
||||
} catch (NoSuchFieldError unused9) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.END_ARRAY.ordinal()] = 10;
|
||||
} catch (NoSuchFieldError unused10) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final class EnumTypeAdapter<T extends Enum<T>> extends TypeAdapter<T> {
|
||||
private final Map<String, T> nameToConstant = new HashMap();
|
||||
private final Map<T, String> constantToName = new HashMap();
|
||||
|
||||
public EnumTypeAdapter(Class<T> cls) {
|
||||
try {
|
||||
for (T t : cls.getEnumConstants()) {
|
||||
String name = t.name();
|
||||
SerializedName serializedName = (SerializedName) cls.getField(name).getAnnotation(SerializedName.class);
|
||||
if (serializedName != null) {
|
||||
name = serializedName.value();
|
||||
for (String str : serializedName.alternate()) {
|
||||
this.nameToConstant.put(str, t);
|
||||
}
|
||||
}
|
||||
this.nameToConstant.put(name, t);
|
||||
this.constantToName.put(t, name);
|
||||
}
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public T read(JsonReader jsonReader) throws IOException {
|
||||
if (jsonReader.peek() != JsonToken.NULL) {
|
||||
return this.nameToConstant.get(jsonReader.nextString());
|
||||
}
|
||||
jsonReader.nextNull();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, T t) throws IOException {
|
||||
jsonWriter.value(t == null ? null : this.constantToName.get(t));
|
||||
}
|
||||
}
|
||||
|
||||
private TypeAdapters() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public static <TT> TypeAdapterFactory newFactory(final TypeToken<TT> typeToken, final TypeAdapter<TT> typeAdapter) {
|
||||
return new TypeAdapterFactory() { // from class: com.google.gson.internal.bind.TypeAdapters.31
|
||||
@Override // com.google.gson.TypeAdapterFactory
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken2) {
|
||||
if (typeToken2.equals(TypeToken.this)) {
|
||||
return typeAdapter;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static <TT> TypeAdapterFactory newFactoryForMultipleTypes(final Class<TT> cls, final Class<? extends TT> cls2, final TypeAdapter<? super TT> typeAdapter) {
|
||||
return new TypeAdapterFactory() { // from class: com.google.gson.internal.bind.TypeAdapters.34
|
||||
@Override // com.google.gson.TypeAdapterFactory
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
|
||||
Class<? super T> rawType = typeToken.getRawType();
|
||||
if (rawType == cls || rawType == cls2) {
|
||||
return typeAdapter;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Factory[type=" + cls.getName() + "+" + cls2.getName() + ",adapter=" + typeAdapter + "]";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static <T1> TypeAdapterFactory newTypeHierarchyFactory(final Class<T1> cls, final TypeAdapter<T1> typeAdapter) {
|
||||
return new TypeAdapterFactory() { // from class: com.google.gson.internal.bind.TypeAdapters.35
|
||||
@Override // com.google.gson.TypeAdapterFactory
|
||||
public <T2> TypeAdapter<T2> create(Gson gson, TypeToken<T2> typeToken) {
|
||||
final Class<? super T2> rawType = typeToken.getRawType();
|
||||
if (cls.isAssignableFrom(rawType)) {
|
||||
return (TypeAdapter<T2>) new TypeAdapter<T1>() { // from class: com.google.gson.internal.bind.TypeAdapters.35.1
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public T1 read(JsonReader jsonReader) throws IOException {
|
||||
T1 t1 = (T1) typeAdapter.read(jsonReader);
|
||||
if (t1 == null || rawType.isInstance(t1)) {
|
||||
return t1;
|
||||
}
|
||||
throw new JsonSyntaxException("Expected a " + rawType.getName() + " but was " + t1.getClass().getName());
|
||||
}
|
||||
|
||||
@Override // com.google.gson.TypeAdapter
|
||||
public void write(JsonWriter jsonWriter, T1 t1) throws IOException {
|
||||
typeAdapter.write(jsonWriter, t1);
|
||||
}
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Factory[typeHierarchy=" + cls.getName() + ",adapter=" + typeAdapter + "]";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static <TT> TypeAdapterFactory newFactory(final Class<TT> cls, final TypeAdapter<TT> typeAdapter) {
|
||||
return new TypeAdapterFactory() { // from class: com.google.gson.internal.bind.TypeAdapters.32
|
||||
@Override // com.google.gson.TypeAdapterFactory
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
|
||||
if (typeToken.getRawType() == cls) {
|
||||
return typeAdapter;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Factory[type=" + cls.getName() + ",adapter=" + typeAdapter + "]";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static <TT> TypeAdapterFactory newFactory(final Class<TT> cls, final Class<TT> cls2, final TypeAdapter<? super TT> typeAdapter) {
|
||||
return new TypeAdapterFactory() { // from class: com.google.gson.internal.bind.TypeAdapters.33
|
||||
@Override // com.google.gson.TypeAdapterFactory
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
|
||||
Class<? super T> rawType = typeToken.getRawType();
|
||||
if (rawType == cls || rawType == cls2) {
|
||||
return typeAdapter;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Factory[type=" + cls2.getName() + "+" + cls.getName() + ",adapter=" + typeAdapter + "]";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
120
sources/com/google/gson/internal/bind/util/ISO8601Utils.java
Normal file
120
sources/com/google/gson/internal/bind/util/ISO8601Utils.java
Normal file
@@ -0,0 +1,120 @@
|
||||
package com.google.gson.internal.bind.util;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ISO8601Utils {
|
||||
private static final String UTC_ID = "UTC";
|
||||
private static final TimeZone TIMEZONE_UTC = TimeZone.getTimeZone(UTC_ID);
|
||||
|
||||
private static boolean checkOffset(String str, int i, char c) {
|
||||
return i < str.length() && str.charAt(i) == c;
|
||||
}
|
||||
|
||||
public static String format(Date date) {
|
||||
return format(date, false, TIMEZONE_UTC);
|
||||
}
|
||||
|
||||
private static int indexOfNonDigit(String str, int i) {
|
||||
while (i < str.length()) {
|
||||
char charAt = str.charAt(i);
|
||||
if (charAt < '0' || charAt > '9') {
|
||||
return i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return str.length();
|
||||
}
|
||||
|
||||
private static void padInt(StringBuilder sb, int i, int i2) {
|
||||
String num = Integer.toString(i);
|
||||
for (int length = i2 - num.length(); length > 0; length--) {
|
||||
sb.append('0');
|
||||
}
|
||||
sb.append(num);
|
||||
}
|
||||
|
||||
/* JADX WARN: Removed duplicated region for block: B:44:0x00cc A[Catch: IllegalArgumentException | IndexOutOfBoundsException | NumberFormatException -> 0x01bb, NumberFormatException -> 0x01bd, IndexOutOfBoundsException -> 0x01bf, TryCatch #2 {IllegalArgumentException | IndexOutOfBoundsException | NumberFormatException -> 0x01bb, blocks: (B:3:0x0006, B:5:0x0018, B:6:0x001a, B:8:0x0026, B:9:0x0028, B:11:0x0037, B:13:0x003d, B:18:0x0052, B:20:0x0062, B:21:0x0064, B:23:0x0070, B:24:0x0072, B:26:0x0078, B:30:0x0082, B:35:0x0094, B:37:0x009c, B:42:0x00c6, B:44:0x00cc, B:46:0x00d3, B:47:0x0181, B:53:0x00df, B:54:0x00f8, B:55:0x00f9, B:58:0x0115, B:60:0x0122, B:63:0x012b, B:65:0x014a, B:68:0x0159, B:69:0x017b, B:71:0x017e, B:72:0x0104, B:73:0x01b3, B:74:0x01ba, B:75:0x00b4, B:76:0x00b7), top: B:2:0x0006 }] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:73:0x01b3 A[Catch: IllegalArgumentException | IndexOutOfBoundsException | NumberFormatException -> 0x01bb, NumberFormatException -> 0x01bd, IndexOutOfBoundsException -> 0x01bf, TryCatch #2 {IllegalArgumentException | IndexOutOfBoundsException | NumberFormatException -> 0x01bb, blocks: (B:3:0x0006, B:5:0x0018, B:6:0x001a, B:8:0x0026, B:9:0x0028, B:11:0x0037, B:13:0x003d, B:18:0x0052, B:20:0x0062, B:21:0x0064, B:23:0x0070, B:24:0x0072, B:26:0x0078, B:30:0x0082, B:35:0x0094, B:37:0x009c, B:42:0x00c6, B:44:0x00cc, B:46:0x00d3, B:47:0x0181, B:53:0x00df, B:54:0x00f8, B:55:0x00f9, B:58:0x0115, B:60:0x0122, B:63:0x012b, B:65:0x014a, B:68:0x0159, B:69:0x017b, B:71:0x017e, B:72:0x0104, B:73:0x01b3, B:74:0x01ba, B:75:0x00b4, B:76:0x00b7), top: B:2:0x0006 }] */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public static java.util.Date parse(java.lang.String r18, java.text.ParsePosition r19) throws java.text.ParseException {
|
||||
/*
|
||||
Method dump skipped, instructions count: 552
|
||||
To view this dump change 'Code comments level' option to 'DEBUG'
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.google.gson.internal.bind.util.ISO8601Utils.parse(java.lang.String, java.text.ParsePosition):java.util.Date");
|
||||
}
|
||||
|
||||
private static int parseInt(String str, int i, int i2) throws NumberFormatException {
|
||||
int i3;
|
||||
int i4;
|
||||
if (i < 0 || i2 > str.length() || i > i2) {
|
||||
throw new NumberFormatException(str);
|
||||
}
|
||||
if (i < i2) {
|
||||
i3 = i + 1;
|
||||
int digit = Character.digit(str.charAt(i), 10);
|
||||
if (digit < 0) {
|
||||
throw new NumberFormatException("Invalid number: " + str.substring(i, i2));
|
||||
}
|
||||
i4 = -digit;
|
||||
} else {
|
||||
i3 = i;
|
||||
i4 = 0;
|
||||
}
|
||||
while (i3 < i2) {
|
||||
int i5 = i3 + 1;
|
||||
int digit2 = Character.digit(str.charAt(i3), 10);
|
||||
if (digit2 < 0) {
|
||||
throw new NumberFormatException("Invalid number: " + str.substring(i, i2));
|
||||
}
|
||||
i4 = (i4 * 10) - digit2;
|
||||
i3 = i5;
|
||||
}
|
||||
return -i4;
|
||||
}
|
||||
|
||||
public static String format(Date date, boolean z) {
|
||||
return format(date, z, TIMEZONE_UTC);
|
||||
}
|
||||
|
||||
public static String format(Date date, boolean z, TimeZone timeZone) {
|
||||
GregorianCalendar gregorianCalendar = new GregorianCalendar(timeZone, Locale.US);
|
||||
gregorianCalendar.setTime(date);
|
||||
StringBuilder sb = new StringBuilder(19 + (z ? 4 : 0) + (timeZone.getRawOffset() == 0 ? 1 : 6));
|
||||
padInt(sb, gregorianCalendar.get(1), 4);
|
||||
sb.append('-');
|
||||
padInt(sb, gregorianCalendar.get(2) + 1, 2);
|
||||
sb.append('-');
|
||||
padInt(sb, gregorianCalendar.get(5), 2);
|
||||
sb.append('T');
|
||||
padInt(sb, gregorianCalendar.get(11), 2);
|
||||
sb.append(':');
|
||||
padInt(sb, gregorianCalendar.get(12), 2);
|
||||
sb.append(':');
|
||||
padInt(sb, gregorianCalendar.get(13), 2);
|
||||
if (z) {
|
||||
sb.append('.');
|
||||
padInt(sb, gregorianCalendar.get(14), 3);
|
||||
}
|
||||
int offset = timeZone.getOffset(gregorianCalendar.getTimeInMillis());
|
||||
if (offset != 0) {
|
||||
int i = offset / 60000;
|
||||
int abs = Math.abs(i / 60);
|
||||
int abs2 = Math.abs(i % 60);
|
||||
sb.append(offset >= 0 ? '+' : '-');
|
||||
padInt(sb, abs, 2);
|
||||
sb.append(':');
|
||||
padInt(sb, abs2, 2);
|
||||
} else {
|
||||
sb.append('Z');
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user