Example #1
0
        /// <summary>Adds a SOM name to the search node chain.</summary>
        /// <param name="inverseSearch">the start point</param>
        /// <param name="stack">the stack with the separated SOM parts</param>
        /// <param name="unstack">the full name</param>
        public static void InverseSearchAdd(IDictionary <String, InverseStore> inverseSearch
                                            , Stack <String> stack, String unstack)
        {
            String       last  = stack.Peek();
            InverseStore store = inverseSearch.Get(last);

            if (store == null)
            {
                store = new InverseStore();
                inverseSearch[last] = store;
            }
            for (int k = stack.Count - 2; k >= 0; --k)
            {
                last = stack.ElementAt(k);
                InverseStore store2;
                int          idx = store.part.IndexOf(last);
                if (idx < 0)
                {
                    store.part.Add(last);
                    store2 = new InverseStore();
                    store.follow.Add(store2);
                }
                else
                {
                    store2 = (InverseStore)store.follow[idx];
                }
                store = store2;
            }
            store.part.Add("");
            store.follow.Add(unstack);
        }
Example #2
0
        /// <summary>Searches the SOM hierarchy from the bottom.</summary>
        /// <param name="parts">the SOM parts</param>
        /// <returns>the full name or <CODE>null</CODE> if not found</returns>
        public virtual String InverseSearchGlobal(IList <String> parts)
        {
            if (parts.Count == 0)
            {
                return(null);
            }
            InverseStore store = inverseSearch.Get(parts[parts.Count - 1]);

            if (store == null)
            {
                return(null);
            }
            for (int k = parts.Count - 2; k >= 0; --k)
            {
                String part = parts[k];
                int    idx  = store.part.IndexOf(part);
                if (idx < 0)
                {
                    if (store.IsSimilar(part))
                    {
                        return(null);
                    }
                    return(store.GetDefaultName());
                }
                store = (InverseStore)store.follow[idx];
            }
            return(store.GetDefaultName());
        }
Example #3
0
        /// <summary>
        /// Gets the full name by traversing the hierarchy using only the
        /// index 0.
        /// </summary>
        /// <returns>the full name</returns>
        public virtual String GetDefaultName()
        {
            InverseStore store = this;

            while (true)
            {
                Object obj = store.follow[0];
                if (obj is String)
                {
                    return((String)obj);
                }
                store = (InverseStore)obj;
            }
        }