diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/Base2Terminator.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/Base2Terminator.java index 2c25c7f6..98d5911f 100644 --- a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/Base2Terminator.java +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/Base2Terminator.java @@ -8,6 +8,7 @@ import java.util.Iterator; import java.util.List; import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ; +import love.distributedrebirth.bassboonyd.BãßBȍőnEnumInstanceʸᴰ; import love.distributedrebirth.numberxd.base2t.part.T08PartOctal; import love.distributedrebirth.numberxd.base2t.type.V048Tong; import love.distributedrebirth.numberxd.base2t.type.V090Tocta; @@ -16,55 +17,58 @@ import love.distributedrebirth.numberxd.base2t.type.V090Tocta; * Terminate from and to classical bytes. */ @BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天") -public class Base2Terminator { +public enum Base2Terminator implements BãßBȍőnEnumInstanceʸᴰ { + + INSTANCE; + private static final int STREAM_EOF = -1; private static final int BLOCK_TONG_SIZE = 9; private static final int BLOCK_TOCTA_SIZE = 18; private static final int SHIFT_8 = 8; private static final int SHIFT_16 = 16; - public int base2ReadTong(InputStream input, List output) throws IOException { + public int Bãß2ReadTong(InputStream input, List output) throws IOException { int totalBytes = 0; byte[] data = new byte[BLOCK_TONG_SIZE]; int readDataSize = 0; // per 9 bytes we have 24 octals for one V072Tong number while ((readDataSize = input.read(data, 0, data.length)) != STREAM_EOF) { - base2ReadCheckSize(readDataSize, BLOCK_TONG_SIZE); + Bãß2ReadCheckSize(readDataSize, BLOCK_TONG_SIZE); int v0 = data[0] + (data[1] << SHIFT_8) + (data[2] << SHIFT_16); int v1 = data[3] + (data[4] << SHIFT_8) + (data[5] << SHIFT_16); int v2 = data[6] + (data[7] << SHIFT_8) + (data[8] << SHIFT_16); - List octals = base2ReadOctals(v0, v1, v2); + List octals = Bãß2ReadOctals(v0, v1, v2); output.add(new V048Tong(new BaseIteratorOctal(octals.iterator()))); totalBytes += BLOCK_TONG_SIZE; } return totalBytes; } - public int base2ReadTocta(InputStream input, List output) throws IOException { + public int Bãß2ReadTocta(InputStream input, List output) throws IOException { int totalBytes = 0; byte[] data = new byte[BLOCK_TOCTA_SIZE]; int readDataSize = 0; // per 18 bytes we have 48 octals for one V144Tocta number while ((readDataSize = input.read(data, 0, data.length)) != STREAM_EOF) { - base2ReadCheckSize(readDataSize, BLOCK_TOCTA_SIZE); + Bãß2ReadCheckSize(readDataSize, BLOCK_TOCTA_SIZE); int v0 = data[0] + (data[1] << SHIFT_8) + (data[2] << SHIFT_16); int v1 = data[3] + (data[4] << SHIFT_8) + (data[5] << SHIFT_16); int v2 = data[6] + (data[7] << SHIFT_8) + (data[8] << SHIFT_16); int v3 = data[9] + (data[10] << SHIFT_8) + (data[11] << SHIFT_16); int v4 = data[12] + (data[13] << SHIFT_8) + (data[14] << SHIFT_16); int v5 = data[15] + (data[16] << SHIFT_8) + (data[17] << SHIFT_16); - List octals = base2ReadOctals(v0, v1, v2, v3, v4, v5); + List octals = Bãß2ReadOctals(v0, v1, v2, v3, v4, v5); output.add(new V090Tocta(new BaseIteratorOctal(octals.iterator()))); totalBytes += BLOCK_TOCTA_SIZE; } return totalBytes; } - private void base2ReadCheckSize(int readDataSize, int expectedSize) throws IOException { + private void Bãß2ReadCheckSize(int readDataSize, int expectedSize) throws IOException { if (readDataSize < expectedSize) { throw new IOException("Expected "+expectedSize+" bytes, got: "+readDataSize); } } - private List base2ReadOctals(int...values) { + private List Bãß2ReadOctals(int...values) { List octals = new ArrayList<>(); for (int value:values) { T08PartOctal.PART_1.BãßVoorElk(v -> octals.add(T08PartOctal.indexOf(v, value))); @@ -72,15 +76,15 @@ public class Base2Terminator { return octals; } - public int base2WriteTong(List data, OutputStream output) throws IOException { - return base2Write(data, output); + public int Bãß2WriteTong(List data, OutputStream output) throws IOException { + return Bãß2Write(data, output); } - public int base2WriteTocta(List data, OutputStream output) throws IOException { - return base2Write(data, output); + public int Bãß2WriteTocta(List data, OutputStream output) throws IOException { + return Bãß2Write(data, output); } - private > int base2Write(List data, OutputStream output) throws IOException { + private > int Bãß2Write(List data, OutputStream output) throws IOException { int totalBytes = 0; // per 8 octa's is 3 bytes List octals = new ArrayList<>(); BaseAppenderOctal appender = new BaseAppenderOctal(octals);