java.lang.Object
java.lang.Throwable
java.lang.Exception
de.vwsoft.barcodelib4j.oned.BarcodeException
- All Implemented Interfaces:
Serializable
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:
CONTENT_EMPTY
- Indicates empty content.CONTENT_INVALID
- States a general invalidity of the content.CONTENT_NOT_DIGITS
- Indicates that the content contains non-digit characters.CONTENT_NOT_ASCII
- Indicates that the content contains non-ASCII characters.CONTENT_LENGTH_INVALID
- Indicates an invalid content length.CONTENT_LENGTH_NOT_EVEN
- Indicates that the content length is not even.
CHECKSUM_INVALID
- Indicates an invalid checksum.
ADDON_EMPTY
- Indicates empty add-on content.ADDON_LENGTH_INVALID
- Indicates an invalid add-on length.ADDON_NOT_DIGITS
- Indicates that the add-on content contains non-digit characters.
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 Summary
Modifier and TypeFieldDescriptionstatic final int
Exception ID indicating empty add-on content.static final int
Exception ID indicating an invalid add-on length.static final int
Exception ID indicating non-digit characters in the add-on content.static final int
Exception ID indicating an invalid checksum.static final int
Exception ID indicating empty content.static final int
Exception ID indicating general invalidity of the content.static final int
Exception ID indicating an invalid content length.static final int
Exception ID indicating an uneven content length.static final int
Exception ID indicating non-ASCII characters in the content.static final int
Exception ID indicating non-digit characters in the content. -
Constructor Summary
ConstructorDescriptionBarcodeException
(int id, String message) Creates a new BarcodeException with the specified exception ID and message. -
Method Summary
Modifier and TypeMethodDescriptionint
getID()
Returns the exception ID associated with this exception.boolean
Returns whether the exception is add-on related.boolean
Returns whether the exception is checksum related.boolean
Returns whether the exception is content related.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Field Details
-
CONTENT_EMPTY
public static final int CONTENT_EMPTYException ID indicating empty content. -
CONTENT_INVALID
public static final int CONTENT_INVALIDException ID indicating general invalidity of the content. -
CONTENT_NOT_DIGITS
public static final int CONTENT_NOT_DIGITSException ID indicating non-digit characters in the content. -
CONTENT_NOT_ASCII
public static final int CONTENT_NOT_ASCIIException ID indicating non-ASCII characters in the content. -
CONTENT_LENGTH_INVALID
public static final int CONTENT_LENGTH_INVALIDException ID indicating an invalid content length. -
CONTENT_LENGTH_NOT_EVEN
public static final int CONTENT_LENGTH_NOT_EVENException ID indicating an uneven content length. -
CHECKSUM_INVALID
public static final int CHECKSUM_INVALIDException ID indicating an invalid checksum. -
ADDON_EMPTY
public static final int ADDON_EMPTYException ID indicating empty add-on content. -
ADDON_LENGTH_INVALID
public static final int ADDON_LENGTH_INVALIDException ID indicating an invalid add-on length. -
ADDON_NOT_DIGITS
public static final int ADDON_NOT_DIGITSException ID indicating non-digit characters in the add-on content.
-
-
Constructor Details
-
BarcodeException
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 asCONTENT_EMPTY
,CHECKSUM_INVALID
, orADDON_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
-