net.sourceforge.jbarcodebean.model
Class Code93

java.lang.Object
  extended by net.sourceforge.jbarcodebean.model.AbstractBarcodeStrategy
      extended by net.sourceforge.jbarcodebean.model.Code93
All Implemented Interfaces:
BarcodeStrategy
Direct Known Subclasses:
Code93Extended

public class Code93
extends AbstractBarcodeStrategy


Nested Class Summary
 
Nested classes/interfaces inherited from class net.sourceforge.jbarcodebean.model.AbstractBarcodeStrategy
AbstractBarcodeStrategy.CharacterCode
 
Field Summary
protected static char SHIFT_DOLLAR
           
protected static char SHIFT_PERCENT
           
protected static char SHIFT_PLUS
           
protected static char SHIFT_SLASH
           
 
Fields inherited from interface net.sourceforge.jbarcodebean.model.BarcodeStrategy
MANDATORY_CHECKSUM, NO_CHECKSUM, OPTIONAL_CHECKSUM
 
Constructor Summary
Code93()
           
 
Method Summary
protected  java.lang.String augmentWithChecksum(java.lang.String text)
          Subclasses implement this method to calculate the checksum from the text to encode, and return a String containing the text with the checksum included.
 EncodedBarcode encode(java.lang.String textToEncode, boolean checked)
          This implementation carries out the following steps: Call AbstractBarcodeStrategy.preprocess(java.lang.String) Call AbstractBarcodeStrategy.augmentWithChecksum(java.lang.String) to add in the checksum Call AbstractBarcodeStrategy.postprocess(java.lang.String) Adds in the start and end sentinels Use the CharacterCode array returned by getCodes to encode the text into a barcode Insert left and right margins Return EncodedBarcode object
protected  java.lang.String getBarcodeLabelText(java.lang.String text)
          Subclasses implement this method to return the text which appears below the barcode.
protected  AbstractBarcodeStrategy.CharacterCode[] getCodes()
          Subclasses implement this method to return an array of CharacterCode objects, representing all possible encodings of bars and spaces for every encodable character.
protected  byte getMarginWidth()
          Sublclasses implement this method to return the width of the whitespace that must appear on each side of the barcode.
protected  char getStartSentinel()
          Subclasses implement this method to return the start sentinel character.
protected  char getStopSentinel()
          Subclasses implement this method to return the stop sentinel character.
protected  boolean isInterleaved()
          Subclasses must implement this method to return true or false depending on whether the barcode type is interleaved.
protected  java.lang.String postprocess(java.lang.String text)
          Subclasses implement this method to perform any postprocessing required to the text after including the checksum.
protected  java.lang.String preprocess(java.lang.String text)
          Subclasses implement this method to perform any preprocessing necessary on the original text to encode.
 int requiresChecksum()
          Subclasses implement this method to determine whether this type of barcode has a mandatory, optional or no checksum.
 
Methods inherited from class net.sourceforge.jbarcodebean.model.AbstractBarcodeStrategy
computeSize, getCharacterCode, getCharacterCode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHIFT_DOLLAR

protected static final char SHIFT_DOLLAR
See Also:
Constant Field Values

SHIFT_PERCENT

protected static final char SHIFT_PERCENT
See Also:
Constant Field Values

SHIFT_SLASH

protected static final char SHIFT_SLASH
See Also:
Constant Field Values

SHIFT_PLUS

protected static final char SHIFT_PLUS
See Also:
Constant Field Values
Constructor Detail

Code93

public Code93()
Method Detail

augmentWithChecksum

protected java.lang.String augmentWithChecksum(java.lang.String text)
                                        throws BarcodeException
Description copied from class: AbstractBarcodeStrategy
Subclasses implement this method to calculate the checksum from the text to encode, and return a String containing the text with the checksum included.

Specified by:
augmentWithChecksum in class AbstractBarcodeStrategy
Parameters:
text - The text to encode (after preprocessing - see AbstractBarcodeStrategy.preprocess(java.lang.String)).
Returns:
A String containing the text passed into the method, augmented with the checksum. For barcode types that don't support a checksum, this would simply be the text passed to the method.
Throws:
BarcodeException

getBarcodeLabelText

