Class BarcodeFormat

java.lang.Object
com.codename1.ai.vision.BarcodeFormat

public final class BarcodeFormat extends Object

The normalized symbology names Barcode.getFormat() reports, as constants instead of literals. Every backend maps its own vendor identifier onto one of these before the result reaches application code, and reports UNKNOWN for a symbology outside this set.

scanner.process(VisionImage.encoded(jpeg)).ready(codes -> {
    for (Barcode code : codes) {
        if (BarcodeFormat.matches(code, BarcodeFormat.QR_CODE)) {
            Log.p("QR: " + code.getValue());
        } else if (BarcodeFormat.matches(code, BarcodeFormat.EAN_13,
                BarcodeFormat.UPC_A)) {
            lookUpProduct(code.getValue());
        }
    }
});
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Aztec two-dimensional code, common on transit tickets.
    static final String
    Codabar linear code, used by libraries and blood banks.
    static final String
    Code 128 linear code, the usual choice for shipping labels.
    static final String
    Code 39 linear code.
    static final String
    Code 93 linear code.
    static final String
    Data Matrix two-dimensional code, common on small parts.
    static final String
    EAN-13 retail product code.
    static final String
    EAN-8 retail product code.
    static final String
    Interleaved 2 of 5 linear code.
    static final String
    PDF417 stacked code, used by driving licences and boarding passes.
    static final String
    QR code.
    static final String
    Reported when the backend decoded a code whose symbology has no portable name here.
    static final String
    UPC-A retail product code.
    static final String
    UPC-E retail product code.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    matches(Barcode barcode, String... formats)
    Tests a decoded barcode against a set of accepted formats.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • matches

      public static boolean matches(Barcode barcode, String... formats)
      Tests a decoded barcode against a set of accepted formats. An empty or null format list accepts every symbology, which is what a general-purpose scanner wants.
      Parameters:
      barcode - observation to test, or null
      formats - accepted format constants
      Returns:
      true when the barcode's format is one of formats