198 lines
5.6 KiB
Java
198 lines
5.6 KiB
Java
package c.i.d.q.x;
|
|
|
|
import c.i.d.g;
|
|
import c.i.d.j;
|
|
import c.i.d.k;
|
|
import com.google.gson.JsonElement;
|
|
import com.google.gson.JsonObject;
|
|
import com.google.gson.stream.JsonWriter;
|
|
import java.io.IOException;
|
|
import java.io.Writer;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
/* compiled from: JsonTreeWriter */
|
|
public final class b extends JsonWriter {
|
|
public static final Writer t = new a();
|
|
public static final k u = new k("closed");
|
|
public final List<JsonElement> v = new ArrayList();
|
|
public String w;
|
|
|
|
/* renamed from: x reason: collision with root package name */
|
|
public JsonElement f1400x = j.a;
|
|
|
|
/* compiled from: JsonTreeWriter */
|
|
public class a extends Writer {
|
|
@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();
|
|
}
|
|
}
|
|
|
|
public b() {
|
|
super(t);
|
|
}
|
|
|
|
@Override // com.google.gson.stream.JsonWriter
|
|
public JsonWriter B(long j) throws IOException {
|
|
Q(new k(Long.valueOf(j)));
|
|
return this;
|
|
}
|
|
|
|
@Override // com.google.gson.stream.JsonWriter
|
|
public JsonWriter C(Boolean bool) throws IOException {
|
|
if (bool == null) {
|
|
Q(j.a);
|
|
return this;
|
|
}
|
|
Q(new k(bool));
|
|
return this;
|
|
}
|
|
|
|
@Override // com.google.gson.stream.JsonWriter
|
|
public JsonWriter G(Number number) throws IOException {
|
|
if (number == null) {
|
|
Q(j.a);
|
|
return this;
|
|
}
|
|
if (!this.p) {
|
|
double doubleValue = number.doubleValue();
|
|
if (Double.isNaN(doubleValue) || Double.isInfinite(doubleValue)) {
|
|
throw new IllegalArgumentException("JSON forbids NaN and infinities: " + number);
|
|
}
|
|
}
|
|
Q(new k(number));
|
|
return this;
|
|
}
|
|
|
|
@Override // com.google.gson.stream.JsonWriter
|
|
public JsonWriter H(String str) throws IOException {
|
|
if (str == null) {
|
|
Q(j.a);
|
|
return this;
|
|
}
|
|
Q(new k(str));
|
|
return this;
|
|
}
|
|
|
|
@Override // com.google.gson.stream.JsonWriter
|
|
public JsonWriter I(boolean z2) throws IOException {
|
|
Q(new k(Boolean.valueOf(z2)));
|
|
return this;
|
|
}
|
|
|
|
public JsonElement M() {
|
|
if (this.v.isEmpty()) {
|
|
return this.f1400x;
|
|
}
|
|
StringBuilder P = c.d.b.a.a.P("Expected one JSON element but was ");
|
|
P.append(this.v);
|
|
throw new IllegalStateException(P.toString());
|
|
}
|
|
|
|
public final JsonElement N() {
|
|
List<JsonElement> list = this.v;
|
|
return list.get(list.size() - 1);
|
|
}
|
|
|
|
public final void Q(JsonElement jsonElement) {
|
|
if (this.w != null) {
|
|
if (!(jsonElement instanceof j) || this.f2445s) {
|
|
((JsonObject) N()).a.put(this.w, jsonElement);
|
|
}
|
|
this.w = null;
|
|
} else if (this.v.isEmpty()) {
|
|
this.f1400x = jsonElement;
|
|
} else {
|
|
JsonElement N = N();
|
|
if (N instanceof g) {
|
|
((g) N).i.add(jsonElement);
|
|
return;
|
|
}
|
|
throw new IllegalStateException();
|
|
}
|
|
}
|
|
|
|
@Override // com.google.gson.stream.JsonWriter
|
|
public JsonWriter b() throws IOException {
|
|
g gVar = new g();
|
|
Q(gVar);
|
|
this.v.add(gVar);
|
|
return this;
|
|
}
|
|
|
|
@Override // com.google.gson.stream.JsonWriter
|
|
public JsonWriter c() throws IOException {
|
|
JsonObject jsonObject = new JsonObject();
|
|
Q(jsonObject);
|
|
this.v.add(jsonObject);
|
|
return this;
|
|
}
|
|
|
|
@Override // com.google.gson.stream.JsonWriter, java.io.Closeable, java.lang.AutoCloseable
|
|
public void close() throws IOException {
|
|
if (this.v.isEmpty()) {
|
|
this.v.add(u);
|
|
return;
|
|
}
|
|
throw new IOException("Incomplete document");
|
|
}
|
|
|
|
@Override // com.google.gson.stream.JsonWriter
|
|
public JsonWriter e() throws IOException {
|
|
if (this.v.isEmpty() || this.w != null) {
|
|
throw new IllegalStateException();
|
|
} else if (N() instanceof g) {
|
|
List<JsonElement> list = this.v;
|
|
list.remove(list.size() - 1);
|
|
return this;
|
|
} else {
|
|
throw new IllegalStateException();
|
|
}
|
|
}
|
|
|
|
@Override // com.google.gson.stream.JsonWriter
|
|
public JsonWriter f() throws IOException {
|
|
if (this.v.isEmpty() || this.w != null) {
|
|
throw new IllegalStateException();
|
|
} else if (N() instanceof JsonObject) {
|
|
List<JsonElement> list = this.v;
|
|
list.remove(list.size() - 1);
|
|
return this;
|
|
} else {
|
|
throw new IllegalStateException();
|
|
}
|
|
}
|
|
|
|
@Override // com.google.gson.stream.JsonWriter, java.io.Flushable
|
|
public void flush() throws IOException {
|
|
}
|
|
|
|
@Override // com.google.gson.stream.JsonWriter
|
|
public JsonWriter p(String str) throws IOException {
|
|
if (this.v.isEmpty() || this.w != null) {
|
|
throw new IllegalStateException();
|
|
} else if (N() instanceof JsonObject) {
|
|
this.w = str;
|
|
return this;
|
|
} else {
|
|
throw new IllegalStateException();
|
|
}
|
|
}
|
|
|
|
@Override // com.google.gson.stream.JsonWriter
|
|
public JsonWriter s() throws IOException {
|
|
Q(j.a);
|
|
return this;
|
|
}
|
|
}
|