sync with jwo

This commit is contained in:
2021-08-14 09:24:53 +02:00
parent 605e1ad644
commit 47c33036d1
12 changed files with 29 additions and 97 deletions

View File

@@ -1,39 +0,0 @@
package net.woggioni.wson.buffer;
import lombok.SneakyThrows;
import java.io.InputStream;
public class LookAheadInputStream extends InputStream {
private final byte[] buffer = new byte[1024];
private final InputStream stream;
private int bufferFill = -1;
private int cursor = -1;
private int currentByte;
public LookAheadInputStream(InputStream stream) {
this.stream = stream;
}
@Override
@SneakyThrows
public int read() {
if (cursor > bufferFill) {
return -1;
} else if (cursor == bufferFill) {
do {
bufferFill = stream.read(buffer, 0, buffer.length) - 1;
cursor = 0;
} while(bufferFill == -1);
currentByte = bufferFill == -2 ? -1 : Math.floorMod(buffer[0], 256);
} else {
currentByte = Math.floorMod(buffer[++cursor], 256);
}
return currentByte;
}
public int getCurrentByte() {
return currentByte;
}
}

View File

@@ -1,41 +0,0 @@
package net.woggioni.wson.buffer;
import lombok.SneakyThrows;
import java.io.InputStream;
import java.io.Reader;
public class LookAheadTextInputStream extends InputStream {
private final char[] buffer = new char[1024];
private final Reader reader;
private int bufferFill = -1;
private int cursor = -1;
private int currentChar;
public LookAheadTextInputStream(Reader reader) {
this.reader = reader;
}
@Override
@SneakyThrows
public int read() {
if (cursor > bufferFill) {
return -1;
} else if (cursor == bufferFill) {
do {
bufferFill = reader.read(buffer, 0, buffer.length) - 1;
cursor = 0;
} while(bufferFill == -1);
currentChar = bufferFill == -2 ? -1 : buffer[0];
} else {
currentChar = buffer[++cursor];
}
return currentChar;
}
public int getCurrentByte() {
return currentChar;
}
}

View File

@@ -2,7 +2,7 @@ package net.woggioni.wson.serialization.binary;
import lombok.SneakyThrows;
import net.woggioni.jwo.Leb128;
import net.woggioni.wson.buffer.LookAheadInputStream;
import net.woggioni.jwo.LookAheadInputStream;
import net.woggioni.wson.exception.ParseException;
import net.woggioni.wson.serialization.ValueParser;
import net.woggioni.wson.xface.Parser;

View File

@@ -1,7 +1,7 @@
package net.woggioni.wson.serialization.json;
import lombok.SneakyThrows;
import net.woggioni.wson.buffer.LookAheadTextInputStream;
import net.woggioni.jwo.LookAheadTextInputStream;
import net.woggioni.wson.exception.IOException;
import net.woggioni.wson.exception.NotImplementedException;
import net.woggioni.wson.exception.ParseException;

View File

@@ -0,0 +1,5 @@
module net.woggioni.wson {
exports net.woggioni.wson.xface;
exports net.woggioni.wson.value;
exports net.woggioni.wson.exception;
}

View File

@@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.JsonNodeType;
import lombok.SneakyThrows;
import net.woggioni.wson.buffer.LookAheadTextInputStream;
import net.woggioni.jwo.LookAheadTextInputStream;
import net.woggioni.wson.exception.NotImplementedException;
import net.woggioni.wson.value.ArrayValue;
import net.woggioni.wson.value.ObjectValue;

View File

@@ -2,9 +2,9 @@ package net.woggioni.wson.traversal;
import lombok.SneakyThrows;
import net.woggioni.jwo.JWO;
import net.woggioni.jwo.Tuple2;
import net.woggioni.wson.serialization.json.JSONParser;
import net.woggioni.wson.serialization.json.JSONTest;
import net.woggioni.jwo.tuple.Tuple2;
import net.woggioni.wson.value.ArrayValue;
import net.woggioni.wson.value.ObjectValue;
import net.woggioni.wson.xface.Parser;

View File

@@ -1,6 +1,6 @@
package net.woggioni.wson.value;
import net.woggioni.jwo.tuple.Tuple2;
import net.woggioni.jwo.Tuple2;
import net.woggioni.wson.xface.Value;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;