Class Interleaved2Of5LogicImpl

java.lang.Object
org.krysalis.barcode4j.impl.int2of5.Interleaved2Of5LogicImpl
Direct Known Subclasses:
ITF14LogicImpl

public class Interleaved2Of5LogicImpl extends Object
This class is an implementation of the Interleaved 2 of 5 barcode.
Version:
$Id: Interleaved2Of5LogicImpl.java,v 1.3 2009-02-19 10:14:54 jmaerki Exp $
  • Constructor Details

    • Interleaved2Of5LogicImpl

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

    • calcChecksum

      public static char calcChecksum(String msg, int oddMultiplier, int evenMultiplier)
      Calculates the checksum for a message to be encoded as an Interleaved 2 of 5 barcode. The algorithm is a weighted modulo 10 scheme.
      Parameters:
      msg - message to calculate the check digit for
      oddMultiplier - multiplier to be used for odd positions (usually 3 or 4)
      evenMultiplier - multiplier to be used for even positions (usually 1 or 9)
      Returns:
      char the check digit
    • calcChecksum

      public static char calcChecksum(String msg)
      Calculates the checksum for a message to be encoded as an Interleaved 2 of 5 barcode. The algorithm is a weighted modulo 10 scheme. This method uses the default specification (ITF-14, EAN-14, SSC-14, DUN14 and USPS).
      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
    • getChecksumMode

      public ChecksumMode getChecksumMode()
      Returns the current checksum mode
      Returns:
      the checksum mode
    • doHandleChecksum

      protected String doHandleChecksum(StringBuffer sb, ChecksumMode mode)
      Handles the checksum based on the given checksum mode. The checksum is either checked, ignored or attached to the given string buffer.
      Parameters:
      sb - the string buffer containing the message
      mode - the checksum mode
      Returns:
      the updated string after checksum processing (for the human-readable part)
    • handleChecksum

      protected String handleChecksum(StringBuffer sb)
      Handles the checksum based on the checksum mode. The checksum is either checked, ignored or attached to the given string buffer.
      Parameters:
      sb - the string buffer containing the message
      Returns:
      the updated string after checksum processing (for the human-readable part)
    • 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