Esempio n. 1
0
        internal static void ParseHeaderInformation(CharSequence text, string type, CSVHeaderInformation info)
        {
            Matcher mapMatcher   = MapPattern.matcher(text);
            string  errorMessage = format("Failed to parse %s value: '%s'", type, text);

            if (!(mapMatcher.find() && mapMatcher.groupCount() == 1))
            {
                throw new InvalidValuesArgumentException(errorMessage);
            }

            string mapContents = mapMatcher.group(1);

            if (mapContents.Length == 0)
            {
                throw new InvalidValuesArgumentException(errorMessage);
            }

            Matcher matcher = KeyValuePattern.matcher(mapContents);

            if (!(matcher.find()))
            {
                throw new InvalidValuesArgumentException(errorMessage);
            }

            do
            {
                string key = matcher.group("k");
                if (!string.ReferenceEquals(key, null))
                {
                    string value = matcher.group("v");
                    if (!string.ReferenceEquals(value, null))
                    {
                        info.Assign(key, value);
                    }
                }
            } while (matcher.find());
        }