Added handy toString() methods

git-svn-id: https://zxing.googlecode.com/svn/trunk@401 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2008-05-23 22:20:10 +00:00
parent 5c705313bb
commit c2c8b2fcfb
2 changed files with 22 additions and 0 deletions

View file

@ -153,5 +153,16 @@ public final class BitArray {
}
return new int[arraySize];
}
public String toString() {
StringBuffer result = new StringBuffer(size);
for (int i = 0; i < size; i++) {
if (i % 8 == 0) {
result.append(' ');
}
result.append(get(i) ? 'X' : '.');
}
return result.toString();
}
}

View file

@ -115,4 +115,15 @@ public final class BitMatrix {
return bits;
}
public String toString() {
StringBuffer result = new StringBuffer(dimension * (dimension + 1));
for (int i = 0; i < dimension; i++) {
for (int j = 0; j < dimension; j++) {
result.append(get(i, j) ? 'X' : ' ');
}
result.append('\n');
}
return result.toString();
}
}