Package com.itextpdf.barcodes.qrcode
Class QRCode
- java.lang.Object
-
- com.itextpdf.barcodes.qrcode.QRCode
-
final class QRCode extends java.lang.Object
A QR code (short for "quick-response code") is a type of two-dimensional matrix barcode, invented in 1994, by Japanese company Denso Wave for labelling automobile parts.[1][2] A barcode is a machine-readable optical image that contains information specific to the labelled item. In practice, QR codes contain data for a locator, an identifier, and web tracking. To efficiently store data, QR codes use four standardized modes of encoding (i) numeric, (ii) alphanumeric, (iii) byte or binary, and (iv) kanji.[3]
-
-
Field Summary
Fields Modifier and Type Field Description private ErrorCorrectionLevel
ecLevel
private int
maskPattern
private ByteMatrix
matrix
private int
matrixWidth
private Mode
mode
static int
NUM_MASK_PATTERNS
private int
numDataBytes
private int
numECBytes
private int
numRSBlocks
private int
numTotalBytes
private int
version
-
Constructor Summary
Constructors Constructor Description QRCode()
Create a QR-code object with unitialized parameters
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
at(int x, int y)
Retrieve the value of the module (cell) pointed by "x" and "y" in the matrix of the QR Code.ErrorCorrectionLevel
getECLevel()
Possible error correction level values ranked from lowest error correction capability to highest: L, M, Q, Hint
getMaskPattern()
ByteMatrix
getMatrix()
int
getMatrixWidth()
Mode
getMode()
Mode used by the QR code to encode data into bits.int
getNumDataBytes()
int
getNumECBytes()
int
getNumRSBlocks()
int
getNumTotalBytes()
int
getVersion()
Together with error correction level, the version determines the information capacity of the QR code.boolean
isValid()
Check the validity of all member variablesstatic boolean
isValidMaskPattern(int maskPattern)
Check if "mask_pattern" is valid.void
setECLevel(ErrorCorrectionLevel value)
Set the error correction level of th QR code.void
setMaskPattern(int value)
Set the masking patternvoid
setMatrix(ByteMatrix value)
Set the byte-matrixvoid
setMatrixWidth(int value)
Sets the width of the byte matrixvoid
setMode(Mode value)
Set the data encoding mode of the QR code Possible modes: TERMINATOR, NUMERIC, ALPHANUMERIC, STRUCTURED_APPEND, BYTE, ECI, KANJI, FNC1_FIRST_POSITION, FNC2_SECOND_POSITIONvoid
setNumDataBytes(int value)
Set the number of data bytesvoid
setNumECBytes(int value)
Set the number of error correction blocksvoid
setNumRSBlocks(int value)
Set the number of Reed-Solomon blocksvoid
setNumTotalBytes(int value)
Set the number of total bytesvoid
setVersion(int value)
Set the version of the QR code.java.lang.String
toString()
Prints all parameters
-
-
-
Field Detail
-
NUM_MASK_PATTERNS
public static final int NUM_MASK_PATTERNS
- See Also:
- Constant Field Values
-
mode
private Mode mode
-
ecLevel
private ErrorCorrectionLevel ecLevel
-
version
private int version
-
matrixWidth
private int matrixWidth
-
maskPattern
private int maskPattern
-
numTotalBytes
private int numTotalBytes
-
numDataBytes
private int numDataBytes
-
numECBytes
private int numECBytes
-
numRSBlocks
private int numRSBlocks
-
matrix
private ByteMatrix matrix
-
-
Method Detail
-
getMode
public Mode getMode()
Mode used by the QR code to encode data into bits. Possible values: TERMINATOR, NUMERIC, ALPHANUMERIC, STRUCTURED_APPEND, BYTE, ECI, KANJI, FNC1_FIRST_POSITION, FNC2_SECOND_POSITION- Returns:
- Mode of the QR Code.
-
getECLevel
public ErrorCorrectionLevel getECLevel()
Possible error correction level values ranked from lowest error correction capability to highest: L, M, Q, H- Returns:
- Error correction level of the QR Code.
-
getVersion
public int getVersion()
Together with error correction level, the version determines the information capacity of the QR code. Higher version numbers correspond with higher capacity. Ranges from 1 to 40.- Returns:
- Version of the QR Code.
-
getMatrixWidth
public int getMatrixWidth()
- Returns:
- ByteMatrix width of the QR Code.
-
getMaskPattern
public int getMaskPattern()
- Returns:
- Mask pattern of the QR Code.
-
getNumTotalBytes
public int getNumTotalBytes()
- Returns:
- Number of total bytes in the QR Code.
-
getNumDataBytes
public int getNumDataBytes()
- Returns:
- Number of data bytes in the QR Code.
-
getNumECBytes
public int getNumECBytes()
- Returns:
- Number of error correction bytes in the QR Code.
-
getNumRSBlocks
public int getNumRSBlocks()
- Returns:
- Number of Reedsolomon blocks in the QR Code.
-
getMatrix
public ByteMatrix getMatrix()
- Returns:
- ByteMatrix data of the QR Code.
-
at
public int at(int x, int y)
Retrieve the value of the module (cell) pointed by "x" and "y" in the matrix of the QR Code. 1 represents a black cell, and 0 represents a white cell.- Parameters:
x
- width coordinatey
- height coordinate- Returns:
- 1 for a black cell, 0 for a white cell
-
isValid
public boolean isValid()
Check the validity of all member variables- Returns:
- true if all variables are valid, false otherwise
-
toString
public java.lang.String toString()
Prints all parameters- Overrides:
toString
in classjava.lang.Object
- Returns:
- string containing all parameters
-
setMode
public void setMode(Mode value)
Set the data encoding mode of the QR code Possible modes: TERMINATOR, NUMERIC, ALPHANUMERIC, STRUCTURED_APPEND, BYTE, ECI, KANJI, FNC1_FIRST_POSITION, FNC2_SECOND_POSITION- Parameters:
value
- new data encoding mode
-
setECLevel
public void setECLevel(ErrorCorrectionLevel value)
Set the error correction level of th QR code. Possible error correction level values ranked from lowest error correction capability to highest: L, M, Q, H- Parameters:
value
- new error correction level
-
setVersion
public void setVersion(int value)
Set the version of the QR code. Together with error correction level, the version determines the information capacity of the QR code. Higher version numbers correspond with higher capacity. Range: 1 to 40.- Parameters:
value
- the new version of the QR code
-
setMatrixWidth
public void setMatrixWidth(int value)
Sets the width of the byte matrix- Parameters:
value
- the new width of the matrix
-
setMaskPattern
public void setMaskPattern(int value)
Set the masking pattern- Parameters:
value
- new masking pattern of the QR code
-
setNumTotalBytes
public void setNumTotalBytes(int value)
Set the number of total bytes- Parameters:
value
- new number of total bytes
-
setNumDataBytes
public void setNumDataBytes(int value)
Set the number of data bytes- Parameters:
value
- new number of data bytes
-
setNumECBytes
public void setNumECBytes(int value)
Set the number of error correction blocks- Parameters:
value
- new number of error correction blocks
-
setNumRSBlocks
public void setNumRSBlocks(int value)
Set the number of Reed-Solomon blocks- Parameters:
value
- new number of Reed-Solomon blocks
-
setMatrix
public void setMatrix(ByteMatrix value)
Set the byte-matrix- Parameters:
value
- the new byte-matrix
-
isValidMaskPattern
public static boolean isValidMaskPattern(int maskPattern)
Check if "mask_pattern" is valid.- Parameters:
maskPattern
- masking pattern to check- Returns:
- true if the pattern is valid, false otherwise
-
-