QrPrinter implements Printer { protected byte[] print( final String data ) { final byte[] dataBytes = data.getBytes(); final QrCodeStore qrCodeStore = QrCodeStore.createQrCodeStore( dataBytes ); Integer messageSize = qrCodeStore.getCommand().length + dataBytes.length + QrCodePrint.PRINT.getCommand().length; for ( final ControlSequence controlSequence : controlSequences ) { messageSize += controlSequence.getCommand().length; } final ByteBuffer buffer = ByteBuffer.allocate( messageSize ); for ( final ControlSequence controlSequence : controlSequences ) { buffer.put( controlSequence.getCommand() ); } buffer.put( qrCodeStore.getCommand() ); buffer.put( dataBytes ); buffer.put( QrCodePrint.PRINT.getCommand() ); return buffer.array(); } private  QrPrinter( final Collection<ControlSequence> controlSequences, final String data ); static QrPrinter create( final Collection<ControlSequence> controlSequences, final String data ); @Override byte[] getCommand();  }
@Test public void testPrint() throws Exception { final Printer qrPrinter = QrPrinterBuilder.aPrinterBuilder() .withQrControlSequence( QrCodeModel.MODEL2 ) .withQrControlSequence( QrCodeSize.SIZE7 ) .withQrControlSequence( QrCodeErrorCorrectionLevel.L ) .buildPrinter( "223175087923687075112234402528973166755123456781508151013321" ); final byte[] command = qrPrinter.getCommand(); Assert.assertEquals( "[29, 40, 107, 4, 0, 49, 65, 50, 0, 29, 40, 107, 3, 0, 49, 67, 6, 29, 40, 107, 3, 0, 49, 69, 48, 29, 40, 107, 63, 0, 49, 80, 48, 50, 50, 51, 49, 55, 53, 48, 56, 55, 57, 50, 51, 54, 56, 55, 48, 55, 53, 49, 49, 50, 50, 51, 52, 52, 48, 50, 53, 50, 56, 57, 55, 51, 49, 54, 54, 55, 53, 53, 49, 50, 51, 52, 53, 54, 55, 56, 49, 53, 48, 56, 49, 53, 49, 48, 49, 51, 51, 50, 49, 29, 40, 107, 3, 0, 49, 81, 48]", Arrays.toString( command ) ); }