Label Definition Builder

Defined in package com.scandit.datacapture.label

LabelDefinitionBuilder
class LabelDefinitionBuilder

Added in version 8.6.0

A fluent builder class for creating LabelDefinition objects with a convenient, chainable interface. This builder provides methods to add various field types (barcodes, text fields, dates) and configure their properties in a structured manner.

The LabelDefinitionBuilder enables you to construct complex label definitions by adding multiple field types:

  • Barcode Fields - Serial numbers, part numbers, IMEI codes, custom barcodes

  • Text Fields - Unit prices, total prices, weight information, custom text, date fields (for example, packing dates, expiry dates with configurable formats)

Each field can be configured with validation regexes, optional status, and symbology settings where applicable. The builder pattern ensures type safety and provides a clear, readable way to define label structures.

Note

This builder is the recommended approach for creating label definitions as it provides better type safety and readability compared to manual construction.

LabelDefinitionBuilder()
LabelDefinitionBuilder()

Added in version 8.6.0

Constructs a builder with the label definition name pre-set. When provided, build can be called without arguments.

addSerialNumberBarcode()
fun addSerialNumberBarcode(): SerialNumberBarcodeBuilder

Added in version 8.6.0

Adds a serial number barcode field to the label definition. Returns a builder for configuring the serial number field properties.

serialNumberBarcode(name, func)
fun serialNumberBarcode(name: String,
        func: SerialNumberBarcodeBuilder.() -> Unit)

Added in version 8.6.0

Adds a serial number barcode field with a configuration function. This method allows for inline configuration of the serial number field properties.

addPartNumberBarcode()
fun addPartNumberBarcode(): PartNumberBarcodeBuilder

Added in version 8.6.0

Adds a part number barcode field to the label definition. Returns a builder for configuring the part number field properties.

partNumberBarcode(name, func)
fun partNumberBarcode(name: String,
        func: PartNumberBarcodeBuilder.() -> Unit)

Added in version 8.6.0

Adds a part number barcode field with a configuration function. This method allows for inline configuration of the part number field properties.

addImeiOneBarcode()
fun addImeiOneBarcode(): ImeiOneBarcodeBuilder

Added in version 8.6.0

Adds an IMEI-1 barcode field to the label definition. Returns a builder for configuring the IMEI-1 field properties.

IMEI-1 barcodes are used for mobile device identification. This field type is specifically optimized for recognizing the first IMEI code format commonly found on device labels.

imeiOneBarcode(name, func)
fun imeiOneBarcode(name: String,
        func: ImeiOneBarcodeBuilder.() -> Unit)

Added in version 8.6.0

Adds an IMEI-1 barcode field with a configuration function. This method allows for inline configuration of the IMEI-1 field properties.

addImeiTwoBarcode()
fun addImeiTwoBarcode(): ImeiTwoBarcodeBuilder

Added in version 8.6.0

Adds an IMEI-2 barcode field to the label definition. Returns a builder for configuring the IMEI-2 field properties.

IMEI-2 barcodes are used for mobile device identification, specifically for the second IMEI code format. This field type is optimized for recognizing the alternative IMEI code format.

imeiTwoBarcode(name, func)
fun imeiTwoBarcode(name: String,
        func: ImeiTwoBarcodeBuilder.() -> Unit)

Added in version 8.6.0

Adds an IMEI-2 barcode field with a configuration function. This method allows for inline configuration of the IMEI-2 field properties.

addCustomBarcode()
fun addCustomBarcode(): CustomBarcodeBuilder

Added in version 8.6.0

Adds a custom barcode field to the label definition. Returns a builder for configuring the custom barcode field properties.

customBarcode(name, func)
fun customBarcode(name: String,
        func: CustomBarcodeBuilder.() -> Unit)

Added in version 8.6.0

Adds a custom barcode field with a configuration function. This method allows for inline configuration of the custom barcode field properties.

