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, String messageDE, Object... inserts)
      Constructs a BarcodeException with the specified ID, message, and optional inserts.

      The optional inserts can be used to dynamically insert values into the message text. Use "%s" as a placeholder in the message where the insert should be placed. The order of the inserts should correspond to the order of the placeholders in the message. For example, if the message is "Invalid value at position %s: %s", you can provide the position and the invalid value as inserts.

      Parameters:
      id - the exception ID that categorizes the exception
      message - the detailed message explaining the exception
      messageDE - the German translation of the message
      inserts - optional parameters to be inserted into the message
  • Method Details

    • getID

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

      public String getLocalizedMessage()
      Returns the localized message for this exception. If the default locale is German, it returns the German message. Otherwise, it returns the standard message.
      Overrides:
      getLocalizedMessage in class Throwable
      Returns:
      the localized message for 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