Class Code128LogicImpl

java.lang.Object
org.krysalis.barcode4j.impl.code128.Code128LogicImpl

public class Code128LogicImpl extends Object
This class is an implementation of the Code 128 barcode.
Version:
$Id: Code128LogicImpl.java,v 1.5 2009-02-20 13:07:21 jmaerki Exp $
  • Field Details

    • FNC_1

      public static final char FNC_1
      The function 1 command. ASCII: 0xF1
      See Also:
    • FNC_2

      public static final char FNC_2
      The function 2 command. ASCII: 0xF2
      See Also:
    • FNC_3

      public static final char FNC_3
      The function 3 command. ASCII: 0xF3
      See Also:
    • FNC_4

      public static final char FNC_4
      The function 4 command. ASCII: 0xF4
      See Also:
  • Constructor Details

    • Code128LogicImpl

      public Code128LogicImpl()
      Default constructor.
    • Code128LogicImpl

      public Code128LogicImpl(int codeset)
      Main constructor.
      Parameters:
      codeset - the enabled codeset
  • Method Details

    • isValidChar

      public static boolean isValidChar(char ch)
      Determines whether a character can be encoded in Code 128.
      Parameters:
      ch - the character to check
      Returns:
      true if it is a valid character
    • isInCodeSetA

      public static boolean isInCodeSetA(char ch)
      Determines whether a character is defined in codeset A.
      Parameters:
      ch - the character to check
      Returns:
      true if it is found in codeset A
    • isInCodeSetB

      public static boolean isInCodeSetB(char ch)
      Determines whether a character is defined in codeset B.
      Parameters:
      ch - the character to check
      Returns:
      true if it is found in codeset B
    • canBeInCodeSetC

      public static boolean canBeInCodeSetC(char ch, boolean second)
      Determines whether a character is a digit or a function 1 command.
      Parameters:
      ch - the character to check
      second - true if checking the character for the second position in a duo.
      Returns:
      true if the above condition is met
    • symbolCharToString

      public static String symbolCharToString(int index)
      Converts a character set index to a String representation. This is primarily used for debugging purposes.
      Parameters:
      index - the character set index
      Returns:
      the String representation
    • toString

      public static String toString(int[] encodedMsg)
      Converts an encoded Code 128 message into a String for debugging purposes.
      Parameters:
      encodedMsg - the encoded message
      Returns:
      the String representation
    • encodeChar

      protected void encodeChar(ClassicBarcodeLogicHandler logic, int index)
      Encodes a character.
      Parameters:
      logic - LogicHandler to send the barcode events to
      index - index withing the character set of the character to encode
    • encodeStop

      protected void encodeStop(ClassicBarcodeLogicHandler logic)
      Encodes the special stop character.
      Parameters:
      logic - LogicHandler to send the barcode events to
    • getEncoder

      protected Code128Encoder getEncoder()
      Returns the encoder to be used. The encoder is responsible for turning a String message into an array of character set indexes.

      Override this method to supply your own implementation.

      Returns:
      the requested encoder
    • generateBarcodeLogic

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