2 * Copyright 2008 Google Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.google.zxing.oned;
19 import com.google.zxing.ReaderException;
20 import com.google.zxing.Result;
21 import com.google.zxing.common.BitArray;
24 * <p>A reader that can read all available UPC/EAN formats. If a caller wants to try to
25 * read all such formats, it is most efficent to use this implementation rather than invoke
26 * individual readers.</p>
28 * @author srowen@google.com (Sean Owen)
30 public final class MultiFormatUPCEANReader extends AbstractOneDReader {
33 * Reader implementations to which this implementation delegates, in the order
34 * they will be attempted. Order is important.
36 private final UPCEANReader[] readers = new UPCEANReader[]{
37 new EAN13Reader(), new UPCAReader(), new EAN8Reader(), new UPCEReader()
40 public Result decodeRow(int rowNumber, BitArray row) throws ReaderException {
41 // Compute this location once and reuse it on multiple implementations
42 int[] startGuardPattern = AbstractUPCEANReader.findStartGuardPattern(row);
43 ReaderException saved = null;
44 for (int i = 0; i < readers.length; i++) {
46 return readers[i].decodeRow(rowNumber, row, startGuardPattern);
47 } catch (ReaderException re) {