Class BarcodeURN
- java.lang.Object
- com.iizix.urn.URN
- com.iizix.barcode.BarcodeURN
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
public class BarcodeURN extends URN implements java.lang.Cloneable, java.io.Serializable
Barcode Uniform Resource Naming (URN) instance class, holding the barcode type and data string.For better control of the barcode and additional parameters use the
BarcodeBuilderfrom 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:
- Serialized Form
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BarcodeBuildercreateBuilder()Creates a barcode builder for this barcode URN.booleanequals(java.lang.Object obj)Checks if two instances are equal.static BarcodeURNfrom(BarcodeType format, java.lang.String text, int width, int height)Creates a BarcodeURN for a barcode format or type.static BarcodeURNfrom(BarcodeType format, java.lang.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.IImageTargetgetImageTarget()Gets the image target interface for this URN instance.java.lang.StringgetParamString()Gets the parameter string for theURN.toString()method.java.lang.StringgetSVG()Gets the URL of this as a data URL containing SVG code for the barcode.java.lang.StringgetURL()Gets the URL of this as a data URL containing SVG code for the barcode.inthashCode()Hashcode of this instance.booleanisImageTargetSupported()Checks 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 Detail
from
public static BarcodeURN from(BarcodeType format, java.lang.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, java.lang.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
public BarcodeBuilder 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
public java.lang.String 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
public java.lang.String getURL() throws java.io.IOExceptionGets the URL of this as a data URL containing SVG code for the barcode.
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
public IImageTarget getImageTarget()
Gets the image target interface for this URN instance.- Overrides:
getImageTargetin classURN- Returns:
- The image target interface to an SVG image target.
getParamString
public java.lang.String 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.