Class BitMatrixParser
- java.lang.Object
-
- com.google.zxing.datamatrix.decoder.BitMatrixParser
-
final class BitMatrixParser extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private BitMatrix
mappingBitMatrix
private BitMatrix
readMappingMatrix
private Version
version
-
Constructor Summary
Constructors Constructor Description BitMatrixParser(BitMatrix bitMatrix)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private BitMatrix
extractDataRegion(BitMatrix bitMatrix)
Extracts the data region from aBitMatrix
that contains alignment patterns.(package private) Version
getVersion()
(package private) byte[]
readCodewords()
Reads the bits in theBitMatrix
representing the mapping matrix (No alignment patterns) in the correct order in order to reconstitute the codewords bytes contained within the Data Matrix Code.private int
readCorner1(int numRows, int numColumns)
Reads the 8 bits of the special corner condition 1.private int
readCorner2(int numRows, int numColumns)
Reads the 8 bits of the special corner condition 2.private int
readCorner3(int numRows, int numColumns)
Reads the 8 bits of the special corner condition 3.private int
readCorner4(int numRows, int numColumns)
Reads the 8 bits of the special corner condition 4.private boolean
readModule(int row, int column, int numRows, int numColumns)
Reads a bit of the mapping matrix accounting for boundary wrapping.private int
readUtah(int row, int column, int numRows, int numColumns)
Reads the 8 bits of the standard Utah-shaped pattern.private static Version
readVersion(BitMatrix bitMatrix)
Creates the version object based on the dimension of the original bit matrix from the datamatrix code.
-
-
-
Constructor Detail
-
BitMatrixParser
BitMatrixParser(BitMatrix bitMatrix) throws FormatException
- Parameters:
bitMatrix
-BitMatrix
to parse- Throws:
FormatException
- if dimension is < 8 or > 144 or not 0 mod 2
-
-
Method Detail
-
getVersion
Version getVersion()
-
readVersion
private static Version readVersion(BitMatrix bitMatrix) throws FormatException
Creates the version object based on the dimension of the original bit matrix from the datamatrix code.
See ISO 16022:2006 Table 7 - ECC 200 symbol attributes
- Parameters:
bitMatrix
- OriginalBitMatrix
including alignment patterns- Returns:
Version
encapsulating the Data Matrix Code's "version"- Throws:
FormatException
- if the dimensions of the mapping matrix are not valid Data Matrix dimensions.
-
readCodewords
byte[] readCodewords() throws FormatException
Reads the bits in the
BitMatrix
representing the mapping matrix (No alignment patterns) in the correct order in order to reconstitute the codewords bytes contained within the Data Matrix Code.- Returns:
- bytes encoded within the Data Matrix Code
- Throws:
FormatException
- if the exact number of bytes expected is not read
-
readModule
private boolean readModule(int row, int column, int numRows, int numColumns)
Reads a bit of the mapping matrix accounting for boundary wrapping.
- Parameters:
row
- Row to read in the mapping matrixcolumn
- Column to read in the mapping matrixnumRows
- Number of rows in the mapping matrixnumColumns
- Number of columns in the mapping matrix- Returns:
- value of the given bit in the mapping matrix
-
readUtah
private int readUtah(int row, int column, int numRows, int numColumns)
Reads the 8 bits of the standard Utah-shaped pattern.
See ISO 16022:2006, 5.8.1 Figure 6
- Parameters:
row
- Current row in the mapping matrix, anchored at the 8th bit (LSB) of the patterncolumn
- Current column in the mapping matrix, anchored at the 8th bit (LSB) of the patternnumRows
- Number of rows in the mapping matrixnumColumns
- Number of columns in the mapping matrix- Returns:
- byte from the utah shape
-
readCorner1
private int readCorner1(int numRows, int numColumns)
Reads the 8 bits of the special corner condition 1.
See ISO 16022:2006, Figure F.3
- Parameters:
numRows
- Number of rows in the mapping matrixnumColumns
- Number of columns in the mapping matrix- Returns:
- byte from the Corner condition 1
-
readCorner2
private int readCorner2(int numRows, int numColumns)
Reads the 8 bits of the special corner condition 2.
See ISO 16022:2006, Figure F.4
- Parameters:
numRows
- Number of rows in the mapping matrixnumColumns
- Number of columns in the mapping matrix- Returns:
- byte from the Corner condition 2
-
readCorner3
private int readCorner3(int numRows, int numColumns)
Reads the 8 bits of the special corner condition 3.
See ISO 16022:2006, Figure F.5
- Parameters:
numRows
- Number of rows in the mapping matrixnumColumns
- Number of columns in the mapping matrix- Returns:
- byte from the Corner condition 3
-
readCorner4
private int readCorner4(int numRows, int numColumns)
Reads the 8 bits of the special corner condition 4.
See ISO 16022:2006, Figure F.6
- Parameters:
numRows
- Number of rows in the mapping matrixnumColumns
- Number of columns in the mapping matrix- Returns:
- byte from the Corner condition 4
-
-