Class BarcodeURN
- All Implemented Interfaces:
Serializable,Cloneable
For better control of the barcode and additional parameters use the BarcodeBuilder from a call to {@link BarcodeType#createBuilder()}.
Barcode URN's are encoded in IIZI as:
urn:iz-barcode:type:text[:width=w][:height:h][:param1=value1:...:paramN=valueN]
where the valid types are (in lower case):
- AZTEC *,
- CODABAR,
- CODE_39,
- CODE_93,
- CODE_128,
- DATA_MATRIX *,
- EAN_8,
- EAN_13,
- ITF,
- PDF_417 *,
- QR_CODE *,
- UPC_A; and
- UPC_E.
The types marked with an asterisk '*' are two dimensional. Generally all barcodes needs a width and height to be displayed properly.
- Author:
- Christopher Mindus
- See Also:
Field Summary
Method Summary
Modifier and TypeMethodDescriptionCreates a barcode builder for this barcode URN.booleanChecks if two instances are equal.static BarcodeURNfrom(BarcodeType format, String text, int width, int height) Creates a BarcodeURN for a barcode format or type.static BarcodeURNfrom(BarcodeType format, String text, int width, int height, ErrorCorrectionLevel errorCorrectionLevel) Creates a BarcodeURN for a barcode format or type, and for the QR code format, an optional error correction level.Gets the image target interface for this URN instance.Gets the parameter string for theURN.toString()method.getSVG()Gets the URL of this as a data URL containing SVG code for the barcode.getURL()Gets the URL of this as a data URL containing SVG code for the barcode.inthashCode()Hashcode of this instance.booleanChecks if this instance supports returning the image target interface{@link IImageTarget}.Methods inherited from class com.iizix.urn.URN
asURNResource, from, getURNString, isURNResource, toString
Method Details
from
public static BarcodeURN from(BarcodeType format, String text, int width, int height) throws BarcodeException Creates a BarcodeURN for a barcode format or 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
BarcodeBuilderfrom a call to{@link BarcodeType#createBuilder()}.- Parameters:
format- The barcode format or type, must benon-null. If the format is a QR code, the error correction level will be set to L = Lowest = ~7%.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.
from
public static BarcodeURN from(BarcodeType format, String text, int width, int height, ErrorCorrectionLevel errorCorrectionLevel) throws BarcodeException Creates a BarcodeURN for a barcode format or type, and for the QR code format, an optional error correction level.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
BarcodeBuilderfrom a call to{@link BarcodeType#createBuilder()}.- Parameters:
format- The barcode format or type, must benon-null. If the format is a QR code, the error correction level will be set to L = Lowest = ~7%.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 toBarcodeType.QR_CODE,nullfor 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.
createBuilder
Creates a barcode builder for this barcode URN. This method is useful if e.g. a barcode has been read from an image (file) and the size is not present.- Returns:
- A new barcode builder for this barcode URN.
getSVG
Gets the URL of this as a data URL containing SVG code for the barcode.- Returns:
- The data URL as
data:image/svg+xml;base64,<i>data</i>.
getURL
Gets the URL of this as a data URL containing SVG code for the barcode.- Specified by:
getURLin classURN- Returns:
- The data URL as
data:image/svg+xml;base64,<i>data</i>. - Throws:
IOException- If there was a problem retrieving the file, an SQL error or other I/O error that caused the URL not to be possible to get (e.g. barcode failure).
isImageTargetSupported
public boolean isImageTargetSupported()Checks if this instance supports returning the image target interface{@link IImageTarget}.- Overrides:
isImageTargetSupportedin classURN- Returns:
trueas Barcode URN's always supports images in SVG.
getImageTarget
Gets the image target interface for this URN instance.- Overrides:
getImageTargetin classURN- Returns:
- The image target interface to an SVG image target.
getParamString
Gets the parameter string for theURN.toString()method.- Specified by:
getParamStringin classURN- Returns:
- The parameter string, always
non-null.
hashCode
public int hashCode()Hashcode of this instance.equals
Checks if two instances are equal.