mirror of
https://github.com/Team4388/RidgeScout.git
synced 2026-06-09 08:38:03 -06:00
Work on adding blankable fields
This commit is contained in:
@@ -4,10 +4,11 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class BuiltByteParser {
|
||||
public static final Integer intType = 0;
|
||||
public static final Integer stringType = 1;
|
||||
public static final Integer intArrayType = 2;
|
||||
public static final Integer stringArrayType = 3;
|
||||
public static final Integer boolType = 0;
|
||||
public static final Integer intType = 1;
|
||||
public static final Integer stringType = 2;
|
||||
public static final Integer intArrayType = 3;
|
||||
public static final Integer stringArrayType = 4;
|
||||
|
||||
public class byteParsingExeption extends Exception {
|
||||
public byteParsingExeption() {}
|
||||
@@ -22,6 +23,11 @@ public class BuiltByteParser {
|
||||
public abstract Object get();
|
||||
}
|
||||
|
||||
public class boolObject extends parsedObject{
|
||||
boolean val;
|
||||
public Integer getType(){return boolType;}
|
||||
public Object get(){return val;}
|
||||
}
|
||||
|
||||
public class intObject extends parsedObject{
|
||||
int num;
|
||||
@@ -83,16 +89,21 @@ public class BuiltByteParser {
|
||||
|
||||
switch(type){
|
||||
case 0:
|
||||
boolObject bo = new boolObject();
|
||||
bo.val = block[0] == (byte) 1;
|
||||
objects.add(bo);
|
||||
break;
|
||||
case 1:
|
||||
intObject io = new intObject();
|
||||
io.num = fileEditor.fromBytes(block, length);
|
||||
objects.add(io);
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
stringObject so = new stringObject();
|
||||
so.str = new String(block, StandardCharsets.UTF_8);
|
||||
objects.add(so);
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
BuiltByteParser int_bbp = new BuiltByteParser(block);
|
||||
ArrayList<parsedObject> intArrayObjects = int_bbp.parse();
|
||||
|
||||
@@ -106,7 +117,7 @@ public class BuiltByteParser {
|
||||
ia.arr = intArr;
|
||||
objects.add(ia);
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
|
||||
BuiltByteParser str_bbp = new BuiltByteParser(block);
|
||||
ArrayList<parsedObject> strArrayObjects = str_bbp.parse();
|
||||
|
||||
@@ -4,10 +4,11 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ByteBuilder {
|
||||
public static final int int_id = 0;
|
||||
public static final int string_id = 1;
|
||||
public static final int int_arr_id = 2;
|
||||
public static final int string_arr_id = 3;
|
||||
public static final int bool_id = 0;
|
||||
public static final int int_id = 1;
|
||||
public static final int string_id = 2;
|
||||
public static final int int_arr_id = 3;
|
||||
public static final int string_arr_id = 4;
|
||||
|
||||
ArrayList<byteType> bytesToBuild = new ArrayList<>();
|
||||
|
||||
@@ -24,6 +25,23 @@ public class ByteBuilder {
|
||||
public abstract byte[] build();
|
||||
}
|
||||
|
||||
private class boolType extends byteType {
|
||||
public boolean val;
|
||||
public byte getType(){return bool_id;}
|
||||
public int length(){return 1;}
|
||||
public byte[] build(){
|
||||
return new byte[]{(byte) (val ? 1 : 0)};
|
||||
}
|
||||
}
|
||||
|
||||
public ByteBuilder addBool(boolean n) throws buildingException {
|
||||
boolType boolType = new boolType();
|
||||
boolType.val = n;
|
||||
|
||||
bytesToBuild.add(boolType);
|
||||
return this;
|
||||
}
|
||||
|
||||
private class intType extends byteType {
|
||||
public int precision;
|
||||
public int num;
|
||||
|
||||
Reference in New Issue
Block a user