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