parseInformation method

  1. @override
String parseInformation()
override

Implementation

@override
String parseInformation() {
  if (information.size < _headerSize + AI01Decoder.gtinSize) {
    throw NotFoundException.instance;
  }

  final buf = StringBuilder();

  encodeCompressedGtin(buf, _headerSize);

  final lastAIdigit = generalDecoder.extractNumericValueFromBitArray(
    _headerSize + AI01Decoder.gtinSize,
    _lastDigitSize,
  );

  buf.write('(393');
  buf.write(lastAIdigit);
  buf.write(')');

  final firstThreeDigits = generalDecoder.extractNumericValueFromBitArray(
    _headerSize + AI01Decoder.gtinSize + _lastDigitSize,
    _firstThreeDigitsSize,
  );
  if (firstThreeDigits ~/ 100 == 0) {
    buf.write('0');
  }
  if (firstThreeDigits ~/ 10 == 0) {
    buf.write('0');
  }
  buf.write(firstThreeDigits);

  final generalInformation = generalDecoder.decodeGeneralPurposeField(
    _headerSize +
        AI01Decoder.gtinSize +
        _lastDigitSize +
        _firstThreeDigitsSize,
    null,
  );
  buf.write(generalInformation.newString);

  return buf.toString();
}