Label Definition
Defined in package com.scandit.datacapture.label
- LabelDefinition
class LabelDefinitionAdded in version 6.21.0
A configuration that defines labels and their relevant fields for Smart Label Capture to recognize and extract during scans. Label definitions provide flexible data extraction from specific label layouts without custom coding, enabling structured data extraction from diverse label types.
Label definitions support two primary approaches:
Pre-built Labels - Includes predefined configurations for common label types (price labels, VIN labels, 7-segment displays)
Custom Labels - Allows creating unique label definitions using custom barcode and text fields
Key configuration options for custom fields:
patterns - Regular expressions to identify target strings
dataTypePatterns - Context-identifying keywords for field recognition
symbologies - Specific barcode types to match
isOptional - Determines field requirement status
Pre-built field categories include:
Barcode Fields - Serial number, part number, IMEI
Price/Weight Fields - Unit price, total price, weight
Date/Text Fields - Packing date, expiry date
You can create label definitions in three ways:
Builder Pattern - Use LabelDefinitionBuilder for fluent configuration
Factory Methods - Use predefined definitions like createPriceCaptureDefinition() for common use cases
Manual Construction - Create with explicit field lists using create()
- create(name, fields)
static @NonNull LabelDefinition create(@NonNull String name, @NonNull List<@NonNull LabelFieldDefinition> fields)
Added in version 6.21.0
Create a new label definition with the given name and fields.
- fields
@NonNull List<@NonNull LabelFieldDefinition> getFields()
Added in version 6.21.0
The fields of the label definition.
- hiddenProperties
@NonNull Map<@NonNull String, @NonNull Object> getHiddenProperties()
voidsetHiddenProperties(@NonNull Map<@NonNull String, @NonNull Object> value)Added in version 7.6.0
Set properties to the label definition.
- createVinLabelDefinition(name)
static @NonNull LabelDefinition createVinLabelDefinition(@NonNull String name)
Added in version 7.4.0
Creates a predefined label definition for scanning Vehicle Identification Numbers (VIN). VIN codes are 17-character alphanumeric serial numbers that can appear as either text or barcodes on vehicles.
LabelDefinition vinLabel = LabelDefinition.createVinLabelDefinition("vehicle_vin");
This factory method returns a label definition with two optional fields:
text - An optional text field for scanning VIN codes in text format with pattern
[A-Z0-9]{17}barcode - An optional barcode field for scanning VIN codes in barcode format (QR, Code 39, or Data Matrix symbologies) with pattern
[A-Z0-9]{17}
- createPriceCaptureDefinition(name)
static @NonNull LabelDefinition createPriceCaptureDefinition(@NonNull String name)
Added in version 7.4.0
Creates a predefined label definition for scanning price labels on retail products. This factory method is designed for price checking scenarios where both barcode and price text need to be captured from product labels.
This factory method returns a label definition with two fields:
SKU - A mandatory barcode field for scanning Symbology.EAN13_UPCA and Symbology.CODE128.
priceText - An optional text field for scanning price text using specialized price label recognition with pattern
\\d+.
You can easily disable one of the symbologies of the barcode field by changing global mode settings. For example, to disable Symbology.CODE128 one can do this:
SymbologySettings symbologySettings = labelCaptureSettings.getSymbologySettings(Symbology.CODE128); symbologySettings.setEnabled(false);
Note
To use this label definition, make sure to import the PriceCapture library.
- createSevenSegmentDisplayLabelDefinition(name)
static @NonNull LabelDefinition createSevenSegmentDisplayLabelDefinition(@NonNull String name)
Added in version 7.5.0
Creates a predefined label definition for reading numeric values from 7-segment displays, such as digital scales, meters, or other electronic displays.
This factory method returns a label definition with one field:
weight - A text field for 7-segment displays with pattern
[0-9OQB]{1,4}[\.\,\s]?[0-9OQB]{1,4}
The pattern accounts for common variations in 7-segment displays where certain characters may appear similar (e.g., ‘O’ for ‘0’, ‘Q’ for ‘0’, ‘B’ for ‘8’).
- builder()
static @NonNull LabelDefinitionBuilder builder()
Added in version 6.21.0
Create a new label definition builder.