Enum Class BarcodeType
- All Implemented Interfaces:
Serializable
,Comparable<BarcodeType>
,Constable
- Author:
- Christopher Mindus
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
Enum Constant Summary
Enum ConstantDescriptionAztec Code is a type of 2D barcode invented by Andrew Longacre, Jr.Codabar is a linear barcode symbology developed in 1972 by Pitney Bowes Corp.Code 128 is a high-density linear barcode symbology defined in ISO/IEC 15417:2007.Code 39 (also known as Alpha39, Code 3 of 9, Code 3/9, Type 39, USS Code 39, or USD-3) is a variable length, discrete barcode symbology.Code 93 is a barcode symbology designed in 1982 by Intermec to provide a higher density and data security enhancement to Code 39.A Data Matrix is a two-dimensional code consisting of black and white "cells" or dots arranged in either a square or rectangular pattern, also known as a matrix.The International Article Number (also known as European Article Number or EAN) is a standard describing a barcode symbology and numbering system used in global trade to identify a specific retail product type, in a specific packaging configuration, from a specific manufacturer.An EAN-8 is an EAN/UPC symbology barcode and is derived from the longer International Article Number (EAN-13) code.In telecommunication, a two-out-of-five code is an m of n code that provides exactly ten possible combinations, and thus is popular for representing decimal digits using five bits.PDF417 is a stacked linear barcode format used in a variety of applications such as transport, identification cards, and inventory management.A QR code (abbreviated from Quick Response code) is a type of matrix barcode (or two-dimensional barcode) first designed in 1994 for the automotive industry in Japan.The Universal Product Code (UPC) (redundantly: UPC code) is a barcode symbology that is widely used in the United States, Canada, Europe, Australia, New Zealand, and other countries for tracking trade items in stores.To allow the use of UPC barcodes on smaller packages, where a full 12-digit barcode may not fit, a 'zero-suppressed' version of UPC was developed, called UPC-E, in which the number system digit, all trailing zeros in the manufacturer code, and all leading zeros in the product code, are suppressed (omitted).Field Summary
Modifier and TypeFieldDescriptionfinal BarcodeFormat
The barcode format for the encoder.final boolean
Flag indicating the bar code is two-dimensional and generally needs a size to be represented.final String
The lower case name of this "enum", used for URN strings.static final String
Error message when barcode text isnull
when validating it.Method Summary
Modifier and TypeMethodDescriptionprotected abstract Writer
Creates the writer used for barcode encoding.createBarcodeURN
(String text, int width, int height) Creates a BarcodeURN for a barcode type.createBarcodeURN
(String text, int width, int height, ErrorCorrectionLevel errorCorrectionLevel) Creates a BarcodeURN for a barcode type.Gets theBarcodeBuilder
initialized with the barcode type or format of this instance.static BarcodeType
from
(BarcodeFormat format) Looks up aBarcodeType
barcode type from a ZxingBarcodeFormat
.static BarcodeType
Looks up aBarcodeType
barcode type from a case sensitive string.Creates an SVG image for the barcode type or format.getSVG
(String text, int width, int height, ErrorCorrectionLevel errorCorrectionLevel) Creates an SVG image for the barcode type or format.Gets the writer used to encode barcodes, or to validate the data string.boolean
Checks if a data string is valid.Validates the data string for the barcode type or format.static BarcodeType
Returns the enum constant of this class with the specified name.static BarcodeType[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
Enum Constant Details
AZTEC
Aztec Code is a type of 2D barcode invented by Andrew Longacre, Jr. and Robert Hussey in 1995. The code was published by AIM, Inc. in 1997. Although the Aztec code was patented, that patent was officially made public domain. The Aztec Code is also published as ISO/IEC 24778:2008 standard. Named after the resemblance of the central finder pattern to an Aztec pyramid, Aztec Code has the potential to use less space than other matrix barcodes because it does not require a surrounding blank "quiet zone".CODABAR
Codabar is a linear barcode symbology developed in 1972 by Pitney Bowes Corp. It and its variants are also known as Codeabar, Ames Code, NW-7, Monarch, Code 2 of 7, Rationalized Codabar, ANSI/AIM BC3-1995 or USD-4. Although Codabar has not been registered for US federal trademark status, its hyphenated variant Code-a-bar is a registered trademark.Codabar was designed to be accurately read even when printed on dot-matrix printers for multi-part forms such as FedEx airbills and blood bank forms, where variants are still in use as of 2007. Although newer symbologies hold more information in a smaller space, Codabar has a large installed base in libraries. It is even possible to print Codabar codes using typewriter-like impact printers, which allows the creation of many codes with consecutive numbers without having to use computer equipment. After each printed code, the printer's stamp is mechanically turned to the next number, as for example in mechanical mile counters.
CODE_39
Code 39 (also known as Alpha39, Code 3 of 9, Code 3/9, Type 39, USS Code 39, or USD-3) is a variable length, discrete barcode symbology.The Code 39 specification defines 43 characters, consisting of uppercase letters (A through Z), numeric digits (0 through 9) and a number of special characters (-, ., $, /, +, %, and space). An additional character (denoted '*') is used for both start and stop delimiters. Each character is composed of nine elements: five bars and four spaces. Three of the nine elements in each character are wide (binary value 1), and six elements are narrow (binary value 0). The width ratio between narrow and wide is not critical, and may be chosen between 1:2 and 1:3.
The barcode itself does not contain a check digit (in contrast to — for instance — Code 128), but it can be considered self-checking on the grounds that a single erroneously interpreted bar cannot generate another valid character. Possibly the most serious drawback of Code 39 is its low data density: It requires more space to encode data in Code 39 than, for example, in Code 128. This means that very small goods cannot be labeled with a Code 39 based barcode. However, Code 39 is still used by some postal services (although the Universal Postal Union recommends using Code 128 in all cases), and can be decoded with virtually any barcode reader. One advantage of Code 39 is that since there is no need to generate a check digit, it can easily be integrated into an existing printing system by adding a barcode font to the system or printer and then printing the raw data in that font.
Code 39 was developed by Dr. David Allais and Ray Stevens of Intermec in 1974. Their original design included two wide bars and one wide space in each character, resulting in 40 possible characters. Setting aside one of these characters as a start and stop pattern left 39 characters, which was the origin of the name Code 39. Four punctuation characters were later added, using no wide bars and three wide spaces, expanding the character set to 43 characters. Code 39 was later standardized as ANSI MH 10.8 M-1983 and MIL-STD-1189. MIL-STD-1189 has been cancelled and replaced by ANSI/AIM BC1/1995, Uniform Symbology Specification — Code 39.
CODE_93
Code 93 is a barcode symbology designed in 1982 by Intermec to provide a higher density and data security enhancement to Code 39. It is an alphanumeric, variable length symbology. Code 93 is used primarily by Canada Post to encode supplementary delivery information. Every symbol includes two check characters.Each Code 93 character is nine modules wide, and always has three bars and three spaces, thus the name. Each bar and space is from 1 to 4 modules wide. (For comparison, a Code 39 character consists of five bars and four spaces, three of which are wide, for a total width of 13–16 modules).
Code 93 is designed to encode the same 26 upper case letters, 10 digits and 7 special characters as code 39:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 - . $ / + % SPACE
In addition to 43 characters, Code 93 defines 5 special characters (including a start/stop character), which can be combined with other characters to unambiguously represent all 128 ASCII characters.
CODE_128
Code 128 is a high-density linear barcode symbology defined in ISO/IEC 15417:2007. It is used for alphanumeric or numeric-only barcodes. It can encode all 128 characters of ASCII and, by use of an extension symbol (FNC4), the Latin-1 characters defined in ISO/IEC 8859-1.[citation needed]. It generally results in more compact barcodes compared to other methods like Code 39, especially when the texts contain mostly digits.GS1-128 (formerly known as UCC/EAN-128) is a subset of Code 128 and is used extensively worldwide in shipping and packaging industries as a product identification code for the container and pallet levels in the supply chain.
DATA_MATRIX
A Data Matrix is a two-dimensional code consisting of black and white "cells" or dots arranged in either a square or rectangular pattern, also known as a matrix. The information to be encoded can be text or numeric data. Usual data size is from a few bytes up to 1556 bytes. The length of the encoded data depends on the number of cells in the matrix. Error correction codes are often used to increase reliability: even if one or more cells are damaged so it is unreadable, the message can still be read. A Data Matrix symbol can store up to 2,335 alphanumeric characters.Data Matrix symbols are rectangular, usually square in shape and composed of square "cells" which represent bits. Depending on the coding used, a "light" cell represents a 0 and a "dark" cell is a 1, or vice versa. Every Data Matrix is composed of two solid adjacent borders in an "L" shape (called the "finder pattern") and two other borders consisting of alternating dark and light "cells" or modules (called the "timing pattern"). Within these borders are rows and columns of cells encoding information. The finder pattern is used to locate and orient the symbol while the timing pattern provides a count of the number of rows and columns in the symbol. As more data is encoded in the symbol, the number of cells (rows and columns) increases. Each code is unique. Symbol sizes vary from 10×10 to 144×144 in the new version ECC 200, and from 9×9 to 49×49 in the old version ECC 000 – 140.
EAN_8
An EAN-8 is an EAN/UPC symbology barcode and is derived from the longer International Article Number (EAN-13) code. It was introduced for use on small packages where an EAN-13 barcode would be too large; for example on cigarettes, pencils, and chewing gum packets. It is encoded identically to the 12 digits of the UPC-A barcode, except that it has 4 (rather than 6) digits in each of the left and right halves.EAN-8 barcodes may be used to encode GTIN-8 (8-digit Global Trade Identification Numbers) which are product identifiers from the GS1 System. A GTIN-8 begins with a 2- or 3-digit GS1 prefix (which is assigned to each national GS1 authority) followed by a 5- or 4-digit item reference element depending on the length of the GS1 prefix), and a checksum digit.
EAN-8 codes are common throughout the world, and companies may also use them to encode RCN-8 (8-digit Restricted Circulation Numbers), and use them to identify own-brand products sold only in their stores. RCN-8 are a subset of GTIN-8 which begin with a first digit of 0 or 2.
This method may return bigger size image when specified size is too small. You can set both
width
andheight
to zero to get minimum size barcode.EAN_13
The International Article Number (also known as European Article Number or EAN) is a standard describing a barcode symbology and numbering system used in global trade to identify a specific retail product type, in a specific packaging configuration, from a specific manufacturer. The standard has been subsumed in the Global Trade Item Number standard from the GS1 organization; the same numbers can be referred to as GTINs and can be encoded in other barcode symbologies defined by GS1. EAN barcodes are used worldwide for lookup at retail point of sale, but can also be used as numbers for other purposes such as wholesale ordering or accounting.The most commonly used EAN standard is the thirteen-digit EAN-13, a superset of the original 12-digit Universal Product Code (UPC-A) standard developed in 1970 by George J. Laurer.[1] An EAN-13 number includes a 3-digit GS1 prefix (indicating country of registration or special type of product). A prefix with a first digit of "0" indicates a 12-digit UPC-A code follows. A prefix with first two digits of "45" or "49" indicates a Japanese Article Number (JAN) follows.
The less commonly used 8-digit EAN-8 barcode was introduced for use on small packages, where EAN-13 would be too large. 2-digit EAN-2 and 5-digit EAN-5 are supplemental barcodes, placed on the right-hand side of EAN-13 or UPC. These are generally used for periodicals like magazines or books, to indicate the current year's issue number; and weighed products like food, to indicate the manufacturer's suggested retail price.
See https://en.wikipedia.org/wiki/International_Article_Number.
ITF
In telecommunication, a two-out-of-five code is an m of n code that provides exactly ten possible combinations, and thus is popular for representing decimal digits using five bits. There are ways to assign weights to each bit such that the set bits sum to the desired value, with an exception for zero.According to Federal Standard 1037C:
- each decimal digit is represented by a binary numeral consisting of five bits of which two are of one kind, called "ones," and three are of the other kind, called "zeros", and
- the usual weights assigned to the bit positions are 0-1-2-3-6. However, in this scheme, zero is encoded as "binary" 01100; strictly speaking the 0-1-2-3-6 previously claimed is just a mnemonic device.
The weights give a unique encoding for most digits, but allow two encodings for 3: 0+3 or 10010 and 1+2 or 01100. The former is used to encode the digit 3, and the latter is used to represent the otherwise unrepresentable zero.
The IBM 7070, IBM 7072, and IBM 7074 computers used this code to represent each of the ten decimal digits in a machine word, although they numbered the bit positions 0-1-2-3-4, rather than with weights. Each word also had a sign flag, encoded using a two-out-of-three code, that could be A Alphanumeric, − Minus, or + Plus. When copied to a digit, the three bits were placed in bit positions 0-3-4. (Thus producing the numeric values 3, 6 and 9, respectively).
PDF_417
PDF417 is a stacked linear barcode format used in a variety of applications such as transport, identification cards, and inventory management. "PDF" stands for Portable Data File. The "417" signifies that each pattern in the code consists of 4 bars and spaces in a pattern that is 17 units (modules) long. The PDF417 symbology was invented by Ynjiun P. Wang at Symbol Technologies in 1991 (Wang 1993). It is defined in ISO standard 15438.PDF417 is used in many applications by both commercial and government organizations. PDF417 is one of the formats (along with Data Matrix) that can be used to print postage accepted by the United States Postal Service. PDF417 is also used by the airline industry's Bar Coded Boarding Pass (BCBP) standard as the 2D bar code symbolism for paper boarding passes. PDF417 is the standard selected by the Department of Homeland Security as the machine readable zone technology for RealID compliant driver licenses and state issued identification cards. PDF417 barcodes are also included on visas and border crossing cards issued by the State of Israel (example).
QR_CODE
A QR code (abbreviated from Quick Response code) is a type of matrix barcode (or two-dimensional barcode) first designed in 1994 for the automotive industry in Japan. A barcode is a machine-readable optical label that contains information about the item to which it is attached. In practice, QR codes often contain data for a locator, identifier, or tracker that points to a website or application. A QR code uses four standardized encoding modes (numeric, alphanumeric, byte/binary, and kanji) to store data efficiently; extensions may also be used.The Quick Response system became popular outside the automotive industry due to its fast readability and greater storage capacity compared to standard UPC barcodes. Applications include product tracking, item identification, time tracking, document management, and general marketing.
A QR code consists of black squares arranged in a square grid on a white background, which can be read by an imaging device such as a camera, and processed using Reed–Solomon error correction until the image can be appropriately interpreted. The required data is then extracted from patterns that are present in both horizontal and vertical components of the image.
UPC_A
The Universal Product Code (UPC) (redundantly: UPC code) is a barcode symbology that is widely used in the United States, Canada, Europe, Australia, New Zealand, and other countries for tracking trade items in stores.UPC (technically refers to UPC-A) consists of 12 numeric digits that are uniquely assigned to each trade item. Along with the related EAN barcode, the UPC is the barcode mainly used for scanning of trade items at the point of sale, per GS1 specifications. UPC data structures are a component of GTINs and follow the global GS1 specification, which is based on international standards. But some retailers (clothing, furniture) do not use the GS1 system (rather other barcode symbologies or article number systems). On the other hand, some retailers use the EAN/UPC barcode symbology, but without using a GTIN (for products sold in their own stores only).
UPC_E
To allow the use of UPC barcodes on smaller packages, where a full 12-digit barcode may not fit, a 'zero-suppressed' version of UPC was developed, called UPC-E, in which the number system digit, all trailing zeros in the manufacturer code, and all leading zeros in the product code, are suppressed (omitted). This symbology differs from UPC-A in that it only uses a 6-digit code, does not use M (middle) guard pattern, and the E (end) guard pattern is formed as space-bar-space-bar-space-bar, i.e. UPC-E barcode follows the pattern SDDDDDDE. The way in which a 6-digit UPC-E relates to a 12-digit UPC-A, is determined by UPC-E numerical pattern and UPC-E parity pattern. It can only correspond to UPC-A number system 0 or 1, the value of which, along with the UPC-A check digit, determines the UPC-E parity pattern of the encoding.See https://en.wikipedia.org/wiki/Universal_Product_Code#UPC-E.
Field Details
format
The barcode format for the encoder.lowerCase
The lower case name of this "enum", used for URN strings.isTwoDimensional
public final boolean isTwoDimensionalFlag indicating the bar code is two-dimensional and generally needs a size to be represented.TEXT_IS_NULL_ERROR
Error message when barcode text isnull
when validating it.- See Also:
Method Details
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
from
Looks up aBarcodeType
barcode type from a case sensitive string.- Parameters:
type
- The type string to find.- Returns:
- The
BarcodeType
for thetype
string, ornull
if not found.
from
Looks up aBarcodeType
barcode type from a ZxingBarcodeFormat
.- Parameters:
format
- The ZxingBarcodeFormat
to match with a barcode type.- Returns:
- The
BarcodeType
for theformat
, ornull
if not found.
createBuilder
Gets theBarcodeBuilder
initialized with the barcode type or format of this instance. TheBarcodeBuilder
has a more fine-grained control over parameters that can be set.- Returns:
- A new
{@link BarcodeBuilder}
initialized with this barcode type or format.
_createWriter
Creates the writer used for barcode encoding.- Returns:
- The Writer.
getWriter
Gets the writer used to encode barcodes, or to validate the data string.- Returns:
- The writer singleton.
getSVG
Creates an SVG image for the barcode type or format.Please note that the
QR_CODE
type/format also supports specifying an error correction level. This method will use the default "L
ow" error correction level (~7%) that is default for QR codes.For better control of the barcode and additional parameters use the
BarcodeBuilder
from a call to{@link BarcodeType#createBuilder()}
.This method call is equivalent with calling:
createBuilder() .text(text) .size(width,height) .asSVG();
- Parameters:
text
- The barcode text.width
- The preferred width, or zero for smallest.height
- The preferred height, or zero for smallest.- Returns:
- The SVG image string without XML header.
- Throws:
BarcodeException
- For barcode parameter errors.
getSVG
public String getSVG(String text, int width, int height, ErrorCorrectionLevel errorCorrectionLevel) throws BarcodeException Creates an SVG image for the barcode type or format.Please note that only the
QR_CODE
type/format supports specifying an error correction level. The parameter will be ignored if specified for other than theQR_CODE
type/format.For better control of the barcode and additional parameters use the
BarcodeBuilder
from a call to{@link BarcodeType#createBuilder()}
.This method call is equivalent with calling:
createBuilder() .text(text) .size(width,height) .errorCorrection(errorCorrectionLevel) .asSVG();
- Parameters:
text
- The barcode text.width
- The preferred width, or zero for smallest.height
- The preferred height, or zero for smallest.errorCorrectionLevel
- TheErrorCorrectionLevel
enum has the values:L
= ~7% correctionM
= ~15% correctionQ
= ~25% correctionH
= ~30% correction
Setting the parameter to
null
will default toErrorCorrectionLevel.L
= ~7% correction.- Returns:
- The SVG image string without XML header.
- Throws:
BarcodeException
- For barcode parameter errors.
validate
Validates the data string for the barcode type or format.- Parameters:
text
- The text string.- Returns:
- Error, or
null
for valid data string. The error stringTEXT_IS_NULL_ERROR
ifdata
isnull
.
isValid
Checks if a data string is valid.- Parameters:
text
- The text string.- Returns:
- The validity flag,
false
ifdata
isnull
.
createBarcodeURN
Creates a BarcodeURN for a barcode type.Note: if you specify a width or height that is too small, the resulting barcode might be larger.
For better control of the barcode and additional parameters use the
BarcodeBuilder
from a call to{@link BarcodeType#createBuilder()}
.This method call is equivalent with calling:
createBuilder().text(text).size(width,height).asURN();
- Parameters:
text
- The barcode text string, must benon-null
.width
- The width, or zero for smallest, negative width is set to zero (smallest).height
- The height, or zero for smallest, negative height is set to zero (smallest).- Throws:
BarcodeException
- If there are missing or invalid parameters assigned in this builder encountered during barcode encoding.
createBarcodeURN
public BarcodeURN createBarcodeURN(String text, int width, int height, ErrorCorrectionLevel errorCorrectionLevel) throws BarcodeException Creates a BarcodeURN for a barcode type.Note: if you specify a width or height that is too small, the resulting barcode might be larger.
For better control of the barcode and additional parameters use the
BarcodeBuilder
from a call to{@link BarcodeType#createBuilder()}
.This method call is equivalent with calling:
createBuilder().text(text).size(width,height).errorCorrection(errorCorrectionLevel).asURN();
- Parameters:
text
- The barcode text string, must benon-null
.width
- The width, or zero for smallest, negative width is set to zero (smallest).height
- The height, or zero for smallest, negative height is set to zero (smallest).errorCorrectionLevel
- Only applies toQR_CODE
,null
for default L = Low = ~7% error correction level. If the barcode type is anything else but a QR code, this parameter will be set tonull
.- Throws:
BarcodeException
- If there are missing or invalid parameters assigned in this builder encountered during barcode encoding.