Beispiel #1
0
        /** ********************************************************************************************
         * Searches a domain. If not found, the domain is (or path of domains are) created in
         * the domain tree.
         * If the path string starts with the character defined in #PathSeparator, then
         * the search (and creation) is done starting from the root domain of this domain and not
         * from this domain.
         *
         * @param       domainPathAS  Path and domain to search.
         * @param       sensitivity   Denotes if domain name search is treated case sensitive or not.
         * @param       maxCreate     The maximum number of sub domains that are created if not
         *                            found at the end of the path.
         * @param[out]  wasCreated    Output parameter that is set \c true if domain was not found
         *                            and hence created.
         * @return The domain found or created.
         **********************************************************************************************/
        public Domain Find(AString domainPathAS, Case sensitivity, int maxCreate, ref bool wasCreated)
        {
            Substring domainPath = tSubstring;

            domainPath.Set(domainPathAS);

            // set optional output parameter as default to false
            wasCreated = false;

            int lenBeforeTrim = domainPath.Length();

            // if string is empty (resp. contains only separator characters), return ourselves
            while (domainPath.Consume(PathSeparator))
            {
                ;
            }
            if (domainPath.IsEmpty())
            {
                return(this);
            }

            // Trailing domain separator found: call find on root domain
            Domain startDomain = this;

            if (lenBeforeTrim > domainPath.Length())
            {
                while (startDomain.Parent != null)
                {
                    startDomain = startDomain.Parent;
                }
            }

            // call find
            return(startDomain.findRecursive(domainPath, sensitivity, maxCreate, ref wasCreated));
        }