Пример #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
        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));
                }
            }
        }
Пример #3
0
        private static Object ParseIntLongByte(String arg, int factor)
        {
            // try to parse as an int first, else try to parse as a long
            try
            {
                return IntValue.ParseString(arg)*factor;
            }
            catch (OverflowException e1)
            {
                try
                {
                    return (Int64) (LongValue.ParseString(arg)*factor);
                }
                catch
                {
                }

                throw;
            }
            catch (FormatException e1)
            {
                try
                {
                    return (Int64) (LongValue.ParseString(arg)*factor);
                }
                catch (Exception)
                {
                    try
                    {
                        return (Byte) (ByteValue.ParseString(arg)*factor);
                    }
                    catch (Exception)
                    {
                        throw e1;
                    }
                }
            }
        }