Fixed some issues with indenting
This commit is contained in:
parent
47e7822177
commit
03e4b583f4
|
@ -49,7 +49,6 @@ public class BdfObject implements IBdfType
|
||||||
|
|
||||||
private String calcIndent(BdfIndent indent, int it) {
|
private String calcIndent(BdfIndent indent, int it) {
|
||||||
String t = "";
|
String t = "";
|
||||||
t += indent.breaker;
|
|
||||||
for(int i=0;i<=it;i++) {
|
for(int i=0;i<=it;i++) {
|
||||||
t += indent.indent;
|
t += indent.indent;
|
||||||
}
|
}
|
||||||
|
@ -81,63 +80,70 @@ public class BdfObject implements IBdfType
|
||||||
if(type == BdfTypes.ARRAY_INTEGER) {
|
if(type == BdfTypes.ARRAY_INTEGER) {
|
||||||
String str = "(" + calcIndent(indent, it);
|
String str = "(" + calcIndent(indent, it);
|
||||||
for(int i : this.getIntegerArray()) {
|
for(int i : this.getIntegerArray()) {
|
||||||
str += Integer.toString(i) + "I, " + calcIndent(indent, it);
|
str += indent.breaker + calcIndent(indent, it) + Integer.toString(i) + "I, ";
|
||||||
}
|
}
|
||||||
str = str.substring(0, str.length() - 2) + ")";
|
str = str.substring(0, str.length() - 2);
|
||||||
|
str += indent.breaker + calcIndent(indent, it - 1) + ")";
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == BdfTypes.ARRAY_BOOLEAN) {
|
if(type == BdfTypes.ARRAY_BOOLEAN) {
|
||||||
String str = "(" + calcIndent(indent, it);
|
String str = "(";
|
||||||
for(boolean i : this.getBooleanArray()) {
|
for(boolean i : this.getBooleanArray()) {
|
||||||
str += (i ? "true" : "false") + ", " + calcIndent(indent, it);
|
str += indent.breaker + calcIndent(indent, it) + (i ? "true" : "false") + ", ";
|
||||||
}
|
}
|
||||||
str = str.substring(0, str.length() - 2) + ")";
|
str = str.substring(0, str.length() - 2);
|
||||||
|
str += indent.breaker + calcIndent(indent, it - 1) + ")";
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == BdfTypes.ARRAY_BYTE) {
|
if(type == BdfTypes.ARRAY_BYTE) {
|
||||||
String str = "(" + calcIndent(indent, it);
|
String str = "(" + calcIndent(indent, it);
|
||||||
for(byte i : this.getByteArray()) {
|
for(byte i : this.getByteArray()) {
|
||||||
str += Byte.toString(i) + "B, " + calcIndent(indent, it);
|
str += indent.breaker + calcIndent(indent, it) + Byte.toString(i) + "B, ";
|
||||||
}
|
}
|
||||||
str = str.substring(0, str.length() - 2) + ")";
|
str = str.substring(0, str.length() - 2);
|
||||||
|
str += indent.breaker + calcIndent(indent, it - 1) + ")";
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == BdfTypes.ARRAY_LONG) {
|
if(type == BdfTypes.ARRAY_LONG) {
|
||||||
String str = "(" + calcIndent(indent, it);
|
String str = "(" + calcIndent(indent, it);
|
||||||
for(long i : this.getLongArray()) {
|
for(long i : this.getLongArray()) {
|
||||||
str += Long.toString(i) + "L, " + calcIndent(indent, it);
|
str += indent.breaker + calcIndent(indent, it) + Long.toString(i) + "L, ";
|
||||||
}
|
}
|
||||||
str = str.substring(0, str.length() - 2) + ")";
|
str = str.substring(0, str.length() - 2);
|
||||||
|
str += indent.breaker + calcIndent(indent, it - 1) + ")";
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == BdfTypes.ARRAY_SHORT) {
|
if(type == BdfTypes.ARRAY_SHORT) {
|
||||||
String str = "(" + calcIndent(indent, it);
|
String str = "(" + calcIndent(indent, it);
|
||||||
for(short i : this.getShortArray()) {
|
for(short i : this.getShortArray()) {
|
||||||
str += Short.toString(i) + "S, " + calcIndent(indent, it);
|
str += indent.breaker + calcIndent(indent, it) + Short.toString(i) + "S, ";
|
||||||
}
|
}
|
||||||
str = str.substring(0, str.length() - 2) + ")";
|
str = str.substring(0, str.length() - 2);
|
||||||
|
str += indent.breaker + calcIndent(indent, it - 1) + ")";
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == BdfTypes.ARRAY_DOUBLE) {
|
if(type == BdfTypes.ARRAY_DOUBLE) {
|
||||||
String str = "(" + calcIndent(indent, it);
|
String str = "(" + calcIndent(indent, it);
|
||||||
for(double i : this.getDoubleArray()) {
|
for(double i : this.getDoubleArray()) {
|
||||||
str += Double.toString(i) + "D, " + calcIndent(indent, it);
|
str += indent.breaker + calcIndent(indent, it) + Double.toString(i) + "D, ";
|
||||||
}
|
}
|
||||||
str = str.substring(0, str.length() - 2) + ")";
|
str = str.substring(0, str.length() - 2);
|
||||||
|
str += indent.breaker + calcIndent(indent, it - 1) + ")";
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == BdfTypes.ARRAY_FLOAT) {
|
if(type == BdfTypes.ARRAY_FLOAT) {
|
||||||
String str = "(" + calcIndent(indent, it);
|
String str = "(" + calcIndent(indent, it);
|
||||||
for(float i : this.getFloatArray()) {
|
for(float i : this.getFloatArray()) {
|
||||||
str += Float.toString(i) + "F, " + calcIndent(indent, it);
|
str += indent.breaker + calcIndent(indent, it) + Float.toString(i) + "F, ";
|
||||||
}
|
}
|
||||||
str = str.substring(0, str.length() - 2) + ")";
|
str = str.substring(0, str.length() - 2);
|
||||||
|
str += indent.breaker + calcIndent(indent, it - 1) + ")";
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class Tests {
|
||||||
nl.set("int_array", BdfObject.withIntegerArray(array));
|
nl.set("int_array", BdfObject.withIntegerArray(array));
|
||||||
nl.set("array", BdfObject.withArray(array_bdf));
|
nl.set("array", BdfObject.withArray(array_bdf));
|
||||||
|
|
||||||
System.out.println(bdf.serializeHumanReadable(new BdfIndent(" ", "\n")));
|
System.out.println(bdf.serializeHumanReadable(new BdfIndent("\t", "\n")));
|
||||||
|
|
||||||
bdf.saveDatabase();
|
bdf.saveDatabase();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue