barcode4j 2.1.0

org.krysalis.barcode4j.impl.upcean
Class UPCEANLogicImpl

java.lang.Object
  extended by org.krysalis.barcode4j.impl.upcean.UPCEANLogicImpl
Direct Known Subclasses:
EAN13LogicImpl, EAN8LogicImpl, UPCALogicImpl, UPCELogicImpl

public abstract class UPCEANLogicImpl
extends java.lang.Object

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
protected static byte EVEN_PARITY
          Even parity character set
protected static byte LEFT_HAND_A
          Left hand A character set
protected static byte LEFT_HAND_B
          Left hand B character set
protected static byte ODD_PARITY
          Odd parity character set
protected static byte RIGHT_HAND
          Right hand character set
 
Constructor Summary
UPCEANLogicImpl(ChecksumMode mode)
          Main constructor
 
Method Summary
static char calcChecksum(java.lang.String msg)
          Calculates the check character for a given message
protected  void drawCenterGuard(ClassicBarcodeLogicHandler logic)
          Generates a center guard.
protected  void drawSideGuard(ClassicBarcodeLogicHandler logic)
          Generates a side guard.
protected  void drawSupplemental(ClassicBarcodeLogicHandler logic, java.lang.String supp)
          Generates events for a supplemental.
protected  void encodeChar(ClassicBarcodeLogicHandler logic, char c, int charset)
          Encodes a character.
abstract  void generateBarcodeLogic(ClassicBarcodeLogicHandler logic, java.lang.String msg)
          Generates the barcode logic.
 ChecksumMode getChecksumMode()
          Returns the current checksum mode.
protected static int getSupplementalLength(java.lang.String msg)
          Returns the length of the supplemental part of a UPC/EAN message.
protected static java.lang.String removeSupplemental(java.lang.String msg)
          Removes an optional supplemental (ex. "+20") from the message.
protected static java.lang.String retrieveSupplemental(java.lang.String msg)
          Returns the supplemental part of a UPC/EAN message if there is one.
static void validateMessage(java.lang.String msg)
          Validates a UPC/EAN message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEFT_HAND_A

protected static final byte LEFT_HAND_A
Left hand A character set

See Also:
Constant Field Values

LEFT_HAND_B

protected static final byte LEFT_HAND_B
Left hand B character set

See Also:
Constant Field Values

RIGHT_HAND

protected static final byte RIGHT_HAND
Right hand character set

See Also:
Constant Field Values

ODD_PARITY

protected static final byte ODD_PARITY
Odd parity character set

See Also:
Constant Field Values

EVEN_PARITY

protected static final byte EVEN_PARITY
Even parity character set

See Also:
Constant Field Values
Constructor Detail

UPCEANLogicImpl

public UPCEANLogicImpl(ChecksumMode mode)
Main constructor

Parameters:
mode - the checksum mode
Method Detail

getChecksumMode

public ChecksumMode getChecksumMode()
Returns the current checksum mode.

Returns:
the checksum mode

validateMessage

public static void validateMessage(java.lang.String msg)
Validates a UPC/EAN message. The method throws IllegalArgumentExceptions if an invalid message is passed.

Parameters:
msg - the message to validate

calcChecksum

public static char calcChecksum(java.lang.String msg)
Calculates the check character for a given message

Parameters:
msg - the message
Returns:
char the check character

encodeChar

protected void encodeChar(ClassicBarcodeLogicHandler logic,
                          char c,
                          int charset)
Encodes a character.

Parameters:
logic - the logic handler to receive generated events
c - the character to encode
charset - the character set to use

drawSideGuard

protected void drawSideGuard(ClassicBarcodeLogicHandler logic)
Generates a side guard.

Parameters:
logic - the logic handler to receive generated events

drawCenterGuard

protected void drawCenterGuard(ClassicBarcodeLogicHandler logic)
Generates a center guard.

Parameters:
logic - the logic handler to receive generated events

drawSupplemental

protected void drawSupplemental(ClassicBarcodeLogicHandler logic,
                                java.lang.String supp)
Generates events for a supplemental.

Parameters:
logic - the logic handler to receive generated events
supp - the supplemental

getSupplementalLength

protected static int getSupplementalLength(java.lang.String msg)
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

protected static java.lang.String removeSupplemental(java.lang.String msg)
Removes an optional supplemental (ex. "+20") from the message.

Parameters:
msg - a UPC/EAN message
Returns:
the message without the supplemental

retrieveSupplemental

protected static java.lang.String retrieveSupplemental(java.lang.String msg)
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

generateBarcodeLogic

public abstract void generateBarcodeLogic(ClassicBarcodeLogicHandler logic,
                                          java.lang.String msg)
Generates the barcode logic.

Parameters:
logic - the logic handler to receive generated events
msg - the message to encode

barcode4j 2.1.0

Copyright © 2000-2010 Jeremias Maerki. All rights reserved.