Exemple #1
0
        override public String parseInformation()
        {
            if (this.getInformation().Size < HEADER_SIZE + GTIN_SIZE)
            {
                throw NotFoundException.Instance;
            }

            StringBuilder buf = new StringBuilder();

            encodeCompressedGtin(buf, HEADER_SIZE);

            int lastAIdigit =
                this.getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE + GTIN_SIZE, LAST_DIGIT_SIZE);

            buf.Append("(392");
            buf.Append(lastAIdigit);
            buf.Append(')');

            DecodedInformation decodedInformation =
                this.getGeneralDecoder().decodeGeneralPurposeField(HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE, null);

            buf.Append(decodedInformation.getNewString());

            return(buf.ToString());
        }
        override public String parseInformation()
        {
            if (this.getInformation().Size < HEADER_SIZE + GTIN_SIZE)
            {
                return(null);
            }

            StringBuilder buf = new StringBuilder();

            encodeCompressedGtin(buf, HEADER_SIZE);

            int lastAIdigit =
                this.getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE + GTIN_SIZE, LAST_DIGIT_SIZE);

            buf.Append("(393");
            buf.Append(lastAIdigit);
            buf.Append(')');

            int firstThreeDigits =
                this.getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE, FIRST_THREE_DIGITS_SIZE);

            if (firstThreeDigits / 100 == 0)
            {
                buf.Append('0');
            }
            if (firstThreeDigits / 10 == 0)
            {
                buf.Append('0');
            }
            buf.Append(firstThreeDigits);

            DecodedInformation generalInformation =
                this.getGeneralDecoder().decodeGeneralPurposeField(HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE + FIRST_THREE_DIGITS_SIZE, null);

            buf.Append(generalInformation.getNewString());

            return(buf.ToString());
        }
        internal String decodeAllCodes(StringBuilder buff, int initialPosition)
        {
            int    currentPosition = initialPosition;
            String remaining       = null;

            do
            {
                DecodedInformation info         = this.decodeGeneralPurposeField(currentPosition, remaining);
                String             parsedFields = FieldParser.parseFieldsInGeneralPurpose(info.getNewString());
                if (parsedFields != null)
                {
                    buff.Append(parsedFields);
                }
                if (info.isRemaining())
                {
                    remaining = info.getRemainingValue().ToString();
                }
                else
                {
                    remaining = null;
                }

                if (currentPosition == info.NewPosition)
                {// No step forward!
                    break;
                }
                currentPosition = info.NewPosition;
            } while (true);

            return(buff.ToString());
        }