Barcode-Lib4J requires Java 9+
Package de.vwsoft.barcodelib4j.oned
Java Class «ImplEAN14» – Generate EAN-14 Barcode
java.lang.Object
de.vwsoft.barcodelib4j.oned.Barcode
de.vwsoft.barcodelib4j.oned.ImplCode128
de.vwsoft.barcodelib4j.oned.ImplEAN128
de.vwsoft.barcodelib4j.oned.ImplEAN14
- All Implemented Interfaces:
Cloneable
Implementation of EAN-14 (also known as GTIN-14) using GS1-128. To generate instances, please use one of the
newInstance
static methods in the Barcode
class.
This convenience class generates a GS1-128 barcode that contains a 14-digit GTIN as the sole data element. It automatically includes the Application Identifier prefix '01' in both the barcode and the human readable text line, allowing you to specify only the GTIN number itself.
Note: Encoding the same GTIN number with this class and with the
GS1-128
implementation will produce exactly the same barcode.
-
Field Summary
Fields inherited from class de.vwsoft.barcodelib4j.oned.ImplCode128
FNC1, FNC2, FNC3, FNC4
-
Method Summary
Modifier and TypeMethodDescriptionvoid
setContent
(String content, boolean autoComplete, boolean appendOptionalChecksum) Sets the GTIN number to be encoded in the barcode.Methods inherited from class de.vwsoft.barcodelib4j.oned.Barcode
clone, draw, draw, draw, getAddOn, getContent, getFont, getRatio, getText, getTextOffset, isFontSizeAdjusted, isOptionalChecksumVisible, isTextOnTop, isTextVisible, newInstance, newInstance, setAddOn, setCustomText, setFont, setFontSizeAdjusted, setOptionalChecksumVisible, setRatio, setTextOffset, setTextOnTop, setTextVisible, supportsAddOn, supportsCustomText, supportsOptionalChecksum, supportsRatio, supportsTextOnTop
-
Method Details
-
setContent
public void setContent(String content, boolean autoComplete, boolean appendOptionalChecksum) throws BarcodeException Sets the GTIN number to be encoded in the barcode.The number must be either 14 (with check digit) or 13 (without check digit) in length.
- If the number contains 14 digits, the 14th digit is checked to see if it is a valid check
digit. If the check digit is invalid, a
BarcodeException
is thrown. - If the number contains 13 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.
- Overrides:
setContent
in classImplEAN128
- Parameters:
content
- the GTIN number to be encoded in the barcodeautoComplete
- whether to automatically calculate and append a check digit if it is missingappendOptionalChecksum
- has no function, as GTIN 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 14 digits, the 14th digit is checked to see if it is a valid check
digit. If the check digit is invalid, a
-