Class Decoder


  • public final class Decoder
    extends java.lang.Object

    The main class which implements Aztec Code decoding -- as opposed to locating and extracting the Aztec Code from an image.

    • Constructor Summary

      Constructors 
      Constructor Description
      Decoder()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static byte[] convertBoolArrayToByteArray​(boolean[] boolArr)
      Packs a bit array into bytes, most significant bit first
      private Decoder.CorrectedBitsResult correctBits​(boolean[] rawbits)
      Performs RS error correction on an array of bits.
      DecoderResult decode​(AztecDetectorResult detectorResult)  
      private boolean[] extractBits​(BitMatrix matrix)
      Gets the array of bits from an Aztec Code matrix
      private static java.lang.String getCharacter​(Decoder.Table table, int code)
      Gets the character (or string) corresponding to the passed code in the given table
      private static java.lang.String getEncodedData​(boolean[] correctedBits)
      Gets the string encoded in the aztec code bits
      private static Decoder.Table getTable​(char t)
      gets the table corresponding to the char passed
      static java.lang.String highLevelDecode​(boolean[] correctedBits)  
      private static byte readByte​(boolean[] rawbits, int startIndex)
      Reads a code of length 8 in an array of bits, padding with zeros
      private static int readCode​(boolean[] rawbits, int startIndex, int length)
      Reads a code of given length and at given index in an array of bits
      private static int totalBitsInLayer​(int layers, boolean compact)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • UPPER_TABLE

        private static final java.lang.String[] UPPER_TABLE
      • LOWER_TABLE

        private static final java.lang.String[] LOWER_TABLE
      • MIXED_TABLE

        private static final java.lang.String[] MIXED_TABLE
      • PUNCT_TABLE

        private static final java.lang.String[] PUNCT_TABLE
      • DIGIT_TABLE

        private static final java.lang.String[] DIGIT_TABLE
      • DEFAULT_ENCODING

        private static final java.nio.charset.Charset DEFAULT_ENCODING
    • Constructor Detail

      • Decoder

        public Decoder()
    • Method Detail

      • getEncodedData

        private static java.lang.String getEncodedData​(boolean[] correctedBits)
                                                throws FormatException
        Gets the string encoded in the aztec code bits
        Returns:
        the decoded string
        Throws:
        FormatException
      • getTable

        private static Decoder.Table getTable​(char t)
        gets the table corresponding to the char passed
      • getCharacter

        private static java.lang.String getCharacter​(Decoder.Table table,
                                                     int code)
        Gets the character (or string) corresponding to the passed code in the given table
        Parameters:
        table - the table used
        code - the code of the character
      • extractBits

        private boolean[] extractBits​(BitMatrix matrix)
        Gets the array of bits from an Aztec Code matrix
        Returns:
        the array of bits
      • readCode

        private static int readCode​(boolean[] rawbits,
                                    int startIndex,
                                    int length)
        Reads a code of given length and at given index in an array of bits
      • readByte

        private static byte readByte​(boolean[] rawbits,
                                     int startIndex)
        Reads a code of length 8 in an array of bits, padding with zeros
      • convertBoolArrayToByteArray

        static byte[] convertBoolArrayToByteArray​(boolean[] boolArr)
        Packs a bit array into bytes, most significant bit first
      • totalBitsInLayer

        private static int totalBitsInLayer​(int layers,
                                            boolean compact)