Class UPCEANLogicImpl
java.lang.Object
org.krysalis.barcode4j.impl.upcean.UPCEANLogicImpl
- Direct Known Subclasses:
EAN13LogicImpl,EAN8LogicImpl,UPCALogicImpl,UPCELogicImpl
This is an abstract base class for UPC and EAN barcodes.
- Version:
- $Id: UPCEANLogicImpl.java,v 1.1 2004-09-12 17:57:52 jmaerki Exp $
- Author:
- Jeremias Maerki
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final byteEven parity character setprotected static final byteLeft hand A character setprotected static final byteLeft hand B character setprotected static final byteOdd parity character setprotected static final byteRight hand character set -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic charcalcChecksum(String msg) Calculates the check character for a given messageprotected voidGenerates a center guard.protected voidGenerates a side guard.protected voiddrawSupplemental(ClassicBarcodeLogicHandler logic, String supp) Generates events for a supplemental.protected voidencodeChar(ClassicBarcodeLogicHandler logic, char c, int charset) Encodes a character.abstract voidgenerateBarcodeLogic(ClassicBarcodeLogicHandler logic, String msg) Generates the barcode logic.Returns the current checksum mode.protected static intReturns the length of the supplemental part of a UPC/EAN message.protected static StringremoveSupplemental(String msg) Removes an optional supplemental (ex.protected static StringReturns the supplemental part of a UPC/EAN message if there is one.static voidvalidateMessage(String msg) Validates a UPC/EAN message.
-
Field Details
-
LEFT_HAND_A
protected static final byte LEFT_HAND_ALeft hand A character set- See Also:
-
LEFT_HAND_B
protected static final byte LEFT_HAND_BLeft hand B character set- See Also:
-
RIGHT_HAND
protected static final byte RIGHT_HANDRight hand character set- See Also:
-
ODD_PARITY
protected static final byte ODD_PARITYOdd parity character set- See Also:
-
EVEN_PARITY
protected static final byte EVEN_PARITYEven parity character set- See Also:
-
-
Constructor Details
-
UPCEANLogicImpl
Main constructor- Parameters:
mode- the checksum mode
-
-
Method Details
-
validateMessage
Validates a UPC/EAN message. The method throws IllegalArgumentExceptions if an invalid message is passed.- Parameters:
msg- the message to validate
-
calcChecksum
Calculates the check character for a given message- Parameters:
msg- the message- Returns:
- char the check character
-
getSupplementalLength
Returns the length of the supplemental part of a UPC/EAN message. The method throws an IllegalArgumentException if the supplement is malformed.- Parameters:
msg- the UPC/EAN message- Returns:
- 2 or 5 if there is a supplemental, 0 if there's none.
-
removeSupplemental
Removes an optional supplemental (ex. "+20") from the message.- Parameters:
msg- a UPC/EAN message- Returns:
- the message without the supplemental
-
retrieveSupplemental
Returns the supplemental part of a UPC/EAN message if there is one. Supplementals are added in the form: "+[supplemental]" (ex. "+20").- Parameters:
msg- a UPC/EAN message- Returns:
- the supplemental part, null if there is none
-
getChecksumMode
Returns the current checksum mode.- Returns:
- the checksum mode
-
encodeChar
Encodes a character.- Parameters:
logic- the logic handler to receive generated eventsc- the character to encodecharset- the character set to use
-
drawSideGuard
Generates a side guard.- Parameters:
logic- the logic handler to receive generated events
-
drawCenterGuard
Generates a center guard.- Parameters:
logic- the logic handler to receive generated events
-
drawSupplemental
Generates events for a supplemental.- Parameters:
logic- the logic handler to receive generated eventssupp- the supplemental
-
generateBarcodeLogic
Generates the barcode logic.- Parameters:
logic- the logic handler to receive generated eventsmsg- the message to encode
-