Initial commit
This commit is contained in:
74
sources/com/google/gson/JsonStreamParser.java
Normal file
74
sources/com/google/gson/JsonStreamParser.java
Normal file
@@ -0,0 +1,74 @@
|
||||
package com.google.gson;
|
||||
|
||||
import com.google.gson.internal.Streams;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.MalformedJsonException;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class JsonStreamParser implements Iterator<JsonElement> {
|
||||
private final Object lock;
|
||||
private final JsonReader parser;
|
||||
|
||||
public JsonStreamParser(String str) {
|
||||
this(new StringReader(str));
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public boolean hasNext() {
|
||||
boolean z;
|
||||
synchronized (this.lock) {
|
||||
try {
|
||||
try {
|
||||
try {
|
||||
z = this.parser.peek() != JsonToken.END_DOCUMENT;
|
||||
} catch (MalformedJsonException e) {
|
||||
throw new JsonSyntaxException(e);
|
||||
}
|
||||
} catch (IOException e2) {
|
||||
throw new JsonIOException(e2);
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public JsonStreamParser(Reader reader) {
|
||||
this.parser = new JsonReader(reader);
|
||||
this.parser.setLenient(true);
|
||||
this.lock = new Object();
|
||||
}
|
||||
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // java.util.Iterator
|
||||
public JsonElement next() throws JsonParseException {
|
||||
if (!hasNext()) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
try {
|
||||
return Streams.parse(this.parser);
|
||||
} catch (JsonParseException e) {
|
||||
if (e.getCause() instanceof EOFException) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
throw e;
|
||||
} catch (OutOfMemoryError e2) {
|
||||
throw new JsonParseException("Failed parsing JSON source to Json", e2);
|
||||
} catch (StackOverflowError e3) {
|
||||
throw new JsonParseException("Failed parsing JSON source to Json", e3);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user