Class AbstractFourStateLogicImpl

java.lang.Object
org.krysalis.barcode4j.impl.fourstate.AbstractFourStateLogicImpl
Direct Known Subclasses:
AbstractRMCBCKIXLogicImpl, USPSIntelligentMailLogicImpl

public abstract class AbstractFourStateLogicImpl extends Object
Provides a base class for "four-state" barcodes.
Version:
$Id: AbstractFourStateLogicImpl.java,v 1.2 2008-05-13 13:00:43 jmaerki Exp $
Author:
Jeremias Maerki
  • Constructor Details

    • AbstractFourStateLogicImpl

      public AbstractFourStateLogicImpl(ChecksumMode mode)
      Main constructor
      Parameters:
      mode - checksum mode
  • Method Details

    • isIgnoredChar

      public static boolean isIgnoredChar(char c)
      Checks if a character is an ignored character (such as a '-' (dash)).
      Parameters:
      c - character to check
      Returns:
      True if the character is ignored
    • getChecksumMode

      public ChecksumMode getChecksumMode()
      Returns the currently active checksum mode.
      Returns:
      the checksum mode
    • calcChecksum

      public abstract char calcChecksum(String msg)
      Calculates the checksum for a message to be encoded as an one of the foru-state barcode symbologies.
      Parameters:
      msg - message to calculate the check digit for
      Returns:
      char the check digit
    • validateChecksum

      public boolean validateChecksum(String msg)
      Verifies the checksum for a message.
      Parameters:
      msg - message (check digit included)
      Returns:
      boolean True, if the checksum is correct
    • normalizeMessage

      protected abstract String normalizeMessage(String msg)
      Turns the given message into a normalize representation. Some subclasses may update/add parentheses around the message and/or handle the checksum as necessary.
      Parameters:
      msg - the message
      Returns:
      the normalized message to be encoded
    • encodeHighLevel

      protected abstract String[] encodeHighLevel(String msg)
      Does the high-level encoding of the message into codewords.
      Parameters:
      msg - the message
      Returns:
      an array of Strings with codewords
    • encodeCodeword

      protected void encodeCodeword(ClassicBarcodeLogicHandler logic, char c, String codeword)
      Encodes a single character.
      Parameters:
      logic - the logic handler to receive generated events
      c - the character to encode
      codeword - the codeword belonging to the character
    • generateBarcodeLogic

      public void generateBarcodeLogic(ClassicBarcodeLogicHandler logic, String msg)
      Generates the barcode logic
      Parameters:
      logic - the logic handler to receive generated events
      msg - the message to encode