コード例 #1
0
        private static String MakeProperty(EsperEPL2GrammarParser.EventPropertyAtomicContext ctx, String defaultNamespacePrefix)
        {
            String prefix = "";

            if (defaultNamespacePrefix != null)
            {
                prefix = defaultNamespacePrefix + ":";
            }

            String unescapedIdent = ASTUtil.UnescapeDot(ctx.eventPropertyIdent().GetText());

            if (ctx.lb != null)
            {
                int index         = IntValue.ParseString(ctx.number().GetText());
                int xPathPosition = index + 1;
                return('/' + prefix + unescapedIdent + "[position() = " + xPathPosition + ']');
            }

            if (ctx.lp != null)
            {
                String key = StringValue.ParseString(ctx.s.Text);
                return('/' + prefix + unescapedIdent + "[@id='" + key + "']");
            }

            return('/' + prefix + unescapedIdent);
        }
コード例 #2
0
ファイル: PropertyParser.cs プロジェクト: valmac/nesper
        private static Property MakeProperty(EsperEPL2GrammarParser.EventPropertyAtomicContext atomic, bool isRootedInDynamic)
        {
            var prop = ASTUtil.UnescapeDot(atomic.eventPropertyIdent().GetText());

            if (prop.Length == 0)
            {
                throw new PropertyAccessException("Invalid zero-length string provided as an event property name");
            }
            if (atomic.lb != null)
            {
                var index = IntValue.ParseString(atomic.ni.GetText());
                if (!isRootedInDynamic && atomic.q == null)
                {
                    return(new IndexedProperty(prop, index));
                }
                else
                {
                    return(new DynamicIndexedProperty(prop, index));
                }
            }
            else if (atomic.lp != null)
            {
                var key = StringValue.ParseString(atomic.s.Text);
                if (!isRootedInDynamic && atomic.q == null)
                {
                    return(new MappedProperty(prop, key));
                }
                else
                {
                    return(new DynamicMappedProperty(prop, key));
                }
            }
            else
            {
                if (!isRootedInDynamic && atomic.q1 == null)
                {
                    return(new SimpleProperty(prop));
                }
                else
                {
                    return(new DynamicSimpleProperty(prop));
                }
            }
        }