Example #1
0
        /// <summary> Returns the segment specified in the given segment_path_spec. </summary>
        public virtual ISegment GetSegment(string segSpec)
        {
            ISegment seg = null;

            if (segSpec.Substring(0, 1 - 0).Equals("/"))
            {
                Finder.Reset();
            }

            var tok    = new SupportClass.Tokenizer(segSpec, "/", false);
            var finder = Finder;

            while (tok.HasMoreTokens())
            {
                var pathSpec = tok.NextToken();
                var ps       = ParsePathSpec(pathSpec);
                if (tok.HasMoreTokens())
                {
                    ps.IsGroup = true;
                }
                else
                {
                    ps.IsGroup = false;
                }

                if (ps.IsGroup)
                {
                    IGroup g = null;
                    if (ps.Find)
                    {
                        g = finder.FindGroup(ps.Pattern, ps.Rep);
                    }
                    else
                    {
                        g = finder.GetGroup(ps.Pattern, ps.Rep);
                    }

                    finder = new SegmentFinder(g);
                }
                else
                {
                    if (ps.Find)
                    {
                        seg = finder.FindSegment(ps.Pattern, ps.Rep);
                    }
                    else
                    {
                        seg = finder.GetSegment(ps.Pattern, ps.Rep);
                    }
                }
            }

            return(seg);
        }
Example #2
0
        /// <summary> Returns the segment specified in the given segment_path_spec. </summary>
        public virtual ISegment getSegment(String segSpec)
        {
            ISegment seg = null;

            if (segSpec.Substring(0, (1) - (0)).Equals("/"))
            {
                Finder.reset();
            }

            SupportClass.Tokenizer tok    = new SupportClass.Tokenizer(segSpec, "/", false);
            SegmentFinder          finder = Finder;

            while (tok.HasMoreTokens())
            {
                String   pathSpec = tok.NextToken();
                PathSpec ps       = parsePathSpec(pathSpec);
                if (tok.HasMoreTokens())
                {
                    ps.isGroup = true;
                }
                else
                {
                    ps.isGroup = false;
                }

                if (ps.isGroup)
                {
                    IGroup g = null;
                    if (ps.find)
                    {
                        g = finder.findGroup(ps.pattern, ps.rep);
                    }
                    else
                    {
                        g = finder.getGroup(ps.pattern, ps.rep);
                    }
                    finder = new SegmentFinder(g);
                }
                else
                {
                    if (ps.find)
                    {
                        seg = finder.findSegment(ps.pattern, ps.rep);
                    }
                    else
                    {
                        seg = finder.getSegment(ps.pattern, ps.rep);
                    }
                }
            }

            return(seg);
        }
Example #3
0
 /// <summary>Creates a new instance of Terser </summary>
 public Terser(IMessage message)
 {
     finder = new SegmentFinder(message);
 }
Example #4
0
 /// <summary>Creates a new instance of Terser </summary>
 public Terser(IMessage message)
 {
     finder = new SegmentFinder(message);
 }
Example #5
0
        /// <summary> Returns the segment specified in the given segment_path_spec. </summary>
        public virtual ISegment getSegment(System.String segSpec)
        {
            ISegment seg = null;

            if (segSpec.Substring(0, (1) - (0)).Equals("/"))
            {
                Finder.reset();
            }

            SupportClass.Tokenizer tok = new SupportClass.Tokenizer(segSpec, "/", false);
            SegmentFinder finder = Finder;
            while (tok.HasMoreTokens())
            {
                System.String pathSpec = tok.NextToken();
                Terser.PathSpec ps = parsePathSpec(pathSpec);
                if (tok.HasMoreTokens())
                {
                    ps.isGroup = true;
                }
                else
                {
                    ps.isGroup = false;
                }

                if (ps.isGroup)
                {
                    IGroup g = null;
                    if (ps.find)
                    {
                        g = finder.findGroup(ps.pattern, ps.rep);
                    }
                    else
                    {
                        g = finder.getGroup(ps.pattern, ps.rep);
                    }
                    finder = new SegmentFinder(g);
                }
                else
                {
                    if (ps.find)
                    {
                        seg = finder.findSegment(ps.pattern, ps.rep);
                    }
                    else
                    {
                        seg = finder.getSegment(ps.pattern, ps.rep);
                    }
                }
            }

            return seg;
        }