com.google.zxing.qrcode.encoder

## Class Encoder

- java.lang.Object
- - com.google.zxing.qrcode.encoder.Encoder

-     public final class Encoder
      extends Object

  Encoder for QR codes.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `(package private) static String` | `DEFAULT_BYTE_MODE_ENCODING`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `(package private) static void` | `append8BitBytes(String content, BitArray bits, String encoding)`
    `(package private) static void` | `appendAlphanumericBytes(CharSequence content, BitArray bits)`
    `(package private) static void` | `appendBytes(String content, Mode mode, BitArray bits, String encoding)` Append "bytes" in "mode" mode (encoding) into "bits".
    `(package private) static void` | `appendKanjiBytes(String content, BitArray bits)`
    `(package private) static void` | `appendLengthInfo(int numLetters, Version version, Mode mode, BitArray bits)` Append length info.
    `(package private) static void` | `appendModeInfo(Mode mode, BitArray bits)` Append mode info.
    `(package private) static void` | `appendNumericBytes(CharSequence content, BitArray bits)`
    `static Mode` | `chooseMode(String content)`
    `static QRCode` | `encode(String content, ErrorCorrectionLevel ecLevel)`
    `static QRCode` | `encode(String content, ErrorCorrectionLevel ecLevel, Map<EncodeHintType,?> hints)`
    `(package private) static byte[]` | `generateECBytes(byte[] dataBytes, int numEcBytesInBlock)`
    `(package private) static int` | `getAlphanumericCode(int code)`
    `(package private) static void` | `getNumDataBytesAndNumECBytesForBlockID(int numTotalBytes, int numDataBytes, int numRSBlocks, int blockID, int[] numDataBytesInBlock, int[] numECBytesInBlock)` Get number of data bytes and number of error correction bytes for block id "blockID".
    `(package private) static BitArray` | `interleaveWithECBytes(BitArray bits, int numTotalBytes, int numDataBytes, int numRSBlocks)` Interleave "bits" with corresponding error correction bytes.
    `(package private) static void` | `terminateBits(int numDataBytes, BitArray bits)` Terminate bits as described in 8.4.8 and 8.4.9 of JISX0510:2004 (p.24).

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_BYTE_MODE_ENCODING

          static final String DEFAULT_BYTE_MODE_ENCODING

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### append8BitBytes

          static void append8BitBytes(String content,
                                      BitArray bits,
                                      String encoding)
                               throws WriterException

      Throws:
        `WriterException`

    - #### appendAlphanumericBytes

          static void appendAlphanumericBytes(CharSequence content,
                                              BitArray bits)
                                       throws WriterException

      Throws:
        `WriterException`

    - #### appendBytes

          static void appendBytes(String content,
                                  Mode mode,
                                  BitArray bits,
                                  String encoding)
                           throws WriterException

      Append "bytes" in "mode" mode (encoding) into "bits". On success, store the result in "bits".
      Throws:
        `WriterException`

    - #### appendKanjiBytes

          static void appendKanjiBytes(String content,
                                       BitArray bits)
                                throws WriterException

      Throws:
        `WriterException`

    - #### appendLengthInfo

          static void appendLengthInfo(int numLetters,
                                       Version version,
                                       Mode mode,
                                       BitArray bits)
                                throws WriterException

      Append length info. On success, store the result in "bits".
      Throws:
        `WriterException`

    - #### appendModeInfo

          static void appendModeInfo(Mode mode,
                                     BitArray bits)

      Append mode info. On success, store the result in "bits".

    - #### appendNumericBytes

          static void appendNumericBytes(CharSequence content,
                                         BitArray bits)

    - #### chooseMode

          public static Mode chooseMode(String content)

    - #### encode

          public static QRCode encode(String content,
                                      ErrorCorrectionLevel ecLevel)
                               throws WriterException

      Parameters:
        `content` - text to encode
        `ecLevel` - error correction level to use
      Returns:
        `QRCode` representing the encoded QR code
      Throws:
        `WriterException` - if encoding can't succeed, because of for example invalid content or configuration

    - #### encode

          public static QRCode encode(String content,
                                      ErrorCorrectionLevel ecLevel,
                                      Map<EncodeHintType,?> hints)
                               throws WriterException

      Throws:
        `WriterException`

    - #### generateECBytes

          static byte[] generateECBytes(byte[] dataBytes,
                                        int numEcBytesInBlock)

    - #### getAlphanumericCode

          static int getAlphanumericCode(int code)

      Returns:
        the code point of the table used in alphanumeric mode or -1 if there is no corresponding code in the table.

    - #### getNumDataBytesAndNumECBytesForBlockID

          static void getNumDataBytesAndNumECBytesForBlockID(int numTotalBytes,
                                                             int numDataBytes,
                                                             int numRSBlocks,
                                                             int blockID,
                                                             int[] numDataBytesInBlock,
                                                             int[] numECBytesInBlock)
                                                      throws WriterException

      Get number of data bytes and number of error correction bytes for block id "blockID". Store the result in "numDataBytesInBlock", and "numECBytesInBlock". See table 12 in 8.5.1 of JISX0510:2004 (p.30)
      Throws:
        `WriterException`

    - #### interleaveWithECBytes

          static BitArray interleaveWithECBytes(BitArray bits,
                                                int numTotalBytes,
                                                int numDataBytes,
                                                int numRSBlocks)
                                         throws WriterException

      Interleave "bits" with corresponding error correction bytes. On success, store the result in "result". The interleave rule is complicated. See 8.6 of JISX0510:2004 (p.37) for details.
      Throws:
        `WriterException`

    - #### terminateBits

          static void terminateBits(int numDataBytes,
                                    BitArray bits)
                             throws WriterException

      Terminate bits as described in 8.4.8 and 8.4.9 of JISX0510:2004 (p.24).
      Throws:
        `WriterException`