Barcode-Lib4J requires Java 9+

Java Class «ImplUPCA»  –  Generate UPC-A Barcode

All Implemented Interfaces:
Cloneable

public class ImplUPCA extends LineageUPC
Implementation of UPC-A. To generate instances, please use one of the newInstance static methods in the Barcode class.
  • Method Details

    • setContent

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

      The number must be either 12 (with check digit) or 11 (without check digit) in length.

      • If the number contains 12 digits, the 12th digit is checked to see if it is a valid check digit according to the UPC-A standard. If the check digit is invalid, a BarcodeException is thrown.
      • If the number contains 11 digits and autoComplete is set to true, the method calculates the missing check digit and appends it to the specified number. If autoComplete is set to false, a BarcodeException is thrown.
      Specified by:
      setContent in class Barcode
      Parameters:
      content - the UPC-A number 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 UPC-A uses a fixed check digit which is not optional
      Throws:
      BarcodeException - if the content is empty, contains non-numeric characters, is of invalid length, or has an invalid check digit