Package com.google.zxing.oned
Class UPCAReader
- java.lang.Object
-
- com.google.zxing.oned.OneDReader
-
- com.google.zxing.oned.UPCEANReader
-
- com.google.zxing.oned.UPCAReader
-
- All Implemented Interfaces:
Reader
public final class UPCAReader extends UPCEANReader
Implements decoding of the UPC-A format.
-
-
Field Summary
Fields Modifier and Type Field Description private UPCEANReader
ean13Reader
-
Fields inherited from class com.google.zxing.oned.UPCEANReader
END_PATTERN, L_AND_G_PATTERNS, L_PATTERNS, MIDDLE_PATTERN, START_END_PATTERN
-
-
Constructor Summary
Constructors Constructor Description UPCAReader()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Result
decode(BinaryBitmap image)
Locates and decodes a barcode in some format within an image.Result
decode(BinaryBitmap image, java.util.Map<DecodeHintType,?> hints)
Locates and decodes a barcode in some format within an image.protected int
decodeMiddle(BitArray row, int[] startRange, java.lang.StringBuilder resultString)
Subclasses override this to decode the portion of a barcode between the start and end guard patterns.Result
decodeRow(int rowNumber, BitArray row, int[] startGuardRange, java.util.Map<DecodeHintType,?> hints)
LikeUPCEANReader.decodeRow(int, BitArray, Map)
, but allows caller to inform method about where the UPC/EAN start pattern is found.Result
decodeRow(int rowNumber, BitArray row, java.util.Map<DecodeHintType,?> hints)
Attempts to decode a one-dimensional barcode format given a single row of an image.(package private) BarcodeFormat
getBarcodeFormat()
Get the format of this decoder.private static Result
maybeReturnResult(Result result)
-
Methods inherited from class com.google.zxing.oned.UPCEANReader
checkChecksum, checkStandardUPCEANChecksum, decodeDigit, decodeEnd, findGuardPattern, findStartGuardPattern, getStandardUPCEANChecksum
-
Methods inherited from class com.google.zxing.oned.OneDReader
patternMatchVariance, recordPattern, recordPatternInReverse, reset
-
-
-
-
Field Detail
-
ean13Reader
private final UPCEANReader ean13Reader
-
-
Method Detail
-
decodeRow
public Result decodeRow(int rowNumber, BitArray row, int[] startGuardRange, java.util.Map<DecodeHintType,?> hints) throws NotFoundException, FormatException, ChecksumException
Description copied from class:UPCEANReader
Like
UPCEANReader.decodeRow(int, BitArray, Map)
, but allows caller to inform method about where the UPC/EAN start pattern is found. This allows this to be computed once and reused across many implementations.- Overrides:
decodeRow
in classUPCEANReader
- Parameters:
rowNumber
- row index into the imagerow
- encoding of the row of the barcode imagestartGuardRange
- start/end column where the opening start pattern was foundhints
- optional hints that influence decoding- Returns:
Result
encapsulating the result of decoding a barcode in the row- Throws:
NotFoundException
- if no potential barcode is foundFormatException
- if a potential barcode is found but format is invalidChecksumException
- if a potential barcode is found but does not pass its checksum
-
decodeRow
public Result decodeRow(int rowNumber, BitArray row, java.util.Map<DecodeHintType,?> hints) throws NotFoundException, FormatException, ChecksumException
Description copied from class:OneDReader
Attempts to decode a one-dimensional barcode format given a single row of an image.
- Overrides:
decodeRow
in classUPCEANReader
- Parameters:
rowNumber
- row number from top of the rowrow
- the black/white pixel data of the rowhints
- decode hints- Returns:
Result
containing encoded string and start/end of barcode- Throws:
NotFoundException
- if no potential barcode is foundFormatException
- if a potential barcode is found but format is invalidChecksumException
- if a potential barcode is found but does not pass its checksum
-
decode
public Result decode(BinaryBitmap image) throws NotFoundException, FormatException
Description copied from interface:Reader
Locates and decodes a barcode in some format within an image.- Specified by:
decode
in interfaceReader
- Overrides:
decode
in classOneDReader
- Parameters:
image
- image of barcode to decode- Returns:
- String which the barcode encodes
- Throws:
NotFoundException
- if no potential barcode is foundFormatException
- if a potential barcode is found but format is invalid
-
decode
public Result decode(BinaryBitmap image, java.util.Map<DecodeHintType,?> hints) throws NotFoundException, FormatException
Description copied from interface:Reader
Locates and decodes a barcode in some format within an image. This method also accepts hints, each possibly associated to some data, which may help the implementation decode.- Specified by:
decode
in interfaceReader
- Overrides:
decode
in classOneDReader
- Parameters:
image
- image of barcode to decodehints
- passed as aMap
fromDecodeHintType
to arbitrary data. The meaning of the data depends upon the hint type. The implementation may or may not do anything with these hints.- Returns:
- String which the barcode encodes
- Throws:
NotFoundException
- if no potential barcode is foundFormatException
- if a potential barcode is found but format is invalid
-
getBarcodeFormat
BarcodeFormat getBarcodeFormat()
Description copied from class:UPCEANReader
Get the format of this decoder.- Specified by:
getBarcodeFormat
in classUPCEANReader
- Returns:
- The 1D format.
-
decodeMiddle
protected int decodeMiddle(BitArray row, int[] startRange, java.lang.StringBuilder resultString) throws NotFoundException
Description copied from class:UPCEANReader
Subclasses override this to decode the portion of a barcode between the start and end guard patterns.- Specified by:
decodeMiddle
in classUPCEANReader
- Parameters:
row
- row of black/white values to searchstartRange
- start/end offset of start guard patternresultString
-StringBuilder
to append decoded chars to- Returns:
- horizontal offset of first pixel after the "middle" that was decoded
- Throws:
NotFoundException
- if decoding could not complete successfully
-
maybeReturnResult
private static Result maybeReturnResult(Result result) throws FormatException
- Throws:
FormatException
-
-