From fec26ca2a847816d47f365a1aacad11dc3be4e23 Mon Sep 17 00:00:00 2001 From: srowen Date: Fri, 23 May 2008 22:20:10 +0000 Subject: [PATCH] Added handy toString() methods git-svn-id: http://zxing.googlecode.com/svn/trunk@401 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- core/src/com/google/zxing/common/BitArray.java | 11 +++++++++++ core/src/com/google/zxing/common/BitMatrix.java | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/core/src/com/google/zxing/common/BitArray.java b/core/src/com/google/zxing/common/BitArray.java index c22fd925..71529470 100644 --- a/core/src/com/google/zxing/common/BitArray.java +++ b/core/src/com/google/zxing/common/BitArray.java @@ -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(); + } } \ No newline at end of file diff --git a/core/src/com/google/zxing/common/BitMatrix.java b/core/src/com/google/zxing/common/BitMatrix.java index cbb58504..d06c28b5 100755 --- a/core/src/com/google/zxing/common/BitMatrix.java +++ b/core/src/com/google/zxing/common/BitMatrix.java @@ -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(); + } + } -- 2.20.1