/**
  * Encodes a single character.
  *
  * @param logic the logic handler to receive generated events
  * @param c the character to encode
  * @param codeword the codeword belonging to the character
  */
 protected void encodeCodeword(ClassicBarcodeLogicHandler logic, char c, String codeword) {
   logic.startBarGroup(BarGroup.MSG_CHARACTER, new Character(c).toString());
   for (int i = 0, count = codeword.length(); i < count; i++) {
     int height = Integer.parseInt(codeword.substring(i, i + 1));
     logic.addBar(true, height);
   }
   logic.endBarGroup();
 }
  /** {@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();
  }