org.faceless.pdf2
Class MaxiCode

java.lang.Object
  extended byorg.faceless.pdf2.AbstractBarCode
      extended byorg.faceless.pdf2.MaxiCode

public class MaxiCode
extends org.faceless.pdf2.AbstractBarCode

The MaxiCode class represents the two-dimensional Barcode methodology called "MaxiCode", originally developed by UPS to barcode packages for delivery, and now in the public domain.

MaxiCodes are always a fixed size - 80 points square - and may encode up to 93 alphanumeric characters or 138 numbers, using reed-solomon error correction to ensure accurate scanning. Only the first 256 Unicode characters (equivalent to ISO-8859-1) may be used - although the full MaxiCode specification theoretically allows other character sets to be used, we don't support them yet.

This API provides three possible ways to create a MaxiCode: Symbols in a MaxiCode are represented using one of 6 "Code Sets", which are switched between to allow the entire 256 character range to be represented in 6 bits. This is normally done automatically, but for more control the user may insert control characters like SHIFTA, LATCHB and LOCK directly into their text.

Note that when calling the PDFPage.drawBarCode or PDFCanvas.drawBarCode method, the size of the barcode should be equal to exactly 80 points. This is the equivalent of 28.2222mm or 1.1111 inches. This allows for the size of the actual code (25.5mm square) plus the required quiet space around it.

Since:
2.0.9
See Also:
PDFPage.drawBarCode, PDFCanvas.drawBarCode, BarCode

Field Summary
static char GS
          Represents the "Group Seperator" characters, or 'U+001D'.
static char LATCHA
          Represents the "LATCH-A" control character, for possible inclusion in the barcode
static char LATCHB
          Represents the "LATCH-B" control character, for possible inclusion in the barcode
static char LOCK
          Represents the "LOCK-A", "LOCK-B" and "LOCK-C" control characters, for possible inclusion in the barcode
static char SHIFTA
          Represents the "SHIFT-A" control character, for possible inclusion in the barcode
static char SHIFTB
          Represents the "SHIFT-B" control character, for possible inclusion in the barcode
static char SHIFTC
          Represents the "SHIFT-C" control character, for possible inclusion in the barcode
static char SHIFTD
          Represents the "SHIFT-D" control character, for possible inclusion in the barcode
static char SHIFTE
          Represents the "SHIFT-E" control character, for possible inclusion in the barcode
static char THREESHIFTA
          Represents the "3 SHIFT-A" control character, for possible inclusion in the barcode
static char TWOSHIFTA
          Represents the "2 SHIFT-A" control character, for possible inclusion in the barcode
 
Constructor Summary
MaxiCode(byte[] b)
          Create a MaxiCode using the specified raw bytes.
MaxiCode(int service, String postcode, int country, String address)
          Create a new MaxiCode representing an address.
MaxiCode(String in, boolean eec)
          Create a new MaxiCode representing an address with the specified message.
 
Method Summary
static int getCountryCode(String code)
          Given a two-letter ISO-3166 country code, return the equivalent numeric code to be passed in to the MaxiCode constructor.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHIFTA

public static final char SHIFTA
Represents the "SHIFT-A" control character, for possible inclusion in the barcode

See Also:
Constant Field Values

SHIFTB

public static final char SHIFTB
Represents the "SHIFT-B" control character, for possible inclusion in the barcode

See Also:
Constant Field Values

SHIFTC

public static final char SHIFTC
Represents the "SHIFT-C" control character, for possible inclusion in the barcode

See Also:
Constant Field Values

SHIFTD

public static final char SHIFTD
Represents the "SHIFT-D" control character, for possible inclusion in the barcode

See Also:
Constant Field Values

SHIFTE

public static final char SHIFTE
Represents the "SHIFT-E" control character, for possible inclusion in the barcode

See Also:
Constant Field Values

TWOSHIFTA

public static final char TWOSHIFTA
Represents the "2 SHIFT-A" control character, for possible inclusion in the barcode

See Also:
Constant Field Values

THREESHIFTA

public static final char THREESHIFTA
Represents the "3 SHIFT-A" control character, for possible inclusion in the barcode

See Also:
Constant Field Values

LATCHA

public static final char LATCHA
Represents the "LATCH-A" control character, for possible inclusion in the barcode

See Also:
Constant Field Values

LATCHB

public static final char LATCHB
Represents the "LATCH-B" control character, for possible inclusion in the barcode

See Also:
Constant Field Values

LOCK

public static final char LOCK
Represents the "LOCK-A", "LOCK-B" and "LOCK-C" control characters, for possible inclusion in the barcode

See Also:
Constant Field Values

GS

public static final char GS
Represents the "Group Seperator" characters, or 'U+001D'. This is commonly used when creating addresses for delivery, and is included here for convinence.

See Also:
Constant Field Values
Constructor Detail

MaxiCode

public MaxiCode(String in,
                boolean eec)
Create a new MaxiCode representing an address with the specified message. For example, to create a mode 5 maxicode using extended error correction, try
 MaxiCode code = new MaxiCode("This is my first MaxiCode", true);
 page.drawBarCode(code, x, y, x+72, y+72);
 
If the message begins "])>" then it will be parsed as a "Structured Carrier Message" (an address) according to the section B.2 of the MaxiCode specification.

Parameters:
in - the string to encode in the message
eec - whether to use Extended Error Correction (mode 5). If the message is a Structured Carrier Message, this parameter is ignored.

MaxiCode

public MaxiCode(int service,
                String postcode,
                int country,
                String address)
Create a new MaxiCode representing an address. Both numeric and alphanumeric postcodes can be supplied, which will result in mode 2 or 3 MaxiCodes respectively. For example, to create a MaxiCode for a Belgian delivery address.
 MaxiCode code = new MaxiCode(999, "B1050", getCountryCode("BE"),
     "Comité Européean de Normalisation"+MaxiCode.GS+
     "rue de Stassart 36"+MaxiCode.GS+"Bruxelles"
 
and, for a US one
 MaxiCode code = new MaxiCode(1, "524032140", getCountryCode("US"),
     "AIM USA"+MaxiCode.GS+"634 ALPHA DRIVE"+MaxiCode.GS+"PITTSBURGH PA");
 

Parameters:
service - The service level, from 1 to 999. We don't know what this means, but it's part of the spec.
postcode - the postcode of the address, either up to nine numeric digits or up to six alphanumeric digits
country - the numeric ISO-3166 country code. If you only have the two-letter ISO country code, the getCountryCode(java.lang.String) method will return the numeric equivalent
address - the address to place in the secondary message. Lines in the address should be separated with the GS character.

MaxiCode

public MaxiCode(byte[] b)
Create a MaxiCode using the specified raw bytes. The supplied array must contain exactly 864 elements representing each module in the MaxiCode barcode, where a non-zero value represents a black hexagon.

Parameters:
b - a byte array exactly 864 bytes long.
Method Detail

getCountryCode

public static final int getCountryCode(String code)
Given a two-letter ISO-3166 country code, return the equivalent numeric code to be passed in to the MaxiCode constructor.

Parameters:
code - the two-letter ISO-3166 country code
Returns:
the numeric ISO-3166 country code
Throws:
IllegalArgumentException - if no such country code exists


Copyright © 2001-2004 Big Faceless Organization