public class UPC extends StandardNumber implements java.lang.Cloneable, java.lang.Comparable<UPC>
ISO 15420 Universal Product Code (UPC).
The Universal Product Code (UPC) is a barcode symbology (i.e., a specific type of barcode) that is widely used in the United States, Canada, the United Kingdom, Australia, New Zealand and in other countries for tracking trade items in stores. Its most common form, the UPC-A, consists of 12 numerical digits, which 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 (Global Trade Item Numbers).
All of these data structures follow the global GS1 specification which bases on international standards.
type, value
Constructor and Description |
---|
UPC() |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Returns a clone if the implementation is cloneable.
|
int |
compareTo(UPC upc) |
UPC |
createChecksum(boolean createWithChecksum)
Indicate that a correct check sum should be computed.
|
boolean |
equals(java.lang.Object object) |
java.lang.String |
format()
Return a formatted value of this standard number
This is best for human-readable representation, but is
not necessarily a format for computation.
|
static StandardNumber |
getInstance(java.lang.Package thePackage,
java.lang.ClassLoader classLoader,
java.lang.String type) |
static StandardNumber |
getInstance(java.lang.String type) |
java.util.Collection<java.lang.String> |
getTypedVariants() |
int |
hashCode() |
boolean |
isValid()
Check this number for validity.
|
UPC |
normalize()
Normalize the value by removing all unwanted characters or
replacing characters with the ones required for verification.
|
java.lang.String |
normalizedValue()
Return normalized value of this standard number.
|
UPC |
reset() |
UPC |
verify()
Verify the number.
|
set, type
public int compareTo(UPC upc)
compareTo
in interface java.lang.Comparable<UPC>
public UPC createChecksum(boolean createWithChecksum)
StandardNumber
Indicate that a correct check sum should be computed.
createChecksum
in class StandardNumber
createWithChecksum
- if checksum is includedpublic UPC normalize()
StandardNumber
Normalize the value by removing all unwanted characters or replacing characters with the ones required for verification.
normalize
in class StandardNumber
public boolean isValid()
StandardNumber
Check this number for validity.
isValid
in class StandardNumber
public UPC verify()
StandardNumber
Verify the number.
verify
in class StandardNumber
public java.lang.String normalizedValue()
StandardNumber
Return normalized value of this standard number. In most cases, this is also the canonical form of the standard number. This is a representation without unneccessary characters, useful for computation purposes, like comparing for equivalence.
normalizedValue
in class StandardNumber
public java.lang.String format()
StandardNumber
Return a formatted value of this standard number This is best for human-readable representation, but is not necessarily a format for computation.
format
in class StandardNumber
public UPC reset()
reset
in class StandardNumber
public java.util.Collection<java.lang.String> getTypedVariants()
getTypedVariants
in class StandardNumber
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
java.lang.CloneNotSupportedException
- if this is called on an
implementation that does not support `Cloneable`public static StandardNumber getInstance(java.lang.String type) throws NoSuchStandardNumberException
NoSuchStandardNumberException
public static StandardNumber getInstance(java.lang.Package thePackage, java.lang.ClassLoader classLoader, java.lang.String type) throws NoSuchStandardNumberException
NoSuchStandardNumberException