sync with jwo
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
5
src/main/java9/module-info.java
Normal file
5
src/main/java9/module-info.java
Normal file
@@ -0,0 +1,5 @@
|
||||
module net.woggioni.wson {
|
||||
exports net.woggioni.wson.xface;
|
||||
exports net.woggioni.wson.value;
|
||||
exports net.woggioni.wson.exception;
|
||||
}
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user