Barcode-Lib4J requires Java 9+
Package de.vwsoft.barcodelib4j.oned
Java Class «ImplUPCE» – Generate UPC-E Barcode
java.lang.Object
de.vwsoft.barcodelib4j.oned.Barcode
de.vwsoft.barcodelib4j.oned.LineageUPC
de.vwsoft.barcodelib4j.oned.ImplUPCE
- All Implemented Interfaces:
Cloneable
Implementation of UPC-E. To generate instances, please use one of the
newInstance
static methods in the Barcode
class.-
Method Summary
Modifier and TypeMethodDescriptionvoid
setContent
(String content, boolean autoComplete, boolean appendOptionalChecksum) Sets the UPC-E number to be encoded in the barcode.Methods inherited from class de.vwsoft.barcodelib4j.oned.LineageUPC
getAddOn, setAddOn
Methods inherited from class de.vwsoft.barcodelib4j.oned.Barcode
clone, draw, draw, getContent, getFont, getRatio, getText, getTextOffset, isFontSizeAdjusted, isOptionalChecksumVisible, isTextOnTop, isTextVisible, newInstance, newInstance, setFont, setFontSizeAdjusted, setOptionalChecksumVisible, setRatio, setTextOffset, setTextOnTop, setTextVisible, supportsAutoCompletion, supportsOptionalChecksum, supportsRatio
-
Method Details
-
setContent
public void setContent(String content, boolean autoComplete, boolean appendOptionalChecksum) throws BarcodeException Sets the UPC-E number to be encoded in the barcode.The first character of the UPC-E number must be either '0' or '1'.
The number must be either 8 (with check digit) or 7 (without check digit) in length.
- If the number contains 8 digits, the 8th digit is checked to see if it is a valid check
digit according to the UPC-E standard. If the check digit is invalid, a
BarcodeException
is thrown. - If the number contains 7 digits and
autoComplete
is set totrue
, the method calculates the missing check digit and appends it to the specified number. IfautoComplete
is set tofalse
, aBarcodeException
is thrown.
- Specified by:
setContent
in classBarcode
- Parameters:
content
- the UPC-E number to be encoded in the barcodeautoComplete
- whether to automatically calculate and append a check digit if it is missingappendOptionalChecksum
- has no function, as UPC-E 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
- If the number contains 8 digits, the 8th digit is checked to see if it is a valid check
digit according to the UPC-E standard. If the check digit is invalid, a
-