RawJsonReader class
Пакет: com.hypixel.hytale.codec.util
Файл: com/hypixel/hytale/codec/util/RawJsonReader.java
implements: AutoCloseable
Поля (160)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
ThreadLocal<char[]> |
READ_BUFFER |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
break |
|
|
continue |
|
|
continue |
|
|
continue |
|
yield |
false |
|
|
return |
|
|
return |
|
|
return |
|
|
return |
|
|
return |
|
|
return |
|
|
return |
|
|
return |
|
|
return |
|
|
return |
|
|
return |
|
|
return |
|
|
return |
|
yield |
true |
|
int |
var1 |
|
|
var1 |
|
|
var1 |
|
|
var1 |
|
char |
var1 |
|
int |
var1 |
|
char[] |
var1 |
|
char |
var1 |
|
int |
var1 |
|
|
var1 |
|
|
var1 |
|
char |
var1 |
|
|
var1 |
|
|
var1 |
|
|
var1 |
|
|
var1 |
|
char |
var1 |
|
|
var1 |
|
|
var1 |
|
|
var1 |
|
|
var1 |
|
|
var1 |
|
char |
var1 |
|
int |
var1 |
|
char |
var1 |
|
int |
var1 |
|
int |
var1 |
|
char |
var1 |
|
StringBuilder |
var1 |
|
StringBuilder |
var1 |
|
StringBuilder |
var1 |
|
int |
var1 |
|
boolean |
var2 |
|
int |
var2 |
|
|
var2 |
|
|
var2 |
|
|
var2 |
|
char[] |
var2 |
|
char |
var2 |
|
boolean |
var2 |
|
|
var2 |
|
|
var2 |
|
int |
var2 |
|
|
var2 |
|
|
var2 |
|
|
var2 |
|
int |
var2 |
|
|
var2 |
|
|
var2 |
|
|
var2 |
|
char |
var2 |
|
int |
var2 |
|
char |
var2 |
|
char |
var2 |
|
char |
var2 |
|
char |
var2 |
|
char |
var2 |
|
int |
var2 |
|
|
var2 |
|
|
var2 |
|
char |
var2 |
|
int |
var2 |
|
int |
var2 |
|
int |
var2 |
|
int |
var3 |
|
long |
var3 |
|
char |
var3 |
|
int |
var3 |
|
long |
var3 |
|
char |
var3 |
|
char |
var3 |
|
char |
var3 |
|
char |
var3 |
|
char |
var3 |
|
char |
var3 |
|
int |
var3 |
|
char |
var3 |
|
long |
var3 |
|
long |
var3 |
|
int |
var3 |
|
char |
var3 |
|
int |
var3 |
|
int |
var3 |
|
int |
var3 |
|
int |
var3 |
|
int |
var3 |
|
int |
var4 |
|
String |
var4 |
|
long |
var4 |
|
double |
var4 |
|
|
var4 |
|
int |
var4 |
|
int |
var4 |
|
char[] |
var5 |
|
long |
var5 |
|
String |
var5 |
|
long |
var5 |
|
long |
var5 |
|
int |
var6 |
|
char |
var6 |
|
int |
var7 |
|
long |
var7 |
|
char |
var7 |
|
int |
var9 |
Методы (203)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
abstract |
throw new |
IOExceptionthrow new IOException("Failed to skip " + var1 + " char's!") |
abstract |
throw new |
IOExceptionthrow new IOException("mark can't be used while already marked!") |
abstract |
throw new |
IOExceptionthrow new IOException("Stream not marked") |
abstract |
return new |
IOExceptionreturn new IOException("Unexpected EOF!") |
abstract |
throw new |
IllegalArgumentExceptionthrow new IllegalArgumentException("buffer can't be null!") |
private |
void |
appendEscapevoid appendEscape() |
private |
int |
appendLineint appendLine(@Nonnull StringBuilder var1, int var2, int var3) |
private |
int |
appendProblemLineint appendProblemLine(@Nonnull StringBuilder var1, int var2, int var3) |
private |
void |
appendStringRunvoid appendStringRun(int var1) |
public |
char[] |
cloneMarkchar[] cloneMark() |
public |
char[] |
closeAndTakeBufferchar[] closeAndTakeBuffer() |
public |
void |
consumeIgnoreCasevoid consumeIgnoreCase(@Nonnull String var1, int var2) |
public |
void |
consumeWhiteSpacevoid consumeWhiteSpace() |
static |
void |
copyStringvoid copyString(@Nonnull RawJsonReader var0, @Nonnull StringBuilder var1) |
abstract |
|
copyString copyString(var0, var1) |
private |
boolean |
ensureboolean ensure() |
private |
boolean |
ensureboolean ensure(int var1) |
static |
boolean |
equalsIgnoreCaseboolean equalsIgnoreCase(char var0, char var1) |
public |
void |
expectvoid expect(char var1) |
public |
void |
expectvoid expect(@Nonnull String var1, int var2) |
private |
boolean |
fillboolean fill() |
private |
boolean |
fillAppendboolean fillAppend() |
private |
boolean |
fillLookAheadboolean fillLookAhead() |
private |
int |
findLineStartint findLineStart(int var1) |
public |
int |
findOffsetint findOffset(char var1) |
public |
int |
findOffsetint findOffset(int var1, char var2) |
|
|
for for(var2 = false; this.bufferIndex + var1 > this.bufferSize; var2 = true) |
|
|
for for(var3 = this.line; var2 > 0 && var3 > this.line - 10; var3--) |
abstract |
|
for for(int var4 = this.appendProblemLine(var1, var2, this.line) |
abstract |
return |
fromJsonStringreturn fromJsonString("\"" + var0 + "\"") |
public |
char[] |
getBufferchar[] getBuffer() |
public |
int |
getBufferIndexint getBufferIndex() |
public |
int |
getBufferSizeint getBufferSize() |
public |
int |
getColumnint getColumn() |
public |
int |
getLineint getLine() |
public |
int |
getMarkDistanceint getMarkDistance() |
|
|
if if(var1 == null) |
|
|
if if(var2 == null) |
|
|
if if(this.in == null) |
|
|
if if(this.markIndex <= -1) |
|
|
if if(this.bufferIndex > 0 && var3 > 0) |
|
|
if if(this.markIndex > 16384) |
|
|
if if(var7 > 0) |
|
|
if if(this.bufferIndex + var1 >= this.bufferSize) |
|
|
if if(this.bufferIndex + var1 >= this.bufferSize) |
|
|
if if(this.bufferIndex >= this.bufferSize) |
|
|
if if(this.bufferIndex >= this.bufferSize) |
|
|
if if(var1 == '\n') |
|
|
if if(var1 < 0L) |
|
|
if if(var1 < var9) |
|
|
if if(var7 <= var5) |
|
|
if if(this.bufferIndex >= this.bufferSize) |
|
|
if if(this.bufferIndex + var1 >= this.bufferSize) |
|
|
if if(var3 == var2) |
|
|
if if(this.in == null) |
|
|
if if(this.bufferSize >= this.buffer.length) |
|
|
if if(var3 > 0) |
|
|
if if(this.markIndex > -1) |
|
|
if if(var3 != var1) |
|
|
if if(this.markIndex >= 0) |
|
|
if if(this.markIndex < 0) |
|
|
if if(this.buffer != null) |
|
|
if if(this.in != null) |
|
|
if if(this.buffer[this.bufferIndex] == var1) |
|
|
if if(var1 == '\n') |
|
|
if if(var3 == '\n') |
|
|
if if(var3 == '\n') |
|
|
if if(var2 != var1) |
|
|
if if(var1 == '\n') |
|
|
if if(var3 == '\n') |
|
|
if if(var3 == var1) |
|
|
if if(var1 == '\n') |
|
|
if if(var2 == '\n') |
|
|
if if(this.bufferIndex >= this.bufferSize) |
|
|
if if(this.bufferIndex >= this.bufferSize) |
|
|
if if(var3 == '\n') |
|
|
if if(var3 == '"') |
|
|
if if(!var2) |
|
|
if if(var3 == '\\') |
|
|
if if(this.tempSb == null) |
|
|
if if(var2 == -1) |
|
|
if if(var2 == -1) |
|
|
if if(var2 == -1) |
|
|
if if(var2 == -1) |
|
|
if if(var2 == -1) |
|
|
if if(var2 == -1) |
|
|
if if(var2 == -1) |
|
|
if if(var2 == -1) |
|
|
if if(var1 == 1) |
|
|
if if(var1 == 2) |
|
|
if if(var1 == 3) |
|
|
if if(this.bufferIndex + var1 >= this.bufferSize) |
|
|
if if(this.bufferIndex >= this.bufferSize) |
|
|
if if(this.bufferIndex >= this.bufferSize) |
|
|
if if(this.tempSb == null) |
|
|
if if(this.bufferIndex >= this.bufferSize) |
|
|
if if(this.bufferIndex >= this.bufferSize) |
|
|
if if(this.bufferIndex >= this.bufferSize) |
|
|
if if(this.bufferIndex >= this.bufferSize) |
|
|
if if(--var1 == 0) |
|
|
if if(--var1 == 0) |
|
|
if if(this.buffer == null) |
|
|
if if(var0 == var1) |
|
|
if if(--var2 == 0) |
|
|
if if(--var2 == 0) |
|
|
if if(var2 == 34) |
|
|
if if(var2 == 92) |
|
|
if if(var3 != -1) |
|
|
if if(var1 == -1) |
public |
boolean |
isMarkedboolean isMarked() |
public |
void |
markvoid mark(int var1) |
public |
void |
markvoid mark() |
public |
boolean |
markSupportedboolean markSupported() |
public |
int |
peekint peek() |
public |
int |
peekint peek(int var1) |
public |
boolean |
peekForboolean peekFor(char var1) |
public |
int |
readint read() |
public |
boolean |
readBooleanValueboolean readBooleanValue() |
static |
void |
readBsonArray0void readBsonArray0(@Nonnull RawJsonReader var0, @Nonnull StringBuilder var1) |
abstract |
|
readBsonArray0 readBsonArray0(var0, var1) |
static |
void |
readBsonDocument0void readBsonDocument0(@Nonnull RawJsonReader var0, @Nonnull StringBuilder var1) |
abstract |
|
readBsonDocument0 readBsonDocument0(var0, var1) |
public |
byte |
readByteValuebyte readByteValue() |
public |
byte |
readByteValuebyte readByteValue(int var1) |
public |
double |
readDoubleValuedouble readDoubleValue() |
public |
float |
readFloatValuefloat readFloatValue() |
public |
int |
readIntValueint readIntValue() |
public |
int |
readIntValueint readIntValue(int var1) |
public |
long |
readLongValuelong readLongValue() |
public |
long |
readLongValuelong readLongValue(int var1) |
public |
long |
readStringPartAsLonglong readStringPartAsLong(int var1) |
protected |
long |
readStringPartAsLongSlowlong readStringPartAsLongSlow(int var1) |
protected |
long |
readStringPartAsLongUnsafelong readStringPartAsLongUnsafe(int var1) |
public |
boolean |
readyboolean ready() |
public |
void |
resetvoid reset() |
static |
boolean |
seekToKeyboolean seekToKey(@Nonnull RawJsonReader var0, @Nonnull String var1) |
public |
long |
skiplong skip(long var1) |
public |
void |
skipArrayvoid skipArray() |
public |
void |
skipArrayContinuedvoid skipArrayContinued() |
public |
void |
skipBooleanValuevoid skipBooleanValue() |
public |
void |
skipDoubleValuevoid skipDoubleValue() |
public |
void |
skipFloatValuevoid skipFloatValue() |
public |
void |
skipIntValuevoid skipIntValue() |
public |
void |
skipIntValuevoid skipIntValue(int var1) |
public |
void |
skipLongValuevoid skipLongValue() |
public |
void |
skipLongValuevoid skipLongValue(int var1) |
public |
void |
skipNullValuevoid skipNullValue() |
public |
void |
skipObjectvoid skipObject() |
public |
void |
skipObjectContinuedvoid skipObjectContinued() |
public |
void |
skipOrThrowvoid skipOrThrow(long var1) |
public |
void |
skipRemainingStringvoid skipRemainingString() |
public |
void |
skipStringvoid skipString() |
public |
void |
skipValuevoid skipValue() |
|
|
switch switch(var1) |
|
|
switch switch(var1) |
|
|
switch switch(var1) |
|
|
switch switch(var1) |
|
return |
switchreturn switch(var1) |
|
|
switch switch(var2) |
|
|
switch switch(var1) |
|
|
switch switch(var2) |
|
|
switch switch(var2) |
|
|
switch switch(var2) |
|
|
switch switch(var2) |
|
|
switch switch(var1) |
|
|
switch switch(var3) |
|
|
switch switch(var3) |
public |
boolean |
tryConsumeboolean tryConsume(char var1) |
public |
boolean |
tryConsumeboolean tryConsume(@Nonnull String var1) |
public |
boolean |
tryConsumeboolean tryConsume(@Nonnull String var1, int var2) |
public |
boolean |
tryConsumeOrExpectboolean tryConsumeOrExpect(char var1, char var2) |
public |
int |
tryConsumeSomeint tryConsumeSome(@Nonnull String var1, int var2) |
public |
boolean |
tryConsumeStringboolean tryConsumeString(@Nonnull String var1) |
public |
void |
unmarkvoid unmark() |
static |
void |
validateBsonDocumentvoid validateBsonDocument(@Nonnull RawJsonReader var0) |
abstract |
|
validateBsonValue validateBsonValue(var0) |
|
|
while while(var3 < var1) |
|
|
while while(true) |
|
|
while while(true) |
|
|
while while(this.bufferIndex < this.bufferSize) |
|
|
while while(true) |
|
|
while while(this.bufferIndex >= this.bufferSize) |
|
|
while while(true) |
|
|
while while(this.bufferIndex < this.bufferSize) |
|
|
while while(true) |
|
|
while while(true) |
|
|
while while(this.bufferIndex < this.bufferSize) |
|
|
while while(true) |
|
|
while while(this.bufferIndex < this.bufferSize) |
|
|
while while(true) |
|
|
while while(this.bufferIndex < this.bufferSize) |
|
|
while while(true) |
|
|
while while(this.bufferIndex < this.bufferSize) |
|
|
while while(true) |
|
|
while while(this.bufferIndex < this.bufferSize) |
|
|
while while(var3 < this.line) |
|
|
while while(var1 > 0 && this.buffer[var1] != '\n') |
|
|
while while(var2 < this.bufferSize && this.buffer[var2] != '\n') |
|
|
while while(var2 < this.bufferSize && this.buffer[var2] != '\n') |
|
|
while while(true) |
|
|
while while(true) |
|
|
while while(true) |
|
|
while while(true) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.codec.util;
class="kw">import ch.randelshofer.fastdoubleparser.JavaDoubleParser;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.ExtraInfo;
class="kw">import com.hypixel.hytale.logger.HytaleLogger;
class="kw">import com.hypixel.hytale.unsafe.UnsafeUtil;
class="kw">import java.io.IOException;
class="kw">import java.io.InputStreamReader;
class="kw">import java.io.Reader;
class="kw">import java.nio.charset.StandardCharsets;
class="kw">import java.nio.file.Files;
class="kw">import java.nio.file.NoSuchFileException;
class="kw">import java.nio.file.Path;
class="kw">import java.util.Arrays;
class="kw">import java.util.logging.Level;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.bson.BsonArray;
class="kw">import org.bson.BsonBoolean;
class="kw">import org.bson.BsonDocument;
class="kw">import org.bson.BsonDouble;
class="kw">import org.bson.BsonNull;
class="kw">import org.bson.BsonString;
class="kw">import org.bson.BsonValue;
class="kw">import sun.misc.Unsafe;
class="kw">public class RawJsonReader class="kw">implements AutoCloseable {
class="kw">public class="kw">static class="kw">final ThreadLocal<char[]> READ_BUFFER = ThreadLocal.withInitial(() -> new char[131072]);
class="kw">public class="kw">static class="kw">final int DEFAULT_CHAR_BUFFER_SIZE = 32768;
class="kw">public class="kw">static class="kw">final int MIN_CHAR_BUFFER_READ = 16384;
class="kw">public class="kw">static class="kw">final int BUFFER_GROWTH = 1048576;
class="kw">private class="kw">static class="kw">final int UNMARKED = -1;
class="kw">private int streamIndex;
@Nullable
class="kw">private Reader in;
@Nullable
class="kw">private char[] buffer;
class="kw">private int bufferIndex;
class="kw">private int bufferSize;
class="kw">private int markIndex = -1;
class="kw">private int markLine = -1;
class="kw">private int markLineStart = -1;
class="kw">private StringBuilder tempSb;
class="kw">private int line;
class="kw">private int lineStart;
class="kw">public class="kw">static class="kw">final int ERROR_LINES_BUFFER = 10;
class="kw">public RawJsonReader(@Nonnull char[] var1) {
if (var1 == null) {
throw new IllegalArgumentException("buffer can't be null!");
}
this.in = null;
this.buffer = var1;
this.bufferIndex = 0;
this.streamIndex = 0;
this.bufferSize = var1.length;
}
class="kw">public RawJsonReader(Reader var1, @Nonnull char[] var2) {
if (var2 == null) {
throw new IllegalArgumentException("buffer can't be null!");
}
this.in = var1;
this.buffer = var2;
this.bufferIndex = 0;
this.streamIndex = 0;
this.bufferSize = 0;
}
class="kw">public char[] getBuffer() {
class="kw">return this.buffer;
}
class="kw">public int getBufferIndex() {
class="kw">return this.bufferIndex;
}
class="kw">public int getBufferSize() {
class="kw">return this.bufferSize;
}
class="kw">public int getLine() {
class="kw">return this.line + 1;
}
class="kw">public int getColumn() {
class="kw">return this.bufferIndex - this.lineStart + 1;
}
class="kw">private boolean ensure() class="kw">throws IOException {
class="kw">return this.ensure(1);
}
class="kw">private boolean ensure(int var1) class="kw">throws IOException {
boolean var2;
for (var2 = false; this.bufferIndex + var1 > this.bufferSize; var2 = true) {
if (!this.fill()) {
throw this.unexpectedEOF();
}
}
class="kw">return var2;
}
class="kw">private boolean fill() class="kw">throws IOException {
if (this.in == null) {
class="kw">return false;
}
int var1;
int var2;
if (this.markIndex <= -1) {
int var3 = this.bufferSize - this.bufferIndex;
if (this.bufferIndex > 0 && var3 > 0) {
System.arraycopy(this.buffer, this.bufferIndex, this.buffer, 0, var3);
}
this.streamIndex = this.streamIndex + this.bufferIndex;
this.bufferIndex = 0;
this.bufferSize = var3;
var1 = var3;
var2 = this.buffer.length - var3;
} else if (this.buffer.length - this.bufferSize > 16384) {
var1 = this.bufferSize;
var2 = this.buffer.length - this.bufferSize;
} else {
int var6 = this.bufferSize - this.markIndex;
if (this.markIndex > 16384) {
System.arraycopy(this.buffer, this.markIndex, this.buffer, 0, var6);
} else {
int var4 = this.bufferSize + 1048576;
System.err.println("Reallocate: " + this.buffer.length + " to " + var4);
char[] var5 = new char[var4];
System.arraycopy(this.buffer, this.markIndex, var5, 0, var6);
this.buffer = var5;
}
this.streamIndex = this.streamIndex + this.markIndex;
this.bufferIndex = this.bufferIndex - this.markIndex;
this.bufferSize = var6;
this.markIndex = 0;
var1 = var6;
var2 = this.buffer.length - var6;
}
int var7 = this.in.read(this.buffer, var1, var2);
if (var7 > 0) {
this.bufferSize = var1 + var7;
class="kw">return true;
} else {
class="kw">return false;
}
}
class="kw">public int peek() class="kw">throws IOException {
class="kw">return this.peek(0);
}
class="kw">public int peek(int var1) class="kw">throws IOException {
if (this.bufferIndex + var1 >= this.bufferSize) {
this.fill();
if (this.bufferIndex + var1 >= this.bufferSize) {
class="kw">return -1;
}
}
class="kw">return this.buffer[this.bufferIndex + var1];
}
class="kw">public int read() class="kw">throws IOException {
if (this.bufferIndex >= this.bufferSize) {
this.fill();
if (this.bufferIndex >= this.bufferSize) {
class="kw">return -1;
}
}
char var1 = this.buffer[this.bufferIndex++];
if (var1 == '\n') {
this.line++;
this.lineStart = this.bufferIndex;
}
class="kw">return var1;
}
class="kw">public long skip(long var1) class="kw">throws IOException {
if (var1 < 0L) {
int var9 = -this.bufferIndex;
if (var1 < var9) {
this.bufferIndex = 0;
class="kw">return var9;
} else {
this.bufferIndex += (int)var1;
class="kw">return var1;
}
} else {
long var3 = 0L;
while (var3 < var1) {
long var5 = (long)this.bufferSize - this.bufferIndex;
long var7 = var1 - var3;
if (var7 <= var5) {
this.bufferIndex += (int)var7;
class="kw">return var1;
}
var3 += var5;
this.bufferIndex = this.bufferSize;
this.fill();
if (this.bufferIndex >= this.bufferSize) {
break;
}
}
class="kw">return var3;
}
}
class="kw">public int findOffset(char var1) class="kw">throws IOException {
class="kw">return this.findOffset(0, var1);
}
class="kw">public int findOffset(int var1, char var2) class="kw">throws IOException {
while (true) {
if (this.bufferIndex + var1 >= this.bufferSize) {
if (!this.fillAppend()) {
throw this.unexpectedEOF();
}
} else {
char var3 = this.buffer[this.bufferIndex + var1];
if (var3 == var2) {
class="kw">return var1;
}
var1++;
}
}
}
class="kw">private boolean fillAppend() class="kw">throws IOException {
if (this.in == null) {
class="kw">return false;
}
if (this.bufferSize >= this.buffer.length) {
int var1 = this.buffer.length + 1048576;
char[] var2 = new char[var1];
System.arraycopy(this.buffer, 0, var2, 0, this.bufferSize);
this.buffer = var2;
}
int var3 = this.in.read(this.buffer, this.bufferSize, this.buffer.length - this.bufferSize);
if (var3 > 0) {
this.bufferSize += var3;
class="kw">return true;
} else {
class="kw">return false;
}
}
class="kw">private boolean fillLookAhead() class="kw">throws IOException {
if (this.markIndex > -1) {
class="kw">return this.fillAppend();
} else if (this.fill()) {
class="kw">return true;
} else {
class="kw">return this.bufferSize >= this.buffer.length ? this.fillAppend() : false;
}
}
class="kw">public void skipOrThrow(long var1) class="kw">throws IOException {
long var3 = this.skip(var1);
if (var3 != var1) {
throw new IOException("Failed to skip " + var1 + " char's!");
}
}
class="kw">public boolean ready() class="kw">throws IOException {
class="kw">return this.buffer != null && this.bufferIndex < this.bufferSize || this.in.ready();
}
class="kw">public boolean markSupported() {
class="kw">return true;
}
class="kw">public void mark(int var1) class="kw">throws IOException {
this.mark();
}
class="kw">public boolean isMarked() {
class="kw">return this.markIndex >= 0;
}
class="kw">public void mark() class="kw">throws IOException {
if (this.markIndex >= 0) {
throw new IOException("mark can't be used while already marked!");
}
this.markIndex = this.bufferIndex;
this.markLine = this.line;
this.markLineStart = this.lineStart;
}
class="kw">public void unmark() {
this.markIndex = -1;
this.markLine = -1;
this.markLineStart = -1;
}
class="kw">public int getMarkDistance() {
class="kw">return this.bufferIndex - this.markIndex;
}
class="kw">public char[] cloneMark() {
class="kw">return Arrays.copyOfRange(this.buffer, this.markIndex, this.bufferIndex);
}
class="kw">public void reset() class="kw">throws IOException {
if (this.markIndex < 0) {
throw new IOException("Stream not marked");
}
this.bufferIndex = this.markIndex;
this.markIndex = -1;
this.line = this.markLine;
this.lineStart = this.markLineStart;
this.markLine = -1;
}
@Override
class="kw">public void close() class="kw">throws IOException {
if (this.buffer != null) {
try {
if (this.in != null) {
this.in.close();
}
} class="kw">finally {
this.in = null;
this.buffer = null;
}
}
}
class="kw">public char[] closeAndTakeBuffer() class="kw">throws IOException {
char[] var1 = this.buffer;
this.close();
class="kw">return var1;
}
class="kw">public boolean peekFor(char var1) class="kw">throws IOException {
this.ensure();
class="kw">return this.buffer[this.bufferIndex] == var1;
}
class="kw">public boolean tryConsume(char var1) class="kw">throws IOException {
this.ensure();
if (this.buffer[this.bufferIndex] == var1) {
this.bufferIndex++;
if (var1 == '\n') {
this.line++;
this.lineStart = this.bufferIndex;
}
class="kw">return true;
} else {
class="kw">return false;
}
}
class="kw">public boolean tryConsumeString(@Nonnull String var1) class="kw">throws IOException {
this.mark();
if (this.tryConsume('"') && this.tryConsume(var1) && this.tryConsume('"')) {
this.unmark();
class="kw">return true;
} else {
this.reset();
class="kw">return false;
}
}
class="kw">public boolean tryConsume(@Nonnull String var1) class="kw">throws IOException {
class="kw">return this.tryConsume(var1, 0);
}
class="kw">public boolean tryConsume(@Nonnull String var1, int var2) class="kw">throws IOException {
while (var2 < var1.length()) {
this.ensure();
while (var2 < var1.length() && this.bufferIndex < this.bufferSize) {
char var3 = this.buffer[this.bufferIndex];
if (var3 != var1.charAt(var2++)) {
class="kw">return false;
}
this.bufferIndex++;
if (var3 == '\n') {
this.line++;
this.lineStart = this.bufferIndex;
}
}
}
class="kw">return true;
}
class="kw">public int tryConsumeSome(@Nonnull String var1, int var2) class="kw">throws IOException {
while (var2 < var1.length()) {
this.ensure();
while (var2 < var1.length() && this.bufferIndex < this.bufferSize) {
char var3 = this.buffer[this.bufferIndex];
if (var3 != var1.charAt(var2)) {
class="kw">return var2;
}
var2++;
this.bufferIndex++;
if (var3 == '\n') {
this.line++;
this.lineStart = this.bufferIndex;
}
}
}
class="kw">return var2;
}
class="kw">public void expect(char var1) class="kw">throws IOException {
this.ensure();
char var2 = this.buffer[this.bufferIndex++];
if (var2 != var1) {
throw this.expecting(var2, var1);
}
if (var1 == '\n') {
this.line++;
this.lineStart = this.bufferIndex;
}
}
class="kw">public void expect(@Nonnull String var1, int var2) class="kw">throws IOException {
this.ensure(var1.length() - var2);
while (var2 < var1.length()) {
char var3 = this.buffer[this.bufferIndex];
if (var3 != var1.charAt(var2++)) {
throw this.expecting(var3, var1, var2);
}
this.bufferIndex++;
if (var3 == '\n') {
this.line++;
this.lineStart = this.bufferIndex;
}
}
}
class="kw">public boolean tryConsumeOrExpect(char var1, char var2) class="kw">throws IOException {
this.ensure();
char var3 = this.buffer[this.bufferIndex];
if (var3 == var1) {
this.bufferIndex++;
if (var1 == '\n') {
this.line++;
this.lineStart = this.bufferIndex;
}
class="kw">return true;
} else if (var3 == var2) {
this.bufferIndex++;
if (var2 == '\n') {
this.line++;
this.lineStart = this.bufferIndex;
}
class="kw">return false;
} else {
throw this.expecting(var3, var2);
}
}
class="kw">public void consumeWhiteSpace() class="kw">throws IOException {
while (true) {
if (this.bufferIndex >= this.bufferSize) {
this.fill();
if (this.bufferIndex >= this.bufferSize) {
class="kw">return;
}
}
while (this.bufferIndex < this.bufferSize) {
char var1 = this.buffer[this.bufferIndex];
class="kw">switch (var1) {
case '\t':
case '\r':
case ' ':
this.bufferIndex++;
break;
case '\n':
this.bufferIndex++;
this.line++;
this.lineStart = this.bufferIndex;
break;
class="kw">default:
if (!Character.isWhitespace(var1)) {
class="kw">return;
}
this.bufferIndex++;
}
}
}
}
class="kw">public void consumeIgnoreCase(@Nonnull String var1, int var2) class="kw">throws IOException {
this.ensure(var1.length() - var2);
while (var2 < var1.length()) {
char var3 = this.buffer[this.bufferIndex];
if (!equalsIgnoreCase(var3, var1.charAt(var2++))) {
throw this.expecting(var3, var1, var2);
}
this.bufferIndex++;
if (var3 == '\n') {
this.line++;
this.lineStart = this.bufferIndex;
}
}
}
@Nonnull
class="kw">public String readString() class="kw">throws IOException {
this.expect('"');
class="kw">return this.readRemainingString();
}
@Nonnull
class="kw">public String readRemainingString() class="kw">throws IOException {
this.ensure();
int var1 = this.bufferIndex;
boolean var2 = false;
while (true) {
while (this.bufferIndex >= this.bufferSize) {
this.appendStringRun(var1);
var2 = true;
this.ensure();
var1 = this.bufferIndex;
}
char var3 = this.buffer[this.bufferIndex];
if (var3 == '"') {
if (!var2) {
String var5 = new String(this.buffer, var1, this.bufferIndex - var1);
this.bufferIndex++;
class="kw">return var5;
}
this.appendStringRun(var1);
this.bufferIndex++;
String var4 = this.tempSb.toString();
this.tempSb.setLength(0);
class="kw">return var4;
}
if (var3 == '\\') {
this.appendStringRun(var1);
var2 = true;
this.bufferIndex++;
this.appendEscape();
var1 = this.bufferIndex;
} else {
if (Character.isISOControl(var3)) {
throw this.unexpectedChar(var3);
}
this.bufferIndex++;
}
}
}
class="kw">private void appendStringRun(int var1) {
if (this.tempSb == null) {
this.tempSb = new StringBuilder(1024);
}
this.tempSb.append(this.buffer, var1, this.bufferIndex - var1);
}
class="kw">private void appendEscape() class="kw">throws IOException {
this.ensure();
char var1 = this.buffer[this.bufferIndex++];
class="kw">switch (var1) {
case '"':
case '/':
case '\\':
this.tempSb.append(var1);
break;
case 'b':
this.tempSb.append('\b');
break;
case 'f':
this.tempSb.append('\f');
break;
case 'n':
this.tempSb.append('\n');
break;
case 'r':
this.tempSb.append('\r');
break;
case 't':
this.tempSb.append('\t');
break;
case 'u':
this.ensure(4);
var1 = this.buffer[this.bufferIndex++];
int var2 = Character.digit(var1, 16);
if (var2 == -1) {
throw this.expectingWhile(var1, "HEX Digit 0-F", "reading string");
}
int var3 = var2 << 12;
var1 = this.buffer[this.bufferIndex++];
var2 = Character.digit(var1, 16);
if (var2 == -1) {
throw this.expectingWhile(var1, "HEX Digit 0-F", "reading string");
}
var3 |= var2 << 8;
var1 = this.buffer[this.bufferIndex++];
var2 = Character.digit(var1, 16);
if (var2 == -1) {
throw this.expectingWhile(var1, "HEX Digit 0-F", "reading string");
}
var3 |= var2 << 4;
var1 = this.buffer[this.bufferIndex++];
var2 = Character.digit(var1, 16);
if (var2 == -1) {
throw this.expectingWhile(var1, "HEX Digit 0-F", "reading string");
}
var3 |= var2;
this.tempSb.appendCodePoint(var3);
break;
class="kw">default:
throw this.expecting(var1, "escape char");
}
}
class="kw">public void skipString() class="kw">throws IOException {
this.expect('"');
this.skipRemainingString();
}
class="kw">public void skipRemainingString() class="kw">throws IOException {
while (true) {
this.ensure();
while (this.bufferIndex < this.bufferSize) {
char var1 = this.buffer[this.bufferIndex++];
class="kw">switch (var1) {
case '"':
class="kw">return;
case '\\':
this.ensure();
var1 = this.buffer[this.bufferIndex++];
class="kw">switch (var1) {
case '"':
case '/':
case '\\':
case 'b':
case 'f':
case 'n':
case 'r':
case 't':
class="kw">continue;
case 'u':
this.ensure(4);
var1 = this.buffer[this.bufferIndex++];
int var2 = Character.digit(var1, 16);
if (var2 == -1) {
throw this.expectingWhile(var1, "HEX Digit 0-F", "skipping string");
}
var1 = this.buffer[this.bufferIndex++];
var2 = Character.digit(var1, 16);
if (var2 == -1) {
throw this.expectingWhile(var1, "HEX Digit 0-F", "skipping string");
}
var1 = this.buffer[this.bufferIndex++];
var2 = Character.digit(var1, 16);
if (var2 == -1) {
throw this.expectingWhile(var1, "HEX Digit 0-F", "skipping string");
}
var1 = this.buffer[this.bufferIndex++];
var2 = Character.digit(var1, 16);
if (var2 == -1) {
throw this.expectingWhile(var1, "HEX Digit 0-F", "skipping string");
}
class="kw">continue;
class="kw">default:
throw this.expecting(var1, "escape char");
}
class="kw">default:
if (Character.isISOControl(var1)) {
throw this.unexpectedChar(var1);
}
}
}
}
}
class="kw">public long readStringPartAsLong(int var1) class="kw">throws IOException {
assert var1 > 0 && var1 <= 4;
class="kw">return UnsafeUtil.UNSAFE != null && this.bufferIndex + var1 <= this.bufferSize
? this.readStringPartAsLongUnsafe(var1)
: this.readStringPartAsLongSlow(var1);
}
class="kw">protected long readStringPartAsLongSlow(int var1) class="kw">throws IOException {
this.ensure(var1);
char var2 = this.buffer[this.bufferIndex++];
if (var1 == 1) {
class="kw">return var2;
}
char var3 = this.buffer[this.bufferIndex++];
long var4 = var2 | (long)var3 << 16;
if (var1 == 2) {
class="kw">return var4;
}
char var6 = this.buffer[this.bufferIndex++];
var4 |= (long)var6 << 32;
if (var1 == 3) {
class="kw">return var4;
}
char var7 = this.buffer[this.bufferIndex++];
class="kw">return var4 | (long)var7 << 48;
}
class="kw">protected long readStringPartAsLongUnsafe(int var1) class="kw">throws IOException {
this.ensure(var1);
int var2 = Unsafe.ARRAY_CHAR_BASE_OFFSET + Unsafe.ARRAY_CHAR_INDEX_SCALE * this.bufferIndex;
long var3 = UnsafeUtil.UNSAFE.getLong(this.buffer, var2);
this.bufferIndex += var1;
long var5 = var1 == 4 ? -1L : (1L << var1 * 16) - 1L;
class="kw">return var3 & var5;
}
class="kw">public boolean readBooleanValue() class="kw">throws IOException {
this.ensure(4);
char var1 = this.buffer[this.bufferIndex++];
class="kw">return class="kw">switch (var1) {
case 'F', 'f' -> {
this.consumeIgnoreCase("false", 1);
yield false;
}
case 'T', 't' -> {
this.consumeIgnoreCase("true", 1);
yield true;
}
class="kw">default -> throw this.expecting(var1, "true' or 'false");
};
}
class="kw">public void skipBooleanValue() class="kw">throws IOException {
this.readBooleanValue();
}
@Nullable
class="kw">public Void readNullValue() class="kw">throws IOException {
this.consumeIgnoreCase("null", 0);
class="kw">return null;
}
class="kw">public void skipNullValue() class="kw">throws IOException {
this.consumeIgnoreCase("null", 0);
}
class="kw">public double readDoubleValue() class="kw">throws IOException {
int var1 = 0;
label20:
while (true) {
if (this.bufferIndex + var1 >= this.bufferSize) {
if (!this.fillLookAhead()) {
break;
}
} else {
char var2 = this.buffer[this.bufferIndex + var1];
class="kw">switch (var2) {
case '+':
case '-':
case '.':
case 'E':
case 'e':
var1++;
break;
class="kw">default:
if (!Character.isDigit(var2)) {
break label20;
}
var1++;
}
}
}
double var4 = JavaDoubleParser.parseDouble(this.buffer, this.bufferIndex, var1);
this.bufferIndex += var1;
class="kw">return var4;
}
class="kw">public void skipDoubleValue() class="kw">throws IOException {
while (true) {
if (this.bufferIndex >= this.bufferSize) {
this.fill();
if (this.bufferIndex >= this.bufferSize) {
class="kw">return;
}
}
while (this.bufferIndex < this.bufferSize) {
char var1 = this.buffer[this.bufferIndex];
class="kw">switch (var1) {
case '+':
case '-':
case '.':
case 'E':
case 'e':
this.bufferIndex++;
break;
class="kw">default:
if (!Character.isDigit(var1)) {
class="kw">return;
}
this.bufferIndex++;
}
}
}
}
class="kw">public float readFloatValue() class="kw">throws IOException {
class="kw">return (float)this.readDoubleValue();
}
class="kw">public void skipFloatValue() class="kw">throws IOException {
this.skipDoubleValue();
}
class="kw">public long readLongValue() class="kw">throws IOException {
class="kw">return this.readLongValue(10);
}
class="kw">public long readLongValue(int var1) class="kw">throws IOException {
if (this.tempSb == null) {
this.tempSb = new StringBuilder(1024);
}
while (true) {
if (this.bufferIndex >= this.bufferSize) {
this.fill();
if (this.bufferIndex >= this.bufferSize) {
long var5 = Long.parseLong(this.tempSb, 0, this.tempSb.length(), var1);
this.tempSb.setLength(0);
class="kw">return var5;
}
}
while (this.bufferIndex < this.bufferSize) {
char var2 = this.buffer[this.bufferIndex];
class="kw">switch (var2) {
case '+':
case '-':
case '.':
case 'E':
case 'e':
this.tempSb.append(var2);
this.bufferIndex++;
break;
class="kw">default:
if (Character.digit(var2, var1) < 0) {
long var3 = Long.parseLong(this.tempSb, 0, this.tempSb.length(), var1);
this.tempSb.setLength(0);
class="kw">return var3;
}
this.tempSb.append(var2);
this.bufferIndex++;
}
}
}
}
class="kw">public void skipLongValue() class="kw">throws IOException {
this.skipLongValue(10);
}
class="kw">public void skipLongValue(int var1) class="kw">throws IOException {
while (true) {
if (this.bufferIndex >= this.bufferSize) {
this.fill();
if (this.bufferIndex >= this.bufferSize) {
class="kw">return;
}
}
while (this.bufferIndex < this.bufferSize) {
char var2 = this.buffer[this.bufferIndex];
class="kw">switch (var2) {
case '+':
case '-':
case '.':
case 'E':
case 'e':
this.bufferIndex++;
break;
class="kw">default:
if (Character.digit(var2, var1) < 0) {
class="kw">return;
}
this.bufferIndex++;
}
}
}
}
class="kw">public int readIntValue() class="kw">throws IOException {
class="kw">return this.readIntValue(10);
}
class="kw">public int readIntValue(int var1) class="kw">throws IOException {
class="kw">return (int)this.readLongValue(var1);
}
class="kw">public byte readByteValue() class="kw">throws IOException {
class="kw">return this.readByteValue(10);
}
class="kw">public byte readByteValue(int var1) class="kw">throws IOException {
class="kw">return (byte)this.readLongValue(var1);
}
class="kw">public void skipIntValue() class="kw">throws IOException {
this.skipLongValue();
}
class="kw">public void skipIntValue(int var1) class="kw">throws IOException {
this.skipLongValue(var1);
}
class="kw">public void skipObject() class="kw">throws IOException {
this.expect('{');
this.skipObjectContinued();
}
class="kw">public void skipObjectContinued() class="kw">throws IOException {
int var1 = 1;
while (true) {
this.ensure();
while (this.bufferIndex < this.bufferSize) {
char var2 = this.buffer[this.bufferIndex++];
class="kw">switch (var2) {
case '\n':
this.line++;
this.lineStart = this.bufferIndex;
break;
case '"':
this.skipRemainingString();
break;
case '{':
var1++;
break;
case '}':
if (--var1 == 0) {
class="kw">return;
}
}
}
}
}
class="kw">public void skipArray() class="kw">throws IOException {
this.expect('[');
this.skipArrayContinued();
}
class="kw">public void skipArrayContinued() class="kw">throws IOException {
int var1 = 1;
while (true) {
this.ensure();
while (this.bufferIndex < this.bufferSize) {
char var2 = this.buffer[this.bufferIndex++];
class="kw">switch (var2) {
case '\n':
this.line++;
this.lineStart = this.bufferIndex;
break;
case '"':
this.skipRemainingString();
break;
case '[':
var1++;
break;
case ']':
if (--var1 == 0) {
class="kw">return;
}
}
}
}
}
class="kw">public void skipValue() class="kw">throws IOException {
this.ensure();
char var1 = this.buffer[this.bufferIndex];
class="kw">switch (var1) {
case '"':
this.skipString();
break;
case '+':
case '-':
this.skipDoubleValue();
break;
case 'F':
case 'f':
this.consumeIgnoreCase("false", 0);
break;
case 'N':
case 'n':
this.skipNullValue();
break;
case 'T':
case 't':
this.consumeIgnoreCase("true", 0);
break;
case '[':
this.skipArray();
break;
case '{':
this.skipObject();
break;
class="kw">default:
if (!Character.isDigit(var1)) {
throw this.unexpectedChar(var1);
}
this.skipDoubleValue();
}
}
@Nonnull
class="kw">private IOException unexpectedEOF() {
class="kw">return new IOException("Unexpected EOF!");
}
@Nonnull
class="kw">private IOException unexpectedChar(char var1) {
class="kw">return new IOException("Unexpected character: " + Integer.toHexString(var1) + ", '" + var1 + "'!");
}
@Nonnull
class="kw">private IOException expecting(char var1, char var2) {
class="kw">return new IOException("Unexpected character: " + Integer.toHexString(var1) + ", '" + var1 + "' expected '" + var2 + "'!");
}
@Nonnull
class="kw">private IOException expecting(char var1, String var2) {
class="kw">return new IOException("Unexpected character: " + Integer.toHexString(var1) + ", '" + var1 + "' expected '" + var2 + "'!");
}
@Nonnull
class="kw">private IOException expectingWhile(char var1, String var2, String var3) {
class="kw">return new IOException("Unexpected character: " + Integer.toHexString(var1) + ", '" + var1 + "' expected '" + var2 + "' while " + var3 + "!");
}
@Nonnull
class="kw">private IOException expecting(char var1, @Nonnull String var2, int var3) {
class="kw">return new IOException(
"Unexpected character: "
+ Integer.toHexString(var1)
+ ", '"
+ var1
+ "' when consuming string '"
+ var2
+ "' expected '"
+ var2.substring(var3 - 1)
+ "'!"
);
}
@Nonnull
@Override
class="kw">public String toString() {
if (this.buffer == null) {
class="kw">return "Closed RawJsonReader";
}
StringBuilder var1 = new StringBuilder("Index: ")
.append(this.streamIndex + this.bufferIndex)
.append(", StreamIndex: ")
.append(this.streamIndex)
.append(", BufferIndex: ")
.append(this.bufferIndex)
.append(", BufferSize: ")
.append(this.bufferSize)
.append(", Line: ")
.append(this.line)
.append(", MarkIndex: ")
.append(this.markIndex)
.append(", MarkLine: ")
.append(this.markLine)
.append('\n');
int var2 = this.findLineStart(this.bufferIndex);
int var3;
for (var3 = this.line; var2 > 0 && var3 > this.line - 10; var3--) {
var2 = this.findLineStart(var2);
}
while (var3 < this.line) {
var2 = this.appendLine(var1, var2, var3);
var3++;
}
for (int var4 = this.appendProblemLine(var1, var2, this.line); var4 < this.bufferSize && var3 < this.line + 10; var3++) {
var4 = this.appendLine(var1, var4, var3);
}
class="kw">return this.in == null ? "Buffer RawJsonReader: " + var1 : "Streamed RawJsonReader: " + var1;
}
class="kw">private int findLineStart(int var1) {
var1--;
while (var1 > 0 && this.buffer[var1] != '\n') {
var1--;
}
class="kw">return var1;
}
class="kw">private int appendLine(@Nonnull StringBuilder var1, int var2, int var3) {
int var4 = var2 + 1;
var2++;
while (var2 < this.bufferSize && this.buffer[var2] != '\n') {
var2++;
}
var1.append("L").append(String.format("%3s", var3)).append('|').append(this.buffer, var4, var2 - var4).append('\n');
class="kw">return var2;
}
class="kw">private int appendProblemLine(@Nonnull StringBuilder var1, int var2, int var3) {
int var4 = ++var2;
while (var2 < this.bufferSize && this.buffer[var2] != '\n') {
var2++;
}
var1.append("L").append(String.format("%3s", var3)).append('>').append(this.buffer, var4, var2 - var4).append('\n');
var1.append(" |");
var1.append("-".repeat(Math.max(0, this.bufferIndex - var4 - 1)));
var1.append('^').append('\n');
class="kw">return var2;
}
@Nonnull
class="kw">public class="kw">static RawJsonReader fromRawString(String var0) {
class="kw">return fromJsonString("\"" + var0 + "\"");
}
@Nonnull
class="kw">public class="kw">static RawJsonReader fromJsonString(@Nonnull String var0) {
class="kw">return fromBuffer(var0.toCharArray());
}
@Nonnull
class="kw">public class="kw">static RawJsonReader fromPath(@Nonnull Path var0, @Nonnull char[] var1) class="kw">throws IOException {
class="kw">return new RawJsonReader(new InputStreamReader(Files.newInputStream(var0), StandardCharsets.UTF_8), var1);
}
@Nonnull
class="kw">public class="kw">static RawJsonReader fromBuffer(@Nonnull char[] var0) {
class="kw">return new RawJsonReader(var0);
}
class="kw">public class="kw">static boolean equalsIgnoreCase(char var0, char var1) {
if (var0 == var1) {
class="kw">return true;
}
char var2 = Character.toUpperCase(var0);
char var3 = Character.toUpperCase(var1);
class="kw">return var2 == var3 || Character.toLowerCase(var2) == Character.toLowerCase(var3);
}
@Deprecated
class="kw">public class="kw">static BsonDocument readBsonDocument(@Nonnull RawJsonReader var0) class="kw">throws IOException {
var0.expect('{');
StringBuilder var1 = new StringBuilder("{");
readBsonDocument0(var0, var1);
class="kw">return BsonDocument.parse(var1.toString());
}
class="kw">private class="kw">static void readBsonDocument0(@Nonnull RawJsonReader var0, @Nonnull StringBuilder var1) class="kw">throws IOException {
int var2 = 1;
int var3;
while ((var3 = var0.read()) != -1) {
var1.append((char)var3);
class="kw">switch (var3) {
case 10:
var0.line++;
var0.lineStart = var0.bufferIndex;
break;
case 34:
copyString(var0, var1);
break;
case 91:
readBsonArray0(var0, var1);
break;
case 123:
var2++;
break;
case 125:
if (--var2 == 0) {
class="kw">return;
}
}
}
throw var0.unexpectedEOF();
}
@Deprecated
class="kw">public class="kw">static BsonArray readBsonArray(@Nonnull RawJsonReader var0) class="kw">throws IOException {
var0.expect('[');
StringBuilder var1 = new StringBuilder("[");
readBsonArray0(var0, var1);
class="kw">return BsonArray.parse(var1.toString());
}
class="kw">private class="kw">static void readBsonArray0(@Nonnull RawJsonReader var0, @Nonnull StringBuilder var1) class="kw">throws IOException {
int var2 = 1;
int var3;
while ((var3 = var0.read()) != -1) {
var1.append((char)var3);
class="kw">switch (var3) {
case 10:
var0.line++;
var0.lineStart = var0.bufferIndex;
break;
case 34:
copyString(var0, var1);
break;
case 91:
var2++;
break;
case 93:
if (--var2 == 0) {
class="kw">return;
}
break;
case 123:
readBsonDocument0(var0, var1);
}
}
throw var0.unexpectedEOF();
}
class="kw">private class="kw">static void copyString(@Nonnull RawJsonReader var0, @Nonnull StringBuilder var1) class="kw">throws IOException {
int var2;
while ((var2 = var0.read()) != -1) {
var1.append((char)var2);
if (var2 == 34) {
class="kw">return;
}
if (var2 == 92) {
int var3 = var0.read();
if (var3 != -1) {
var1.append((char)var3);
class="kw">continue;
}
break;
}
}
throw var0.unexpectedEOF();
}
@Deprecated
class="kw">public class="kw">static BsonValue readBsonValue(@Nonnull RawJsonReader var0) class="kw">throws IOException {
int var1 = var0.peek();
if (var1 == -1) {
throw var0.unexpectedEOF();
}
class="kw">return (BsonValue)(class="kw">switch (var1) {
case 34 -> new BsonString(var0.readString());
case 43, 45 -> new BsonDouble(var0.readDoubleValue());
case 70, 84, 102, 116 -> var0.readBooleanValue() ? BsonBoolean.TRUE : BsonBoolean.FALSE;
case 78, 110 -> {
var0.skipNullValue();
yield BsonNull.VALUE;
}
case 91 -> readBsonArray(var0);
case 123 -> readBsonDocument(var0);
class="kw">default -> {
if (!Character.isDigit(var1)) {
throw var0.unexpectedChar((char)var1);
}
yield new BsonDouble(var0.readDoubleValue());
}
});
}
class="kw">public class="kw">static boolean seekToKey(@Nonnull RawJsonReader var0, @Nonnull String var1) class="kw">throws IOException {
var0.consumeWhiteSpace();
var0.expect('{');
var0.consumeWhiteSpace();
if (var0.tryConsume('}')) {
class="kw">return false;
}
while (true) {
var0.expect('"');
if (var0.tryConsume(var1) && var0.tryConsume('"')) {
var0.consumeWhiteSpace();
var0.expect(':');
var0.consumeWhiteSpace();
class="kw">return true;
}
var0.skipRemainingString();
var0.consumeWhiteSpace();
var0.expect(':');
var0.consumeWhiteSpace();
var0.skipValue();
var0.consumeWhiteSpace();
if (var0.tryConsumeOrExpect('}', ',')) {
class="kw">return false;
}
var0.consumeWhiteSpace();
}
}
@Nullable
class="kw">public class="kw">static String seekToKeyFromObjectStart(@Nonnull RawJsonReader var0, @Nonnull String var1, @Nonnull String var2) class="kw">throws IOException {
var0.consumeWhiteSpace();
var0.expect('{');
var0.consumeWhiteSpace();
if (var0.tryConsume('}')) {
class="kw">return null;
}
while (true) {
var0.expect('"');
int var3 = var0.tryConsumeSome(var1, 0);
if (var3 == var1.length() && var0.tryConsume('"')) {
var0.consumeWhiteSpace();
var0.expect(':');
var0.consumeWhiteSpace();
class="kw">return var1;
}
if (var0.tryConsume(var2, var3) && var0.tryConsume('"')) {
var0.consumeWhiteSpace();
var0.expect(':');
var0.consumeWhiteSpace();
class="kw">return var2;
}
var0.skipRemainingString();
var0.consumeWhiteSpace();
var0.expect(':');
var0.consumeWhiteSpace();
var0.skipValue();
var0.consumeWhiteSpace();
if (var0.tryConsumeOrExpect('}', ',')) {
class="kw">return null;
}
var0.consumeWhiteSpace();
}
}
@Nullable
class="kw">public class="kw">static String seekToKeyFromObjectContinued(@Nonnull RawJsonReader var0, @Nonnull String var1, @Nonnull String var2) class="kw">throws IOException {
var0.consumeWhiteSpace();
if (var0.tryConsumeOrExpect('}', ',')) {
class="kw">return null;
}
var0.consumeWhiteSpace();
while (true) {
var0.expect('"');
int var3 = var0.tryConsumeSome(var1, 0);
if (var3 == var1.length() && var0.tryConsume('"')) {
var0.consumeWhiteSpace();
var0.expect(':');
var0.consumeWhiteSpace();
class="kw">return var1;
}
if (var0.tryConsume(var2, var3) && var0.tryConsume('"')) {
var0.consumeWhiteSpace();
var0.expect(':');
var0.consumeWhiteSpace();
class="kw">return var2;
}
var0.skipRemainingString();
var0.consumeWhiteSpace();
var0.expect(':');
var0.consumeWhiteSpace();
var0.skipValue();
var0.consumeWhiteSpace();
if (var0.tryConsumeOrExpect('}', ',')) {
class="kw">return null;
}
var0.consumeWhiteSpace();
}
}
class="kw">public class="kw">static void validateBsonDocument(@Nonnull RawJsonReader var0) class="kw">throws IOException {
var0.expect('{');
var0.consumeWhiteSpace();
if (!var0.tryConsume('}')) {
while (true) {
var0.skipString();
var0.consumeWhiteSpace();
var0.expect(':');
var0.consumeWhiteSpace();
validateBsonValue(var0);
var0.consumeWhiteSpace();
if (var0.tryConsumeOrExpect('}', ',')) {
class="kw">return;
}
var0.consumeWhiteSpace();
}
}
}
class="kw">public class="kw">static void validateBsonArray(@Nonnull RawJsonReader var0) class="kw">throws IOException {
var0.expect('[');
var0.consumeWhiteSpace();
if (!var0.tryConsume(']')) {
while (true) {
validateBsonValue(var0);
var0.consumeWhiteSpace();
if (var0.tryConsumeOrExpect(']', ',')) {
class="kw">return;
}
var0.consumeWhiteSpace();
}
}
}
class="kw">public class="kw">static void validateBsonValue(@Nonnull RawJsonReader var0) class="kw">throws IOException {
int var1 = var0.peek();
if (var1 == -1) {
throw var0.unexpectedEOF();
}
class="kw">switch (var1) {
case 34:
var0.skipString();
break;
case 43:
case 45:
var0.readDoubleValue();
break;
case 70:
case 84:
case 102:
case 116:
var0.readBooleanValue();
break;
case 78:
case 110:
var0.skipNullValue();
break;
case 91:
validateBsonArray(var0);
break;
case 123:
validateBsonDocument(var0);
break;
class="kw">default:
if (Character.isDigit(var1)) {
var0.readDoubleValue();
class="kw">return;
}
throw var0.unexpectedChar((char)var1);
}
}
@Nullable
class="kw">public class="kw">static <T> T readSync(@Nonnull Path var0, @Nonnull Codec<T> var1, @Nonnull HytaleLogger var2) class="kw">throws IOException {
char[] var3 = READ_BUFFER.get();
RawJsonReader var4 = fromPath(var0, var3);
try {
ExtraInfo var5 = ExtraInfo.THREAD_LOCAL.get();
Object var6 = var1.decodeJson(var4, var5);
var5.getValidationResults().logOrThrowValidatorExceptions(var2);
class="kw">return var6;
} class="kw">finally {
char[] var10 = var4.closeAndTakeBuffer();
if (var10.length > var3.length) {
READ_BUFFER.set(var10);
}
}
}
@Nullable
class="kw">public class="kw">static <T> T readSyncWithBak(@Nonnull Path var0, @Nonnull Codec<T> var1, @Nonnull HytaleLogger var2) {
try {
if (Files.size(var0) == 0L) {
throw new IOException("File is empty: " + var0);
} else {
class="kw">return readSync(var0, var1, var2);
}
} catch (IOException var8) {
Path var4 = var0.resolveSibling(var0.getFileName() + ".bak");
if (var8 class="kw">instanceof NoSuchFileException && !Files.exists(var4)) {
class="kw">return null;
}
((HytaleLogger.Api)var2.at(Level.SEVERE).withCause(var8)).log("Failed to load from primary file %s, trying backup file", var0);
try {
if (Files.size(var4) == 0L) {
throw new NoSuchFileException(var4.toString());
}
Object var5 = readSync(var4, var1, var2);
var2.at(Level.WARNING).log("Loaded from backup file %s after primary file %s failed to load", var4, var0);
class="kw">return var5;
} catch (NoSuchFileException var6) {
class="kw">return null;
} catch (IOException var7) {
((HytaleLogger.Api)var2.at(Level.WARNING).withCause(var8)).log("Failed to load from both %s and backup file %s", var0, var4);
class="kw">return null;
}
}
}
}