Class POSTNETLogicImpl
java.lang.Object
org.krysalis.barcode4j.impl.postnet.POSTNETLogicImpl
Implements the United States Postal Service Postnet barcode.
- Version:
- $Id: POSTNETLogicImpl.java,v 1.3 2006-11-07 16:42:17 jmaerki Exp $
- Author:
- Chris Dolphy
-
Constructor Summary
ConstructorsConstructorDescriptionPOSTNETLogicImpl(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 POSTNET barcode.protected voidencodeChar(ClassicBarcodeLogicHandler logic, char c) Encodes a single character.voidgenerateBarcodeLogic(ClassicBarcodeLogicHandler logic, String msg) Generates the barcode logicReturns the currently active checksum mode.static booleanisIgnoredChar(char c) Checks if a character is an ignored character (such as a '-' (dash)).static StringRemoves ignored character from a valid POSTNET message.static booleanvalidateChecksum(String msg) Verifies the checksum for a message.
-
Constructor Details
-
POSTNETLogicImpl
Main constructor- Parameters:
mode- 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 POSTNET barcode.- 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
-
isIgnoredChar
public static boolean isIgnoredChar(char c) Checks if a character is an ignored character (such as a '-' (dash)).- Parameters:
c- character to check- Returns:
- True if the character is ignored
-
removeIgnoredCharacters
Removes ignored character from a valid POSTNET message.- Parameters:
msg- valid POSTNET message- Returns:
- the message but without ignored characters
-
getChecksumMode
Returns the currently active checksum mode.- Returns:
- the checksum mode
-
encodeChar
Encodes a single character.- Parameters:
logic- the logic handler to receive generated eventsc- the character to encode
-
generateBarcodeLogic
Generates the barcode logic- Parameters:
logic- the logic handler to receive generated eventsmsg- the message to encode
-