Beispiel #1
0
 protected override Type DoResolvePropertyType(String propertyExpression)
 {
     EsperEPL2GrammarParser.StartEventPropertyRuleContext ast = PropertyParser.Parse(propertyExpression);
     return(PropertyParser.IsPropertyDynamic(ast)
         ? typeof(XmlNode)
         : typeof(string));
 }
Beispiel #2
0
        /// <summary>
        /// Return the xPath corresponding to the given property. The PropertyName String
        /// may be simple, nested, indexed or mapped.
        /// </summary>
        /// <param name="ast">is the property tree AST</param>
        /// <param name="propertyName">is the property name to parse</param>
        /// <param name="rootElementName">is the name of the root element for generating the XPath expression</param>
        /// <param name="defaultNamespacePrefix">is the prefix of the default namespace</param>
        /// <param name="isResolvePropertiesAbsolute">is true to indicate to resolve XPath properties as absolute propsor relative props </param>
        /// <returns>
        /// xpath expression
        /// </returns>
        public static String Walk(EsperEPL2GrammarParser.StartEventPropertyRuleContext ast, String propertyName, String rootElementName, String defaultNamespacePrefix, bool isResolvePropertiesAbsolute)
        {
            var xPathBuf = new StringBuilder();

            xPathBuf.Append('/');
            if (isResolvePropertiesAbsolute)
            {
                if (defaultNamespacePrefix != null)
                {
                    xPathBuf.Append(defaultNamespacePrefix);
                    xPathBuf.Append(':');
                }
                xPathBuf.Append(rootElementName);
            }

            IList <EsperEPL2GrammarParser.EventPropertyAtomicContext> ctxs = ast.eventProperty().eventPropertyAtomic();

            if (ctxs.Count == 1)
            {
                xPathBuf.Append(MakeProperty(ctxs[0], defaultNamespacePrefix));
            }
            else
            {
                foreach (EsperEPL2GrammarParser.EventPropertyAtomicContext ctx in ctxs)
                {
                    xPathBuf.Append(MakeProperty(ctx, defaultNamespacePrefix));
                }
            }

            String xPath = xPathBuf.ToString();

            if ((ExecutionPathDebugLog.IsEnabled) && (Log.IsDebugEnabled))
            {
                Log.Debug(".parse For property '" + propertyName + "' the xpath is '" + xPath + "'");
            }

            return(xPath);
            //return XPathExpression.Compile( xPath );
        }
Beispiel #3
0
        /// <summary>
        /// Parse the given property name returning a Property instance for the property.
        /// </summary>
        /// <param name="tree">The tree.</param>
        /// <param name="isRootedDynamic">is true to indicate that the property is already rooted in a dynamicproperty and therefore all child properties should be dynamic properties as well</param>
        /// <returns>
        /// Property instance for property
        /// </returns>
        public static Property Walk(EsperEPL2GrammarParser.StartEventPropertyRuleContext tree, bool isRootedDynamic)
        {
            if (tree.eventProperty().eventPropertyAtomic().Length == 1)
            {
                return(MakeProperty(tree.eventProperty().eventPropertyAtomic(0), isRootedDynamic));
            }

            var propertyRoot = tree.eventProperty();

            IList <Property> properties = new List <Property>();
            var isRootedInDynamic       = isRootedDynamic;

            foreach (var atomic in propertyRoot.eventPropertyAtomic())
            {
                var property = MakeProperty(atomic, isRootedInDynamic);
                if (property is DynamicSimpleProperty)
                {
                    isRootedInDynamic = true;
                }
                properties.Add(property);
            }
            return(new NestedProperty(properties));
        }
Beispiel #4
0
        /// <summary>
        /// Returns true if the property is a dynamic property.
        /// </summary>
        /// <param name="ast">property ast</param>
        /// <returns>dynamic or not</returns>
        public static bool IsPropertyDynamic(EsperEPL2GrammarParser.StartEventPropertyRuleContext ast)
        {
            IList <EsperEPL2GrammarParser.EventPropertyAtomicContext> ctxs = ast.eventProperty().eventPropertyAtomic();

            return(ctxs.Any(ctx => ctx.q != null || ctx.q1 != null));
        }