Class BarcodeTool


  • public class BarcodeTool
    extends java.lang.Object
    Barcodes toolbox
    This class only provides static variables and methods
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DEFAULT_SIZE
      Default size
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String checkEAN13​(java.lang.String code)
      Check an EAN13 code.
      static java.lang.String checkEAN8​(java.lang.String code)
      Check an EAN8 code.
      static int checkSum​(java.lang.String code)
      Calculate checksum for an EAN (EAN13 or EAN8) code
      static byte[] ean13Image​(java.lang.String ean)
      Generate a EAN 13 JPEG image as byte array
      static byte[] ean13Image​(java.lang.String ean, int size)
      Generate a EAN 13 JPEG image as byte array
      static boolean validate​(java.lang.String code)
      Validate an EAN (EAN13 or EAN8) code.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • checkSum

        public static int checkSum​(java.lang.String code)
        Calculate checksum for an EAN (EAN13 or EAN8) code
        Parameters:
        code - EAN code without checksum (e.g. length 12 for an EAN13 or 7 for an EAN 8)
        Returns:
        Checksum digit or -1 in case of error
      • checkEAN8

        public static java.lang.String checkEAN8​(java.lang.String code)
        Check an EAN8 code.
        Parameters:
        code - EAN8 code to check
        Returns:
        Error message if EAN8 is invalid, null otherwise
      • checkEAN13

        public static java.lang.String checkEAN13​(java.lang.String code)
        Check an EAN13 code.
        Parameters:
        code - EAN13 code to check
        Returns:
        Error message if EAN13 is invalid, null otherwise
      • validate

        public static boolean validate​(java.lang.String code)
        Validate an EAN (EAN13 or EAN8) code.
        Parameters:
        code - EAN code
        Returns:
        True if the EAN code is valid
      • ean13Image

        public static byte[] ean13Image​(java.lang.String ean)
        Generate a EAN 13 JPEG image as byte array
        Parameters:
        ean - EAN code
        Returns:
        EAN 13 JPEG image as byte array
      • ean13Image

        public static byte[] ean13Image​(java.lang.String ean,
                                        int size)
        Generate a EAN 13 JPEG image as byte array
        Parameters:
        ean - EAN code
        size - Image size (width) in pixels (no less than 128)
        Returns:
        EAN 13 JPEG image as byte array