Class UPCEANLogicImpl

java.lang.Object
org.krysalis.barcode4j.impl.upcean.UPCEANLogicImpl
Direct Known Subclasses:
EAN13LogicImpl, EAN8LogicImpl, UPCALogicImpl, UPCELogicImpl

public abstract class UPCEANLogicImpl extends Object
This is an abstract base class for UPC and EAN barcodes.
Version:
$Id: UPCEANLogicImpl.java,v 1.1 2004-09-12 17:57:52 jmaerki Exp $
Author:
Jeremias Maerki
  • Field Details

    • LEFT_HAND_A

      protected static final byte LEFT_HAND_A
      Left hand A character set
      See Also:
    • LEFT_HAND_B

      protected static final byte LEFT_HAND_B
      Left hand B character set
      See Also:
    • RIGHT_HAND

      protected static final byte RIGHT_HAND
      Right hand character set
      See Also:
    • ODD_PARITY

      protected static final byte ODD_PARITY
      Odd parity character set
      See Also:
    • EVEN_PARITY

      protected static final byte EVEN_PARITY
      Even parity character set
      See Also:
  • Constructor Details

    • UPCEANLogicImpl

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

    • validateMessage

      public static void validateMessage(String msg)
      Validates a UPC/EAN message. The method throws IllegalArgumentExceptions if an invalid message is passed.
      Parameters:
      msg - the message to validate
    • calcChecksum

      public static char calcChecksum(String msg)
      Calculates the check character for a given message
      Parameters:
      msg - the message
      Returns:
      char the check character
    • getSupplementalLength

      protected static int getSupplementalLength(String msg)
      Returns the length of the supplemental part of a UPC/EAN message. The method throws an IllegalArgumentException if the supplement is malformed.
      Parameters:
      msg - the UPC/EAN message
      Returns:
      2 or 5 if there is a supplemental, 0 if there's none.
    • removeSupplemental

      protected static String removeSupplemental(String msg)
      Removes an optional supplemental (ex. "+20") from the message.
      Parameters:
      msg - a UPC/EAN message
      Returns:
      the message without the supplemental
    • retrieveSupplemental

      protected static String retrieveSupplemental(String msg)
      Returns the supplemental part of a UPC/EAN message if there is one. Supplementals are added in the form: "+[supplemental]" (ex. "+20").
      Parameters:
      msg - a UPC/EAN message
      Returns:
      the supplemental part, null if there is none
    • getChecksumMode

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

      protected void encodeChar(ClassicBarcodeLogicHandler logic, char c, int charset)
      Encodes a character.
      Parameters:
      logic - the logic handler to receive generated events
      c - the character to encode
      charset - the character set to use
    • drawSideGuard

      protected void drawSideGuard(ClassicBarcodeLogicHandler logic)
      Generates a side guard.
      Parameters:
      logic - the logic handler to receive generated events
    • drawCenterGuard

      protected void drawCenterGuard(ClassicBarcodeLogicHandler logic)
      Generates a center guard.
      Parameters:
      logic - the logic handler to receive generated events
    • drawSupplemental

      protected void drawSupplemental(ClassicBarcodeLogicHandler logic, String supp)
      Generates events for a supplemental.
      Parameters:
      logic - the logic handler to receive generated events
      supp - the supplemental
    • generateBarcodeLogic

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