Class Interleaved2Of5LogicImpl
java.lang.Object
org.krysalis.barcode4j.impl.int2of5.Interleaved2Of5LogicImpl
- Direct Known Subclasses:
ITF14LogicImpl
This class is an implementation of the Interleaved 2 of 5 barcode.
- Version:
- $Id: Interleaved2Of5LogicImpl.java,v 1.3 2009-02-19 10:14:54 jmaerki Exp $
-
Constructor Summary
ConstructorsConstructorDescriptionInterleaved2Of5LogicImpl(ChecksumMode mode, boolean displayChecksum) Main constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic charcalcChecksum(String msg) Calculates the checksum for a message to be encoded as an Interleaved 2 of 5 barcode.static charcalcChecksum(String msg, int oddMultiplier, int evenMultiplier) Calculates the checksum for a message to be encoded as an Interleaved 2 of 5 barcode.protected StringdoHandleChecksum(StringBuffer sb, ChecksumMode mode) Handles the checksum based on the given checksum mode.voidgenerateBarcodeLogic(ClassicBarcodeLogicHandler logic, String msg) Generates the barcode logic.Returns the current checksum modeprotected StringHandles the checksum based on the checksum mode.static booleanvalidateChecksum(String msg) Verifies the checksum for a message.
-
Constructor Details
-
Interleaved2Of5LogicImpl
Main constructor.- Parameters:
mode- the checksum modedisplayChecksum- Controls whether to display checksum in the human-readable message
-
-
Method Details
-
calcChecksum
Calculates the checksum for a message to be encoded as an Interleaved 2 of 5 barcode. The algorithm is a weighted modulo 10 scheme.- Parameters:
msg- message to calculate the check digit foroddMultiplier- multiplier to be used for odd positions (usually 3 or 4)evenMultiplier- multiplier to be used for even positions (usually 1 or 9)- Returns:
- char the check digit
-
calcChecksum
Calculates the checksum for a message to be encoded as an Interleaved 2 of 5 barcode. The algorithm is a weighted modulo 10 scheme. This method uses the default specification (ITF-14, EAN-14, SSC-14, DUN14 and USPS).- Parameters:
msg- message to calculate the check digit for- Returns:
- char the check digit
-
validateChecksum
Verifies the checksum for a message.- Parameters:
msg- message (check digit included)- Returns:
- boolean True, if the checksum is correct
-
getChecksumMode
Returns the current checksum mode- Returns:
- the checksum mode
-
doHandleChecksum
Handles the checksum based on the given checksum mode. The checksum is either checked, ignored or attached to the given string buffer.- Parameters:
sb- the string buffer containing the messagemode- the checksum mode- Returns:
- the updated string after checksum processing (for the human-readable part)
-
handleChecksum
Handles the checksum based on the checksum mode. The checksum is either checked, ignored or attached to the given string buffer.- Parameters:
sb- the string buffer containing the message- Returns:
- the updated string after checksum processing (for the human-readable part)
-
generateBarcodeLogic
Generates the barcode logic.- Parameters:
logic- the logic handler to receive generated eventsmsg- the message to encode
-