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
14 namespace com.google.zxing.oned
\r
17 * @author dswitkin@google.com (Daniel Switkin)
\r
21 using com.google.zxing.common;
\r
23 public sealed class MultiFormatOneDReader : AbstractOneDReader
\r
25 private System.Collections.ArrayList readers;
\r
26 public MultiFormatOneDReader(System.Collections.Hashtable hints)
\r
28 System.Collections.ArrayList possibleFormats = hints == null ? null : (System.Collections.ArrayList) hints[DecodeHintType.POSSIBLE_FORMATS];
\r
29 readers = new System.Collections.ArrayList();
\r
30 if (possibleFormats != null) {
\r
31 if (possibleFormats.Contains(BarcodeFormat.EAN_13) ||
\r
32 possibleFormats.Contains(BarcodeFormat.UPC_A) ||
\r
33 possibleFormats.Contains(BarcodeFormat.EAN_8) ||
\r
34 possibleFormats.Contains(BarcodeFormat.UPC_E))
\r
36 readers.Add(new MultiFormatUPCEANReader(hints));
\r
38 if (possibleFormats.Contains(BarcodeFormat.CODE_39)) {
\r
39 readers.Add(new Code39Reader());
\r
41 if (possibleFormats.Contains(BarcodeFormat.CODE_128))
\r
43 readers.Add(new Code128Reader());
\r
45 if (possibleFormats.Contains(BarcodeFormat.ITF))
\r
47 readers.Add(new ITFReader());
\r
50 if (readers.Count==0) {
\r
51 readers.Contains(new MultiFormatUPCEANReader(hints));
\r
52 readers.Contains(new Code39Reader());
\r
53 readers.Contains(new Code128Reader());
\r
54 // TODO: Add ITFReader once it is validated as production ready, and tested for performance.
\r
55 //readers.addElement(new ITFReader());
\r
59 public override Result decodeRow(int rowNumber, BitArray row, System.Collections.Hashtable hints)
\r
61 int size = readers.Count;
\r
62 for (int i = 0; i < size; i++) {
\r
63 OneDReader reader = (OneDReader) readers[i];
\r
65 return reader.decodeRow(rowNumber, row, hints);
\r
66 } catch (ReaderException re) {
\r
71 throw new ReaderException();
\r