parseInformation method

  1. @override
String parseInformation()
override

Implementation

@override
String parseInformation() {
  if (information.size < _HEADER_SIZE + AI01decoder.GTIN_SIZE) {
    throw NotFoundException.instance;
  }

  final buf = StringBuilder();

  encodeCompressedGtin(buf, _HEADER_SIZE);

  final lastAIdigit = generalDecoder.extractNumericValueFromBitArray(
    _HEADER_SIZE + AI01decoder.GTIN_SIZE,
    _LAST_DIGIT_SIZE,
  );

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

  final firstThreeDigits = generalDecoder.extractNumericValueFromBitArray(
    _HEADER_SIZE + AI01decoder.GTIN_SIZE + _LAST_DIGIT_SIZE,
    _FIRST_THREE_DIGITS_SIZE,
  );
  if (firstThreeDigits ~/ 100 == 0) {
    buf.write('0');
  }
  if (firstThreeDigits ~/ 10 == 0) {
    buf.write('0');
  }
  buf.write(firstThreeDigits);

  final generalInformation = generalDecoder.decodeGeneralPurposeField(
    _HEADER_SIZE +
        AI01decoder.GTIN_SIZE +
        _LAST_DIGIT_SIZE +
        _FIRST_THREE_DIGITS_SIZE,
    null,
  );
  buf.write(generalInformation.newString);

  return buf.toString();
}