question: static String encodeHighLevel ( String msg , Compaction compaction ) throws WriterException { byte [ ] bytes = null ; StringBuilder sb = new StringBuilder ( msg . length ( ) ) ; int len = msg . length ( ) ; int p = 0 ; int textSubMode = SUBMODE_ALPHA ; if ( compaction == Compaction . TEXT ) { encodeText ( msg , p , len , sb , textSubMode ) ; } else if ( compaction == Compaction . BYTE ) { bytes = getBytesForMessage ( msg ) ; encodeBinary ( bytes , p , bytes . length , BYTE_COMPACTION , sb ) ; } else if ( compaction == Compaction . NUMERIC ) { sb . append ( ( char ) LATCH_TO_NUMERIC ) ; encodeNumeric ( msg , p , len , sb ) ; } else { int encodingMode = TEXT_COMPACTION ; while ( p < len ) { int n = determineConsecutiveDigitCount ( msg , p ) ; if ( n >= 13 ) { sb . append ( ( char ) LATCH_TO_NUMERIC ) ; encodingMode = NUMERIC_COMPACTION ; textSubMode = SUBMODE_ALPHA ; encodeNumeric ( msg , p , n , sb ) ; p += n ; } else { int t = determineConsecutiveTextCount ( msg , p ) ; if ( t >= 5 || n == len ) { if ( encodingMode != TEXT_COMPACTION ) { sb . append ( ( char ) LATCH_TO_TEXT ) ; encodingMode = TEXT_COMPACTION ; textSubMode = SUBMODE_ALPHA ; } textSubMode = encodeText ( msg , p , t , sb , textSubMode ) ; p += t ; } else { if ( bytes == null ) { bytes = getBytesForMessage ( msg ) ; } int b = determineConsecutiveBinaryCount ( msg , bytes , p ) ; if ( b == 0 ) { b = 1 ; } if ( b == 1 && encodingMode == TEXT_COMPACTION ) { encodeBinary ( bytes , p , 1 , TEXT_COMPACTION , sb ) ; } else { encodeBinary ( bytes , p , b , encodingMode , sb ) ; encodingMode = BYTE_COMPACTION ; textSubMode = SUBMODE_ALPHA ; } p += b ; } } } } return sb . toString ( ) ; }
target:  Performs 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.