protected int [ ] getPatternAsCodewords ( int size ) { if ( size >= 10 ) { throw new IllegalArgumentException ( "Pattern groups of 10 or more digits are likely to be too large to parse as integers." ) ; } if ( pattern == null || pattern . length == 0 ) { return new int [ 0 ] ; } else { int count = ( int ) Math . ceil ( pattern [ 0 ] . length ( ) / ( double ) size ) ; int [ ] codewords = new int [ pattern . length * count ] ; for ( int i = 0 ; i < pattern . length ; i ++ ) { String row = pattern [ i ] ; for ( int j = 0 ; j < count ; j ++ ) { int substringStart = j * size ; int substringEnd = Math . min ( ( j + 1 ) * size , row . length ( ) ) ; codewords [ ( i * count ) + j ] = Integer . parseInt ( row . substring ( substringStart , substringEnd ) ) ; } } return codewords ; } }
Returns this bar code s pattern converted into a set of corresponding codewords . Useful for bar codes that encode their content as a pattern .