Barcode-Lib4J requires Java 9+

Java Class «ImplPZN8»  –  Generate PZN8 Barcode

All Implemented Interfaces:
Cloneable

public class ImplPZN8 extends ImplCode39
Implementation of PZN8. To generate instances, please use one of the newInstance static methods in the Barcode class.

The PZN8 (Pharmazentralnummer) is a German barcode standard used to identify pharmaceutical products. It consists of 7 digits for the product identifier plus a check digit.

In the barcode symbol, the hyphen (-) is included by placing it in front of the number.

The human readable text line for the PZN8 barcode consists of the prefix 'PZN', followed by a space, then a hyphen, and then the 7-digit product identifier, followed by the check digit at the end. For example:

    PZN -12345678
PZN8 is not a standalone barcode type but uses the Code 39 format to encode its data. As a result, this class extends the abstract class LineageTwoWidth, as Code 39 is a type of two-width barcode. See the linked class description for more information.
  • Method Details

    • setContent

      public void setContent(String content, boolean autoComplete, boolean appendOptionalChecksum) throws BarcodeException
      Sets the content to be encoded in the barcode.

      If the autoComplete parameter is true and the length of the content is 7, the method calculates the checksum and appends it to the content, ensuring a total length of 8. If the calculated checksum is 10, a BarcodeException is thrown because this value is invalid.

      If autoComplete is false, the method validates that the content length is 8 and checks if the last digit matches the calculated checksum. If not, a BarcodeException is thrown.

      Overrides:
      setContent in class ImplCode39
      Parameters:
      content - the PZN8 to be encoded in the barcode
      autoComplete - whether to automatically calculate and append a check digit if it is missing
      appendOptionalChecksum - has no function, as PZN8 uses a fixed check digit which is not optional
      Throws:
      BarcodeException - if the content is empty, contains invalid characters, is of incorrect length, has an invalid check digit, or if the calculated checksum is 10