コード例 #1
0
        public PrefixPhrase <O> Add(ParsedUri purl)
        {
            String host = purl.Host;        //edit
            // domainPrefix is a child of this, the root (with no parent)
            PrefixPhrase <O> hostPrefix = GetPrefix(null, host);

            // children of hostPrefix
            String pathStringToParse = usePathFile ? purl.ToString() : purl.LocalPath;        //.pathDirectoryString;

            return((hostPrefix != null) ? hostPrefix.Add(pathStringToParse, separator) : LookupChild(host));
        }
コード例 #2
0
        protected PrefixPhrase <O> Add(String str, int start, char separator)
        {
            int  end       = str.Length;
            bool terminate = false;

            if (start == end)
            {
                terminate = true;
            }
            else
            {
                if (str[start] == separator)
                {
                    start++;
                }
                if (start == end)
                {
                    terminate = true;
                }
            }
            if (terminate)
            {
                Clear();
                return(this);
            }
            int nextSeparator = str.IndexOf(separator, start);

            if (nextSeparator == -1)
            {
                nextSeparator = end;
            }

            if (nextSeparator > -1)
            {
                String phraseString = str.Substring(start, nextSeparator - start);
                // extra round of messing with synch, because we need to know if we
                // are creating a new Phrase
                PrefixPhrase <O> nextPrefixPhrase = GetPrefix(this, phraseString);
                if (nextPrefixPhrase != null)
                {
                    return(nextPrefixPhrase.Add(str, nextSeparator, separator));
                }
                else
                {
                    // done!
                    PrefixPhrase <O> newTerminal = LookupChild(phraseString);
                    //newTerminal.clear();
                    return(newTerminal);
                    //				synchronized (this)
                    //				{
                    //					nextPrefixPhrase	= getPrefix(this, phraseString);
                    //					if (nextPrefixPhrase == null)
                    //					{
                    //						nextPrefixPhrase	= childPhraseMap.getOrCreateAndPutIfNew(phraseString, this);
                    //						result				= nextPrefixPhrase;
                    //					}
                    //				}
                }
            }
            else
            {
                Debug.WriteLine("help! wrong block!!!");
                // last segment
                return(null);
            }
        }