CodeTemplate

open class CodeTemplate

Class for parsing of code templates.

Example: "2{code:5}{i}{code:5}{ec}", resembling a standard EAN13 containing embedded weight or prices

Valid groups

code | either a known format (ean8, ean13 or ean14), or a length

embed | embedded data in the code. This may be a weight, amount or price, depending on the encodingUnit of the scanned code

Supports decimal lengths such as "4.3", which tells the parser that there are 4 decimal and 3 fractional digits encoded.

embed100 | embedded data in the code that must be multiplied by 100 (e.g. for an embedded price in Euros)

price | price of one referenceUnit of the product

_ | ignore length character(s)

i | length is always 1, other values will be ignored. Represents the internal 5-digit checksum of an EAN-13. Presence of this property requires that the embed property is also present and has a length of 5.

ec | length is always 1, other values will be ignored, and must be the last component of a template. Represents the check digit of an EAN-8, EAN-13 or EAN-14 code.

Constructors

Link copied to clipboard
constructor(name: String, pattern: String)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
Generates a parsed ScannedCode containing code and embedded data.
Link copied to clipboard
open fun code(code: String): CodeTemplate
Sets the code of the code group
Link copied to clipboard
open fun embed(embeddedData: Int): CodeTemplate
The embedded data that will be embedded in the code, if the code has a embed group
Link copied to clipboard
open fun <T : Group?> getGroup(clazz: Class<out Group>): T
Link copied to clipboard
open fun length(): Int
Link copied to clipboard
open fun match(match: String): CodeTemplate
Matches a code to the template, extracting information that resides in the code.
Link copied to clipboard
open fun reset()
Link copied to clipboard
open fun string(): String