Marginal improvement to datamatrix decoder
[zxing.git] / core / src / com / google / zxing / Result.java
index a320673..8a798f0 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.
@@ -21,7 +21,7 @@ import java.util.Hashtable;
 /**
  * <p>Encapsulates the result of decoding a barcode within an image.</p>
  *
- * @author srowen@google.com (Sean Owen)
+ * @author Sean Owen
  */
 public final class Result {
 
@@ -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;
+    }
+  }
+
 }