public object Evaluate(
            EventBean[] eventsPerStream,
            bool isNewData,
            ExprEvaluatorContext context)
        {
            var pattern = (string) _patternEval.Evaluate(eventsPerStream, isNewData, context);
            if (pattern == null) {
                return null;
            }

            var es = '\\';
            if (_optionalEscapeEval != null) {
                var escapeString = (string) _optionalEscapeEval.Evaluate(eventsPerStream, isNewData, context);
                if (!string.IsNullOrEmpty(escapeString)) {
                    es = escapeString[0];
                }
            }

            var likeUtil = new LikeUtil(pattern, es, false);

            var value = _lhsEval.Evaluate(eventsPerStream, isNewData, context);
            if (value == null) {
                return null;
            }

            if (_form.IsNumericValue) {
                value = value.ToString();
            }

            var result = _form.ForgeRenderable.IsNot ^ likeUtil.CompareTo((string) value);

            return result;
        }
Esempio n. 2
0
 public ExprLikeNodeForgeConst(
     ExprLikeNode parent,
     bool isNumericValue,
     LikeUtil likeUtil,
     CodegenExpression likeUtilInit)
     : base(
         parent,
         isNumericValue)
 {
     LikeUtil = likeUtil;
     LikeUtilInit = likeUtilInit;
 }
Esempio n. 3
0
 /// <summary>Ctor. </summary>
 /// <param name="likeString">pattern to match</param>
 public StringPatternSetLike(String likeString)
 {
     this.likeString = likeString;
     likeUtil        = new LikeUtil(likeString, '\\', false);
 }
Esempio n. 4
0
        public object Evaluate(EvaluateParams evaluateParams)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QExprLike(this);
            }
            if (_likeUtil == null)
            {
                var patternVal = (string)_evaluators[1].Evaluate(evaluateParams);
                if (patternVal == null)
                {
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().AExprLike(null);
                    }
                    return(null);
                }
                string escape          = "\\";
                char?  escapeCharacter = null;
                if (ChildNodes.Length == 3)
                {
                    escape = (String)_evaluators[2].Evaluate(evaluateParams);
                }
                if (escape.Length > 0)
                {
                    escapeCharacter = escape[0];
                }
                _likeUtil = new LikeUtil(patternVal, escapeCharacter, false);
            }
            else
            {
                if (!_isConstantPattern)
                {
                    var patternVal = (string)_evaluators[1].Evaluate(evaluateParams);
                    if (patternVal == null)
                    {
                        if (InstrumentationHelper.ENABLED)
                        {
                            InstrumentationHelper.Get().AExprLike(null);
                        }
                        return(null);
                    }
                    _likeUtil.ResetPattern(patternVal);
                }
            }

            var evalValue = _evaluators[0].Evaluate(evaluateParams);

            if (evalValue == null)
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AExprLike(null);
                }
                return(null);
            }

            if (_isNumericValue)
            {
                evalValue = evalValue.ToString();
            }

            var result = _likeUtil.Compare((String)evalValue);

            if (_isNot)
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AExprLike(!result);
                }
                return(!result);
            }

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AExprLike(result);
            }
            return(result);
        }