Exemplo n.º 1
0
        public PersonName(String s)
        {
            if (s == null) {
                s = string.Empty;
            }

            int grLen = s.IndexOf('=');
            if ((grLen == - 1 ? s.Length : grLen) > 64) {
                throw new ArgumentException(s);
            }

            var stk = new Tokenizer(s, "=^");
            int field = FAMILY;
            String tk;
            while (stk.HasMoreTokens()) {
                tk = stk.NextToken();
                switch (tk[0]) {
                    case '^':
                        if (++field > SUFFIX) {
                            throw new ArgumentException(s);
                        }
                        break;

                    case '=':
                        goto WHILE_brk;

                    default:
                        components[field] = tk;
                        break;
                }
            }
            WHILE_brk:
            ;

            if (!stk.HasMoreTokens()) {
                return;
            }

            tk = stk.NextToken("=");
            if (tk[0] != '=') {
                ideographic = new PersonName(tk);
                if (stk.HasMoreTokens()) {
                    tk = stk.NextToken("=");
                }
            }
            if (!stk.HasMoreTokens()) {
                return;
            }

            tk = stk.NextToken();
            if (tk[0] == '=' || stk.HasMoreTokens()) {
                throw new ArgumentException(s);
            }

            phonetic = new PersonName(tk);
        }
 private String[] ToStringArray(String s)
 {
     var stk = new Tokenizer(s, " ,;[]\t\r\n");
     if (!stk.HasMoreTokens()) {
         return null;
     }
     var array = new String[stk.Count];
     for (int i = 0; i < array.Length; ++i) {
         array[i] = stk.NextToken();
     }
     return array;
 }