|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.jbarcodebean.model.AbstractBarcodeStrategy
public abstract class AbstractBarcodeStrategy
This abstract class, which implements the BarcodeStrategy
interface,
provides a basic implementation that is subclassed by all the concrete
classes that provide Code39, Interleaved Code25, Codabar, MSI and all
derivative encoding strategies.
Nested Class Summary | |
---|---|
static class |
AbstractBarcodeStrategy.CharacterCode
Inner class representing a character and its barcode encoding. |
Field Summary |
---|
Fields inherited from interface net.sourceforge.jbarcodebean.model.BarcodeStrategy |
---|
MANDATORY_CHECKSUM, NO_CHECKSUM, OPTIONAL_CHECKSUM |
Constructor Summary | |
---|---|
AbstractBarcodeStrategy()
|
Method Summary | |
---|---|
protected abstract 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. |
protected int |
computeSize(java.lang.String text)
Computes the length of the barcode (in bar/space modules) based on the text to encode. |
EncodedBarcode |
encode(java.lang.String textToEncode,
boolean checked)
This implementation carries out the following steps: Call preprocess(java.lang.String)
Call augmentWithChecksum(java.lang.String) to add in the checksum
Call 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 abstract java.lang.String |
getBarcodeLabelText(java.lang.String text)
Subclasses implement this method to return the text which appears below the barcode. |
protected AbstractBarcodeStrategy.CharacterCode |
getCharacterCode(char character)
Looks for the specified character to encode in the CharacterCode array returned by the getCodes() method. |
protected AbstractBarcodeStrategy.CharacterCode |
getCharacterCode(int check)
Looks for an entry in the CharacterCode array returned by the getCodes() method,
by its check attribute. |
protected abstract 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 abstract byte |
getMarginWidth()
Sublclasses implement this method to return the width of the whitespace that must appear on each side of the barcode. |
protected abstract char |
getStartSentinel()
Subclasses implement this method to return the start sentinel character. |
protected abstract char |
getStopSentinel()
Subclasses implement this method to return the stop sentinel character. |
protected abstract boolean |
isInterleaved()
Subclasses must implement this method to return true or false depending on whether the barcode type is interleaved. |
protected abstract 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 abstract java.lang.String |
preprocess(java.lang.String text)
Subclasses implement this method to perform any preprocessing necessary on the original text to encode. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.sourceforge.jbarcodebean.model.BarcodeStrategy |
---|
requiresChecksum |
Constructor Detail |
---|
public AbstractBarcodeStrategy()
Method Detail |
---|
protected abstract AbstractBarcodeStrategy.CharacterCode[] getCodes()
CharacterCode
objects, representing all possible encodings of bars and spaces for
every encodable character.
CharacterCode
objects, one for each possible character
that can be encoded using this strategy.protected abstract java.lang.String augmentWithChecksum(java.lang.String text) throws BarcodeException
text
- The text to encode (after preprocessing - see
preprocess(java.lang.String)
).
BarcodeException
protected abstract java.lang.String preprocess(java.lang.String text) throws BarcodeException
augmentWithChecksum(java.lang.String)
method.
text
- The raw text to encode.
BarcodeException
- Typically caused by passing in
a String containing illegal characters (characters that cannot be encoded in
this type of barcode).protected abstract boolean isInterleaved()
protected abstract char getStartSentinel()
protected abstract char getStopSentinel()
protected abstract byte getMarginWidth()
protected abstract java.lang.String getBarcodeLabelText(java.lang.String text)
text
- The raw text to encode.
protected abstract java.lang.String postprocess(java.lang.String text)
text
- String to process (returned by
augmentWithChecksum(java.lang.String)
).
public EncodedBarcode encode(java.lang.String textToEncode, boolean checked) throws BarcodeException
preprocess(java.lang.String)
augmentWithChecksum(java.lang.String)
to add in the checksumpostprocess(java.lang.String)
encode
in interface BarcodeStrategy
textToEncode
- The raw text to encode.checked
- True if a checksum is to be calculated, False if not.
EncodedBarcode
object.
BarcodeException
- Typically caused by passing in
a String containing illegal characters (characters that cannot be encoded in
this type of barcode).protected int computeSize(java.lang.String text) throws BarcodeException
text
- The text to encode including any check digit,
start and end sentinels.
BarcodeException
- Typically
occurs if attempting to encode invalid characters.protected AbstractBarcodeStrategy.CharacterCode getCharacterCode(char character)
getCodes()
method.
character
- The character to encode.
protected AbstractBarcodeStrategy.CharacterCode getCharacterCode(int check)
getCodes()
method,
by its check attribute.
check
- The check attribute of the character being sought.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |