/** * Generates the barcode logic * * @param logic the logic handler to receive generated events * @param msg the message to encode */ public void generateBarcodeLogic(ClassicBarcodeLogicHandler logic, String msg) { String normalizedMsg = normalizeMessage(msg); String[] encodedMsg = encodeHighLevel(normalizedMsg); logic.startBarcode(msg, normalizedMsg); // encode message for (int i = 0; i < encodedMsg.length; i++) { final char ch = normalizedMsg.charAt(i); encodeCodeword(logic, ch, encodedMsg[i]); } logic.endBarcode(); }
/** {@inheritDoc} */ public void generateBarcodeLogic(ClassicBarcodeLogicHandler logic, String msg) { // slightly specialized version of this method for USPS 4BC: // -> there's no direct correlation between the original msg chars and the effective chars String normalizedMsg = normalizeMessage(msg); String[] encodedMsg = encodeHighLevel(normalizedMsg); // encodedMsg.length will always be 1 logic.startBarcode(msg, normalizedMsg); // encode message String codeword = encodedMsg[0]; for (int i = 0, count = codeword.length(); i < count; i++) { int height = Integer.parseInt(codeword.substring(i, i + 1)); logic.addBar(true, height); } logic.endBarcode(); }