Barcode-Lib4J requires Java 9+

Java Class «BarcodeException»

java.lang.Object
java.lang.Throwable
java.lang.Exception
de.vwsoft.barcodelib4j.oned.BarcodeException
All Implemented Interfaces:
Serializable

public class BarcodeException extends Exception
Thrown when a barcode object is assigned an invalid content that cannot be encoded by the given barcode type.

Returns an exception ID from one of the three categories: Content, Checksum and Add-On. Some IDs are for general use, while others are reserved for specific barcode types.

Content related exceptions:

Checksum related exceptions: Add-On related exceptions:

If you prefer to determine which of the three categories an exception belongs to, rather than handle each exception ID separately, you can use the three corresponding methods isContentRelated(), isChecksumRelated() and isAddOnRelated() provided in this class.

  • Field Details

    • CONTENT_EMPTY

      public static final int CONTENT_EMPTY
      Exception ID indicating empty content.
    • CONTENT_INVALID

      public static final int CONTENT_INVALID
      Exception ID indicating general invalidity of the content.
    • CONTENT_NOT_DIGITS

      public static final int CONTENT_NOT_DIGITS
      Exception ID indicating non-digit characters in the content.
    • CONTENT_NOT_ASCII

      public static final int CONTENT_NOT_ASCII
      Exception ID indicating non-ASCII characters in the content.
    • CONTENT_LENGTH_INVALID

      public static final int CONTENT_LENGTH_INVALID
      Exception ID indicating an invalid content length.
    • CONTENT_LENGTH_NOT_EVEN

      public static final int CONTENT_LENGTH_NOT_EVEN
      Exception ID indicating an uneven content length.
    • CHECKSUM_INVALID

      public static final int CHECKSUM_INVALID
      Exception ID indicating an invalid checksum.
    • ADDON_EMPTY

      public static final int ADDON_EMPTY
      Exception ID indicating empty add-on content.
    • ADDON_LENGTH_INVALID

      public static final int ADDON_LENGTH_INVALID
      Exception ID indicating an invalid add-on length.
    • ADDON_NOT_DIGITS

      public static final int ADDON_NOT_DIGITS
      Exception ID indicating non-digit characters in the add-on content.
  • Constructor Details

    • BarcodeException

      public BarcodeException(int id, String message)
      Creates a new BarcodeException with the specified exception ID and message.
      Parameters:
      id - the exception ID that categorizes the exception, must be one of the predefined constants such as CONTENT_EMPTY, CHECKSUM_INVALID, or ADDON_NOT_DIGITS
      message - the detailed message explaining the exception
  • Method Details

    • getID

      public int getID()
      Returns the exception ID associated with this exception.
      Returns:
      the exception ID associated with this exception
    • isContentRelated

      public boolean isContentRelated()
      Returns whether the exception is content related.
      Returns:
      whether the exception is content related
    • isChecksumRelated

      public boolean isChecksumRelated()
      Returns whether the exception is checksum related.
      Returns:
      whether the exception is checksum related
    • isAddOnRelated

      public boolean isAddOnRelated()
      Returns whether the exception is add-on related.
      Returns:
      whether the exception is add-on related