Class DecodedBitStreamParser


  • final class DecodedBitStreamParser
    extends java.lang.Object

    This class contains the methods for decoding the PDF417 codewords.

    • Field Detail

      • TEXT_COMPACTION_MODE_LATCH

        private static final int TEXT_COMPACTION_MODE_LATCH
        See Also:
        Constant Field Values
      • BYTE_COMPACTION_MODE_LATCH

        private static final int BYTE_COMPACTION_MODE_LATCH
        See Also:
        Constant Field Values
      • NUMERIC_COMPACTION_MODE_LATCH

        private static final int NUMERIC_COMPACTION_MODE_LATCH
        See Also:
        Constant Field Values
      • BYTE_COMPACTION_MODE_LATCH_6

        private static final int BYTE_COMPACTION_MODE_LATCH_6
        See Also:
        Constant Field Values
      • BEGIN_MACRO_PDF417_CONTROL_BLOCK

        private static final int BEGIN_MACRO_PDF417_CONTROL_BLOCK
        See Also:
        Constant Field Values
      • BEGIN_MACRO_PDF417_OPTIONAL_FIELD

        private static final int BEGIN_MACRO_PDF417_OPTIONAL_FIELD
        See Also:
        Constant Field Values
      • MACRO_PDF417_TERMINATOR

        private static final int MACRO_PDF417_TERMINATOR
        See Also:
        Constant Field Values
      • MODE_SHIFT_TO_BYTE_COMPACTION_MODE

        private static final int MODE_SHIFT_TO_BYTE_COMPACTION_MODE
        See Also:
        Constant Field Values
      • MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME

        private static final int MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME
        See Also:
        Constant Field Values
      • MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT

        private static final int MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT
        See Also:
        Constant Field Values
      • MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP

        private static final int MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP
        See Also:
        Constant Field Values
      • MACRO_PDF417_OPTIONAL_FIELD_SENDER

        private static final int MACRO_PDF417_OPTIONAL_FIELD_SENDER
        See Also:
        Constant Field Values
      • MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE

        private static final int MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE
        See Also:
        Constant Field Values
      • MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE

        private static final int MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE
        See Also:
        Constant Field Values
      • MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM

        private static final int MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM
        See Also:
        Constant Field Values
      • PUNCT_CHARS

        private static final char[] PUNCT_CHARS
      • MIXED_CHARS

        private static final char[] MIXED_CHARS
      • EXP900

        private static final java.math.BigInteger[] EXP900
        Table containing values for the exponent of 900. This is used in the numeric compaction decode algorithm.
      • NUMBER_OF_SEQUENCE_CODEWORDS

        private static final int NUMBER_OF_SEQUENCE_CODEWORDS
        See Also:
        Constant Field Values
    • Constructor Detail

      • DecodedBitStreamParser

        private DecodedBitStreamParser()
    • Method Detail

      • textCompaction

        private static int textCompaction​(int[] codewords,
                                          int codeIndex,
                                          ECIStringBuilder result)
                                   throws FormatException
        Text Compaction mode (see 5.4.1.5) permits all printable ASCII characters to be encoded, i.e. values 32 - 126 inclusive in accordance with ISO/IEC 646 (IRV), as well as selected control characters.
        Parameters:
        codewords - The array of codewords (data + error)
        codeIndex - The current index into the codeword array.
        result - The decoded data is appended to the result.
        Returns:
        The next index into the codeword array.
        Throws:
        FormatException
      • decodeTextCompaction

        private static DecodedBitStreamParser.Mode decodeTextCompaction​(int[] textCompactionData,
                                                                        int[] byteCompactionData,
                                                                        int length,
                                                                        ECIStringBuilder result,
                                                                        DecodedBitStreamParser.Mode startMode)
        The Text Compaction mode includes all the printable ASCII characters (i.e. values from 32 to 126) and three ASCII control characters: HT or tab (ASCII value 9), LF or line feed (ASCII value 10), and CR or carriage return (ASCII value 13). The Text Compaction mode also includes various latch and shift characters which are used exclusively within the mode. The Text Compaction mode encodes up to 2 characters per codeword. The compaction rules for converting data into PDF417 codewords are defined in 5.4.2.2. The sub-mode switches are defined in 5.4.2.3.
        Parameters:
        textCompactionData - The text compaction data.
        byteCompactionData - The byte compaction data if there was a mode shift.
        length - The size of the text compaction and byte compaction data.
        result - The decoded data is appended to the result.
        startMode - The mode in which decoding starts
        Returns:
        The mode in which decoding ended
      • byteCompaction

        private static int byteCompaction​(int mode,
                                          int[] codewords,
                                          int codeIndex,
                                          ECIStringBuilder result)
                                   throws FormatException
        Byte Compaction mode (see 5.4.3) permits all 256 possible 8-bit byte values to be encoded. This includes all ASCII characters value 0 to 127 inclusive and provides for international character set support.
        Parameters:
        mode - The byte compaction mode i.e. 901 or 924
        codewords - The array of codewords (data + error)
        codeIndex - The current index into the codeword array.
        result - The decoded data is appended to the result.
        Returns:
        The next index into the codeword array.
        Throws:
        FormatException
      • numericCompaction

        private static int numericCompaction​(int[] codewords,
                                             int codeIndex,
                                             ECIStringBuilder result)
                                      throws FormatException
        Numeric Compaction mode (see 5.4.4) permits efficient encoding of numeric data strings.
        Parameters:
        codewords - The array of codewords (data + error)
        codeIndex - The current index into the codeword array.
        result - The decoded data is appended to the result.
        Returns:
        The next index into the codeword array.
        Throws:
        FormatException
      • decodeBase900toBase10

        private static java.lang.String decodeBase900toBase10​(int[] codewords,
                                                              int count)
                                                       throws FormatException
        Convert a list of Numeric Compacted codewords from Base 900 to Base 10.
        Parameters:
        codewords - The array of codewords
        count - The number of codewords
        Returns:
        The decoded string representing the Numeric data.
        Throws:
        FormatException