java.lang.Object
com.google.zxing.qrcode.decoder.FormatInformation

final class FormatInformationextends Object

Encapsulates a QR Code's format information, including the data mask used and error correction level.

See DataMask
See Also:
  • Field Details

    • FORMAT_INFO_MASK_QR

      private static final int FORMAT_INFO_MASK_QR
      Xor mask applied to the QR format bits.
      See Also:
    • FORMAT_INFO_DECODE_LOOKUP

      private static final int[][] FORMAT_INFO_DECODE_LOOKUP
      See ISO 18004:2006, Annex C, Table C.1
    • errorCorrectionLevel

      private final ErrorCorrectionLevel errorCorrectionLevel
      The level the format bits name.
    • dataMask

      private final byte dataMask
      The data mask pattern the format bits name.
  • Constructor Details

    • FormatInformation

      private FormatInformation(int formatInfo)
      Decodes the fifteen format bits.
      Parameters:
      formatInfo - the raw format information
  • Method Details

    • numBitsDiffering

      static int numBitsDiffering(int a, int b)
      Counts the bits that differ between the two format info bit patterns.
      Parameters:
      a - first of the two format info bit patterns to compare
      b - second of the two format info bit patterns to compare
      Returns:
      number of differing bits
    • decodeFormatInformation

      static FormatInformation decodeFormatInformation(int maskedFormatInfo1, int maskedFormatInfo2)
      To establish best match if doesn't seem to match any known pattern
      Parameters:
      maskedFormatInfo1 - format info indicator, with mask still applied
      maskedFormatInfo2 - second copy of same info; both are checked at the same time
      Returns:
      information about the format it specifies, or null
    • doDecodeFormatInformation

      private static FormatInformation doDecodeFormatInformation(int maskedFormatInfo1, int maskedFormatInfo2)
      Decode with optional mask XOR applied
      Parameters:
      maskedFormatInfo1 - the format info bits read from the symbol, mask possibly applied
      maskedFormatInfo2 - second copy of same info; both are checked at the same time
      Returns:
      the matching format information, or null if nothing is within 3 bits
    • getErrorCorrectionLevel

      ErrorCorrectionLevel getErrorCorrectionLevel()
      Error correction level decoded from format info bits.
      Returns:
      the level selected by bits 3 and 4 of the format information
    • getDataMask

      byte getDataMask()
      Data mask reference decoded from format info bits.
      Returns:
      the 0-7 mask pattern reference taken from the bottom three bits
    • hashCode

      public int hashCode()
      Hash of the error correction level combined with the data mask.
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      True if the other object has the same error correction level and data mask.
      Overrides:
      equals in class Object