Class POSTNETLogicImpl

java.lang.Object
org.krysalis.barcode4j.impl.postnet.POSTNETLogicImpl

public class POSTNETLogicImpl extends Object
Implements the United States Postal Service Postnet barcode.
Version:
$Id: POSTNETLogicImpl.java,v 1.3 2006-11-07 16:42:17 jmaerki Exp $
Author:
Chris Dolphy
  • Constructor Details

    • POSTNETLogicImpl

      public POSTNETLogicImpl(ChecksumMode mode, boolean displayChecksum)
      Main constructor
      Parameters:
      mode - checksum mode
      displayChecksum - Controls whether to display checksum in the human-readable message
  • Method Details

    • calcChecksum

      public static char calcChecksum(String msg)
      Calculates the checksum for a message to be encoded as an POSTNET barcode.
      Parameters:
      msg - message to calculate the check digit for
      Returns:
      char the check digit
    • validateChecksum

      public static boolean validateChecksum(String msg)
      Verifies the checksum for a message.
      Parameters:
      msg - message (check digit included)
      Returns:
      boolean True, if the checksum is correct
    • 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
    • removeIgnoredCharacters

      public static String removeIgnoredCharacters(String msg)
      Removes ignored character from a valid POSTNET message.
      Parameters:
      msg - valid POSTNET message
      Returns:
      the message but without ignored characters
    • getChecksumMode

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

      protected void encodeChar(ClassicBarcodeLogicHandler logic, char c)
      Encodes a single character.
      Parameters:
      logic - the logic handler to receive generated events
      c - the character to encode
    • 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