2 * Licensed under the Apache License, Version 2.0 (the "License");
\r
3 * you may not use this file except in compliance with the License.
\r
4 * You may obtain a copy of the License at
\r
6 * http://www.apache.org/licenses/LICENSE-2.0
\r
8 * Unless required by applicable law or agreed to in writing, software
\r
9 * distributed under the License is distributed on an "AS IS" BASIS,
\r
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
11 * See the License for the specific language governing permissions and
\r
12 * limitations under the License.
\r
16 using System.Collections;
\r
18 namespace com.google.zxing
\r
21 /// <summary> The general exception class throw when something goes wrong during decoding of a barcode.
\r
22 /// This includes, but is not limited to, failing checksums / error correction algorithms, being
\r
23 /// unable to locate finder timing patterns, and so on.
\r
26 /// <author> srowen@google.com (Sean Owen)
\r
29 public sealed class Result
\r
31 private String text;
\r
32 private sbyte[] rawBytes;
\r
33 private ResultPoint[] resultPoints;
\r
34 private BarcodeFormat format;
\r
35 private Hashtable resultMetadata;
\r
37 public Result(String text,
\r
39 ResultPoint[] resultPoints,
\r
40 BarcodeFormat format) {
\r
41 if (text == null && rawBytes == null) {
\r
42 throw new ArgumentException("Text and bytes are null");
\r
45 this.rawBytes = rawBytes;
\r
46 this.resultPoints = resultPoints;
\r
47 this.format = format;
\r
48 this.resultMetadata = null;
\r
52 * @return raw text encoded by the barcode, if applicable, otherwise <code>null</code>
\r
54 public String getText() {
\r
59 * @return raw bytes encoded by the barcode, if applicable, otherwise <code>null</code>
\r
61 public sbyte[] getRawBytes() {
\r
66 * @return points related to the barcode in the image. These are typically points
\r
67 * identifying finder patterns or the corners of the barcode. The exact meaning is
\r
68 * specific to the type of barcode that was decoded.
\r
70 public ResultPoint[] getResultPoints() {
\r
71 return resultPoints;
\r
75 * @return {@link BarcodeFormat} representing the format of the barcode that was recognized and decoded
\r
77 public BarcodeFormat getBarcodeFormat() {
\r
82 * @return {@link Hashtable} mapping {@link ResultMetadataType} keys to values. May be <code>null</code>.
\r
83 * This contains optional metadata about what was detected about the barcode, like orientation.
\r
85 public Hashtable getResultMetadata() {
\r
86 return resultMetadata;
\r
89 public void putMetadata(ResultMetadataType type, Object value) {
\r
90 if (resultMetadata == null) {
\r
91 resultMetadata = new Hashtable(3);
\r
93 resultMetadata.Add(type, value);
\r
96 public String toString() {
\r
98 return "[" + rawBytes.Length + " bytes]";
\r