Package com.google.zxing.pdf417.encoder
Class PDF417HighLevelEncoder
- java.lang.Object
-
- com.google.zxing.pdf417.encoder.PDF417HighLevelEncoder
-
final class PDF417HighLevelEncoder extends java.lang.ObjectPDF417 high-level encoder following the algorithm described in ISO/IEC 15438:2001(E) in annex P.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classPDF417HighLevelEncoder.NoECIInput
-
Field Summary
Fields Modifier and Type Field Description private static intBYTE_COMPACTIONcode for Byte compactionprivate static java.nio.charset.CharsetDEFAULT_ENCODINGprivate static intECI_CHARSETidentifier for an ECI of a character set of code pageprivate static intECI_GENERAL_PURPOSEidentifier for a general purpose ECO formatprivate static intECI_USER_DEFINEDidentifier for a user defined Extended Channel Interpretation (ECI)private static intLATCH_TO_BYTEmode latch to Byte Compaction mode (number of characters a multiple of 6)private static intLATCH_TO_BYTE_PADDEDmode latch to Byte Compaction mode (number of characters NOT a multiple of 6)private static intLATCH_TO_NUMERICmode latch to Numeric Compaction modeprivate static intLATCH_TO_TEXTmode latch to Text Compaction modeprivate static byte[]MIXEDprivate static intNUMERIC_COMPACTIONcode for Numeric compactionprivate static byte[]PUNCTUATIONprivate static intSHIFT_TO_BYTEmode shift to Byte Compaction modeprivate static intSUBMODE_ALPHAText compaction submode Alphaprivate static intSUBMODE_LOWERText compaction submode Lowerprivate static intSUBMODE_MIXEDText compaction submode Mixedprivate static intSUBMODE_PUNCTUATIONText compaction submode Punctuationprivate static intTEXT_COMPACTIONcode for Text compactionprivate static byte[]TEXT_MIXED_RAWRaw code table for text compaction Mixed sub-modeprivate static byte[]TEXT_PUNCTUATION_RAWRaw code table for text compaction: Punctuation sub-mode
-
Constructor Summary
Constructors Modifier Constructor Description privatePDF417HighLevelEncoder()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static intdetermineConsecutiveBinaryCount(ECIInput input, int startpos, java.nio.charset.Charset encoding)Determines the number of consecutive characters that are encodable using binary compaction.private static intdetermineConsecutiveDigitCount(ECIInput input, int startpos)Determines the number of consecutive characters that are encodable using numeric compaction.private static intdetermineConsecutiveTextCount(ECIInput input, int startpos)Determines the number of consecutive characters that are encodable using text compaction.private static voidencodeBinary(byte[] bytes, int startpos, int count, int startmode, java.lang.StringBuilder sb)Encode parts of the message using Byte Compaction as described in ISO/IEC 15438:2001(E), chapter 4.4.3.(package private) static java.lang.StringencodeHighLevel(java.lang.String msg, Compaction compaction, java.nio.charset.Charset encoding, boolean autoECI)Performs high-level encoding of a PDF417 message using the algorithm described in annex P of ISO/IEC 15438:2001(E).private static voidencodeMultiECIBinary(ECIInput input, int startpos, int count, int startmode, java.lang.StringBuilder sb)Encode all of the message using Byte Compaction as described in ISO/IEC 15438:2001(E)private static voidencodeNumeric(ECIInput input, int startpos, int count, java.lang.StringBuilder sb)private static intencodeText(ECIInput input, int startpos, int count, java.lang.StringBuilder sb, int initialSubmode)Encode parts of the message using Text Compaction as described in ISO/IEC 15438:2001(E), chapter 4.4.2.private static voidencodingECI(int eci, java.lang.StringBuilder sb)private static booleanisAlphaLower(char ch)private static booleanisAlphaUpper(char ch)private static booleanisDigit(char ch)private static booleanisMixed(char ch)private static booleanisPunctuation(char ch)private static booleanisText(char ch)(package private) static byte[]subBytes(ECIInput input, int start, int end)
-
-
-
Field Detail
-
TEXT_COMPACTION
private static final int TEXT_COMPACTION
code for Text compaction- See Also:
- Constant Field Values
-
BYTE_COMPACTION
private static final int BYTE_COMPACTION
code for Byte compaction- See Also:
- Constant Field Values
-
NUMERIC_COMPACTION
private static final int NUMERIC_COMPACTION
code for Numeric compaction- See Also:
- Constant Field Values
-
SUBMODE_ALPHA
private static final int SUBMODE_ALPHA
Text compaction submode Alpha- See Also:
- Constant Field Values
-
SUBMODE_LOWER
private static final int SUBMODE_LOWER
Text compaction submode Lower- See Also:
- Constant Field Values
-
SUBMODE_MIXED
private static final int SUBMODE_MIXED
Text compaction submode Mixed- See Also:
- Constant Field Values
-
SUBMODE_PUNCTUATION
private static final int SUBMODE_PUNCTUATION
Text compaction submode Punctuation- See Also:
- Constant Field Values
-
LATCH_TO_TEXT
private static final int LATCH_TO_TEXT
mode latch to Text Compaction mode- See Also:
- Constant Field Values
-
LATCH_TO_BYTE_PADDED
private static final int LATCH_TO_BYTE_PADDED
mode latch to Byte Compaction mode (number of characters NOT a multiple of 6)- See Also:
- Constant Field Values
-
LATCH_TO_NUMERIC
private static final int LATCH_TO_NUMERIC
mode latch to Numeric Compaction mode- See Also:
- Constant Field Values
-
SHIFT_TO_BYTE
private static final int SHIFT_TO_BYTE
mode shift to Byte Compaction mode- See Also:
- Constant Field Values
-
LATCH_TO_BYTE
private static final int LATCH_TO_BYTE
mode latch to Byte Compaction mode (number of characters a multiple of 6)- See Also:
- Constant Field Values
-
ECI_USER_DEFINED
private static final int ECI_USER_DEFINED
identifier for a user defined Extended Channel Interpretation (ECI)- See Also:
- Constant Field Values
-
ECI_GENERAL_PURPOSE
private static final int ECI_GENERAL_PURPOSE
identifier for a general purpose ECO format- See Also:
- Constant Field Values
-
ECI_CHARSET
private static final int ECI_CHARSET
identifier for an ECI of a character set of code page- See Also:
- Constant Field Values
-
TEXT_MIXED_RAW
private static final byte[] TEXT_MIXED_RAW
Raw code table for text compaction Mixed sub-mode
-
TEXT_PUNCTUATION_RAW
private static final byte[] TEXT_PUNCTUATION_RAW
Raw code table for text compaction: Punctuation sub-mode
-
MIXED
private static final byte[] MIXED
-
PUNCTUATION
private static final byte[] PUNCTUATION
-
DEFAULT_ENCODING
private static final java.nio.charset.Charset DEFAULT_ENCODING
-
-
Method Detail
-
encodeHighLevel
static java.lang.String encodeHighLevel(java.lang.String msg, Compaction compaction, java.nio.charset.Charset encoding, boolean autoECI) throws WriterExceptionPerforms high-level encoding of a PDF417 message using the algorithm described in annex P of ISO/IEC 15438:2001(E). If byte compaction has been selected, then only byte compaction is used.- Parameters:
msg- the messagecompaction- compaction mode to useencoding- character encoding used to encode in default or byte compaction ornullfor default / not applicableautoECI- encode input minimally using multiple ECIs if needed If autoECI encoding is specified and additionallyencodingis specified, then the encoder will use the specifiedCharsetfor any character that can be encoded by it, regardless if a different encoding would lead to a more compact encoding. When noencodingis specified then charsets will be chosen so that the byte representation is minimal.- Returns:
- the encoded message (the char values range from 0 to 928)
- Throws:
WriterException
-
encodeText
private static int encodeText(ECIInput input, int startpos, int count, java.lang.StringBuilder sb, int initialSubmode) throws WriterException
Encode parts of the message using Text Compaction as described in ISO/IEC 15438:2001(E), chapter 4.4.2.- Parameters:
input- the inputstartpos- the start position within the messagecount- the number of characters to encodesb- receives the encoded codewordsinitialSubmode- should normally be SUBMODE_ALPHA- Returns:
- the text submode in which this method ends
- Throws:
WriterException
-
encodeMultiECIBinary
private static void encodeMultiECIBinary(ECIInput input, int startpos, int count, int startmode, java.lang.StringBuilder sb) throws WriterException
Encode all of the message using Byte Compaction as described in ISO/IEC 15438:2001(E)- Parameters:
input- the inputstartpos- the start position within the messagecount- the number of bytes to encodestartmode- the mode from which this method startssb- receives the encoded codewords- Throws:
WriterException
-
subBytes
static byte[] subBytes(ECIInput input, int start, int end)
-
encodeBinary
private static void encodeBinary(byte[] bytes, int startpos, int count, int startmode, java.lang.StringBuilder sb)Encode parts of the message using Byte Compaction as described in ISO/IEC 15438:2001(E), chapter 4.4.3. The Unicode characters will be converted to binary using the cp437 codepage.- Parameters:
bytes- the message converted to a byte arraystartpos- the start position within the messagecount- the number of bytes to encodestartmode- the mode from which this method startssb- receives the encoded codewords
-
encodeNumeric
private static void encodeNumeric(ECIInput input, int startpos, int count, java.lang.StringBuilder sb)
-
isDigit
private static boolean isDigit(char ch)
-
isAlphaUpper
private static boolean isAlphaUpper(char ch)
-
isAlphaLower
private static boolean isAlphaLower(char ch)
-
isMixed
private static boolean isMixed(char ch)
-
isPunctuation
private static boolean isPunctuation(char ch)
-
isText
private static boolean isText(char ch)
-
determineConsecutiveDigitCount
private static int determineConsecutiveDigitCount(ECIInput input, int startpos)
Determines the number of consecutive characters that are encodable using numeric compaction.- Parameters:
input- the inputstartpos- the start position within the input- Returns:
- the requested character count
-
determineConsecutiveTextCount
private static int determineConsecutiveTextCount(ECIInput input, int startpos)
Determines the number of consecutive characters that are encodable using text compaction.- Parameters:
input- the inputstartpos- the start position within the input- Returns:
- the requested character count
-
determineConsecutiveBinaryCount
private static int determineConsecutiveBinaryCount(ECIInput input, int startpos, java.nio.charset.Charset encoding) throws WriterException
Determines the number of consecutive characters that are encodable using binary compaction.- Parameters:
input- the inputstartpos- the start position within the messageencoding- the charset used to convert the message to a byte array- Returns:
- the requested character count
- Throws:
WriterException
-
encodingECI
private static void encodingECI(int eci, java.lang.StringBuilder sb) throws WriterException- Throws:
WriterException
-
-