Add BIZCARD support and a little refactoring
[zxing.git] / core / src / com / google / zxing / Result.java
index a320673..80fb7f4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007 Google Inc.
+ * Copyright 2007 ZXing authors
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -35,6 +35,9 @@ public final class Result {
                 byte[] rawBytes,
                 ResultPoint[] resultPoints,
                 BarcodeFormat format) {
+    if (text == null && rawBytes == null) {
+      throw new IllegalArgumentException("Text and bytes are null");
+    }
     this.text = text;
     this.rawBytes = rawBytes;
     this.resultPoints = resultPoints;
@@ -87,4 +90,12 @@ public final class Result {
     resultMetadata.put(type, value);
   }
 
+  public String toString() {
+    if (text == null) {
+      return "[" + rawBytes.length + " bytes]";
+    } else {
+      return text;
+    }
+  }
+
 }