protected java.lang.String getBarcodeLabelText(java.lang.String text)
Description copied from class: AbstractBarcodeStrategy
Subclasses implement this method to return the text which appears below the barcode.

Specified by:
getBarcodeLabelText in class AbstractBarcodeStrategy
Parameters:
text - The raw text to encode.
Returns:
A String containing the text that will appear beneath the barcode.

getCodes

protected AbstractBarcodeStrategy.CharacterCode[] getCodes()
Description copied from class: AbstractBarcodeStrategy
Subclasses implement this method to return an array of CharacterCode objects, representing all possible encodings of bars and spaces for every encodable character.

Specified by:
getCodes in class AbstractBarcodeStrategy
Returns:
An array of CharacterCode objects, one for each possible character that can be encoded using this strategy.

getMarginWidth

protected byte getMarginWidth()
Description copied from class: AbstractBarcodeStrategy
Sublclasses implement this method to return the width of the whitespace that must appear on each side of the barcode.

Specified by:
getMarginWidth in class AbstractBarcodeStrategy
Returns:
The space that must appear on the left and right sides of the barcode expressed as a multiple of the narrowest bar width.

getStartSentinel

protected char getStartSentinel()
Description copied from class: AbstractBarcodeStrategy
Subclasses implement this method to return the start sentinel character.

Specified by:
getStartSentinel in class AbstractBarcodeStrategy
Returns:
The character, which when encoded into bars and spaces, appears on the left edge of every barcode (immediately after the left margin).

getStopSentinel

protected char getStopSentinel()
Description copied from class: AbstractBarcodeStrategy
Subclasses implement this method to return the stop sentinel character.

Specified by:
getStopSentinel in class AbstractBarcodeStrategy
Returns:
The character, which when encoded into bars and spaces, appears on the right edge of every barcode (just before the right margin).

isInterleaved

protected boolean isInterleaved()
Description copied from class: AbstractBarcodeStrategy
Subclasses must implement this method to return true or false depending on whether the barcode type is interleaved.

Specified by:
isInterleaved in class AbstractBarcodeStrategy
Returns:
true if barcode type is interleaved, false if it is not.

postprocess

protected java.lang.String postprocess(java.lang.String text)
Description copied from class: AbstractBarcodeStrategy
Subclasses implement this method to perform any postprocessing required to the text after including the checksum.

Specified by:
postprocess in class AbstractBarcodeStrategy
Parameters:
text - String to process (returned by AbstractBarcodeStrategy.augmentWithChecksum(java.lang.String)).
Returns:
String after postprocessing. If no postprocessing is required, the String passed to the method is returned.

preprocess

protected java.lang.String preprocess(java.lang.String text)
                               throws BarcodeException
Description copied from class: AbstractBarcodeStrategy
Subclasses implement this method to perform any preprocessing necessary on the original text to encode. The result of this method is the string that gets passed to the AbstractBarcodeStrategy.augmentWithChecksum(java.lang.String) method.

Specified by:
preprocess in class AbstractBarcodeStrategy
Parameters:
text - The raw text to encode.
Returns:
The string after preprocessing. If no preprocessing is required, the String passed to the method is returned.
Throws:
BarcodeException - Typically caused by passing in a String containing illegal characters (characters that cannot be encoded in this type of barcode).

requiresChecksum

public int requiresChecksum()
Description copied from interface: BarcodeStrategy
Subclasses implement this method to determine whether this type of barcode has a mandatory, optional or no checksum. Returns one of the constants defined in the interface.


encode

public EncodedBarcode encode(java.lang.String textToEncode,
                             boolean checked)
                      throws BarcodeException
Description copied from class: AbstractBarcodeStrategy
This implementation carries out the following steps:

Specified by:
encode in interface BarcodeStrategy
Overrides:
encode in class AbstractBarcodeStrategy
Parameters:
textToEncode - The raw text to encode.
checked - True if a checksum is to be calculated, False if not.
Returns:
The fully encoded barcode, represented as bars and spaces, wrapped in a EncodedBarcode object.
Throws:
BarcodeException - Typically caused by passing in a String containing illegal characters (characters that cannot be encoded in this type of barcode).


Copyright © 2004-2009 The JBarcodeBean project. All Rights Reserved.