addUnitPriceText()
fun addUnitPriceText(): UnitPriceTextBuilder

Added in version 8.6.0

Adds a unit price text field to the label definition. Returns a builder for configuring the unit price field properties.

unitPriceText(name, func)
fun unitPriceText(name: String,
        func: UnitPriceTextBuilder.() -> Unit)

Added in version 8.6.0

Adds a unit price text field with a configuration function. This method allows for inline configuration of the unit price field properties.

addTotalPriceText()
fun addTotalPriceText(): TotalPriceTextBuilder

Added in version 8.6.0

Adds a total price text field to the label definition. Returns a builder for configuring the total price field properties.

totalPriceText(name, func)
fun totalPriceText(name: String,
        func: TotalPriceTextBuilder.() -> Unit)

Added in version 8.6.0

Adds a total price text field with a configuration function. This method allows for inline configuration of the total price field properties.

addWeightText()
fun addWeightText(): WeightTextBuilder

Added in version 8.6.0

Adds a weight text field to the label definition. Returns a builder for configuring the weight field properties.

weightText(name, func)
fun weightText(name: String,
        func: WeightTextBuilder.() -> Unit)

Added in version 8.6.0

Adds a weight text field with a configuration function. This method allows for inline configuration of the weight field properties.

addPackingDateText()
fun addPackingDateText(): PackingDateTextBuilder

Added in version 8.6.0

Adds a packing date text field to the label definition. Returns a builder for configuring the packing date field properties.

packingDateText(name, func)
fun packingDateText(name: String,
        func: PackingDateTextBuilder.() -> Unit)

Added in version 8.6.0

Adds a packing date text field with a configuration function. This method allows for inline configuration of the packing date field properties.

addExpiryDateText()
fun addExpiryDateText(): ExpiryDateTextBuilder

Added in version 8.6.0

Adds an expiry date text field to the label definition. Returns a builder for configuring the expiry date field properties.

expiryDateText(name, func)
fun expiryDateText(name: String,
        func: ExpiryDateTextBuilder.() -> Unit)

Added in version 8.6.0

Adds an expiry date text field with a configuration function. This method allows for inline configuration of the expiry date field properties.

addDateText()
fun addDateText(): DateTextBuilder

Added in version 8.6.0

Adds a date text field to the label definition. Returns a builder for configuring the date field properties.

dateText(name, func)
fun dateText(name: String,
        func: DateTextBuilder.() -> Unit)

Added in version 8.6.0

Adds a date text field with a configuration function. This method allows for inline configuration of the date field properties.

addCustomText()
fun addCustomText(): CustomTextBuilder

Added in version 8.6.0

Adds a custom text field to the label definition. Returns a builder for configuring the custom text field properties.

customText(name, func)
fun customText(name: String,
        func: CustomTextBuilder.() -> Unit)

Added in version 8.6.0

Adds a custom text field with a configuration function. This method allows for inline configuration of the custom text field properties.

setHiddenProperty(key, value)
fun setHiddenProperty(key: String,
        value: Any): LabelDefinitionBuilder

Added in version 8.6.0

Sets a hidden property to be used when creating the LabelDefinition object.

setHiddenProperties(hiddenProperties)
fun setHiddenProperties(hiddenProperties: Map<String, Any>): LabelDefinitionBuilder

Added in version 8.6.0

Sets hidden properties to be used when creating the LabelDefinition object.

adaptiveRecognition(adaptiveRecognitionMode)
fun adaptiveRecognition(adaptiveRecognitionMode: AdaptiveRecognitionMode): LabelDefinitionBuilder

Added in version 8.6.0

Sets the adaptive recognition mode for the label definition being built. Controls whether cloud-based processing is used as a backup for on-device processing. See AdaptiveRecognitionMode for available options.

build(name)
fun build(name: String): LabelDefinition

Added in version 8.6.0

Builds the LabelDefinition object with the given name. On web the name argument is optional when it was supplied to the constructor.