java.lang.Object
com.google.zxing.qrcode.encoder.QRCode

public final class QRCodeextends Object
QR Code representation for encoding.
  • Field Details

    • NUM_MASK_PATTERNS

      public static final int NUM_MASK_PATTERNS
      Number of mask patterns defined by the QR Code model.
      See Also:
    • mode

      private Mode mode
      The encoding mode the data was encoded with.
    • ecLevel

      private ErrorCorrectionLevel ecLevel
      The error correction level chosen.
    • version

      private Version version
      The symbol size chosen.
    • maskPattern

      private int maskPattern
      The data mask pattern chosen, -1 before it is picked.
    • matrix

      private ByteMatrix matrix
      The finished symbol, null before it is built.
  • Constructor Details

    • QRCode

      public QRCode()
      Construct an empty QR Code, with no mask pattern selected yet.
  • Method Details

    • getMode

      public Mode getMode()
      Return the encoding mode.
      Returns:
      the encoding mode, null until setMode() has been called
    • getECLevel

      public ErrorCorrectionLevel getECLevel()
      Return the error correction level.
      Returns:
      the e c level
    • getVersion

      public Version getVersion()
      Return the symbol version.
      Returns:
      the version, null until setVersion() has been called
    • getMaskPattern

      public int getMaskPattern()
      Return the index of the mask applied to the symbol.
      Returns:
      the mask pattern
    • getMatrix

      public ByteMatrix getMatrix()
      Return the encoded module matrix.
      Returns:
      the matrix, null until setMatrix() has been called
    • toString

      public String toString()
      Render the mode, correction level, version, mask and matrix as text.
      Overrides:
      toString in class Object
      Returns:
      the QR Code rendered for debugging
    • setMode

      public void setMode(Mode value)
      Record the encoding mode.
      Parameters:
      value - the encoding mode for the data being encoded
    • setECLevel

      public void setECLevel(ErrorCorrectionLevel value)
      Record the error correction level.
      Parameters:
      value - the error correction level to encode the symbol with
    • setVersion

      public void setVersion(Version version)
      Record the symbol version.
      Parameters:
      version - the symbol version, which fixes the matrix size
    • setMaskPattern

      public void setMaskPattern(int value)
      Record the index of the mask to apply.
      Parameters:
      value - the index of the mask to apply, 0 to NUM_MASK_PATTERNS - 1
    • setMatrix

      public void setMatrix(ByteMatrix value)
      Record the encoded module matrix.
      Parameters:
      value - the encoded module matrix to emit
    • isValidMaskPattern

      public static boolean isValidMaskPattern(int maskPattern)
      Test whether a mask index is one of the eight the model defines.
      Parameters:
      maskPattern - the mask index to test, in range only from 0 to NUM_MASK_PATTERNS - 1
      Returns:
      whether valid mask pattern