public SparqlSameTerm(SparqlExpression str, SparqlExpression pattern)
        {
            switch (NullablePairExt.Get(str.Const, pattern.Const))
            {
            case NP.bothNull:
                this.Operator       = result => str.TypedOperator(result).Equals(pattern.TypedOperator(result));
                this.AggregateLevel = SetAggregateLevel(str.AggregateLevel, pattern.AggregateLevel);
                break;

            case NP.leftNull:
                this.Operator       = result => str.TypedOperator(result).Equals(pattern.Const);
                this.AggregateLevel = str.AggregateLevel;
                break;

            case NP.rigthNull:
                this.Operator       = result => str.Const.Equals(pattern.TypedOperator(result));
                this.AggregateLevel = pattern.AggregateLevel;
                break;

            case NP.bothNotNull:
                this.Const = new OV_bool(str.Const.Equals(pattern.Const));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            this.TypedOperator = result => new OV_bool(this.Operator(result));
        }
        public SparqlSHA256(SparqlExpression value)   : base(value)
        {
            //SetExprType(ObjectVariantEnum.Str);
            //value.SetExprType(ObjectVariantEnum.Str);

            Create(value);
        }
Exemple #3
0
 protected internal SparqlBinaryExpression(SparqlExpression l, SparqlExpression r, Func <dynamic, dynamic, dynamic> @operator, string symbol)
 {
     this.l         = l;
     this.r         = r;
     this.@operator = @operator;
     this._symbol   = symbol;
 }
Exemple #4
0
        public SparqlInCollectionExpression(SparqlExpression itemExpression, List <SparqlExpression> collection)
        {
            var cConsts = collection.Select(expression => expression.Const).ToArray();

            if (itemExpression.Const != null)
            {
                if (cConsts.Contains(itemExpression.Const))
                {
                    Const = new OV_bool(true);
                    return;
                }
                if (cConsts.All(c => c != null))
                {
                    Const = new OV_bool(false);
                    return;
                }
                AggregateLevel = SetAggregateLevel(collection.Select(c => c.AggregateLevel).ToArray());
            }
            else
            {
                AggregateLevel = SetAggregateLevel(itemExpression.AggregateLevel,
                                                   SetAggregateLevel(collection.Select(c => c.AggregateLevel).ToArray()));
            }

            Operator = result =>
            {
                var o = itemExpression.Operator(result);
                return(collection.Any(element => element.Operator(result).Equals(o)));
            };
            TypedOperator = o => new OV_bool(Operator(o));
            //SetExprType(ObjectVariantEnum.Bool);
        }
        public SparqlStringLang(SparqlExpression literalExpression, SparqlExpression langExpression)
        {
            switch (NullablePairExt.Get(literalExpression.Const, langExpression.Const))
            {
            case NP.bothNull:
                Operator       = literalExpression.Operator;
                TypedOperator  = result => new OV_langstring((string)literalExpression.Operator(result), (string)langExpression.Operator(result));
                AggregateLevel = SetAggregateLevel(literalExpression.AggregateLevel, langExpression.AggregateLevel);
                break;

            case NP.leftNull:
                Operator       = literalExpression.Operator;
                TypedOperator  = result => new OV_langstring((string)literalExpression.Operator(result), (string)langExpression.Const.Content);
                AggregateLevel = literalExpression.AggregateLevel;
                break;

            case NP.rigthNull:
                Operator       = result => literalExpression.Const.Content;
                TypedOperator  = result => new OV_langstring((string)literalExpression.Const.Content, langExpression.Operator(result));
                AggregateLevel = langExpression.AggregateLevel;
                break;

            case NP.bothNotNull:
                Const = new OV_langstring((string)literalExpression.Const.Content, (string)langExpression.Const.Content);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #6
0
        public SparqlStrEnds(SparqlExpression str, SparqlExpression pattern)
        {
            switch (NullablePairExt.Get(str.Const, pattern.Const))
            {
            case NP.bothNull:
                this.Operator       = result => ((string)str.Operator(result)).EndsWith(pattern.Operator(result));
                this.AggregateLevel = SetAggregateLevel(str.AggregateLevel, pattern.AggregateLevel);
                this.TypedOperator  = result => str.TypedOperator(result).Change(o => ((string)o).EndsWith((string)pattern.TypedOperator(result).Content));
                break;

            case NP.leftNull:
                this.Operator       = result => ((string)str.Operator(result)).EndsWith((string)pattern.Const.Content);
                this.TypedOperator  = result => pattern.Const.Change(o => ((string)str.Operator(result)).EndsWith(o));
                this.AggregateLevel = str.AggregateLevel;
                break;

            case NP.rigthNull:
                this.Operator       = result => ((string)str.Const.Content).EndsWith(pattern.Operator(result));
                this.TypedOperator  = result => str.Const.Change(o => ((string)o).EndsWith((string)pattern.Operator(result).Content));
                this.AggregateLevel = pattern.AggregateLevel;
                break;

            case NP.bothNotNull:
                this.Const = new OV_bool(((string)str.Const.Content).EndsWith((string)pattern.Const.Content));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        public SparqlStrBefore(SparqlExpression str, SparqlExpression pattern)
        {
            switch (NullablePairExt.Get(str.Const, pattern.Const))
            {
            case NP.bothNull:
                Operator       = result => StringBefore(str.Operator(result), pattern.Operator(result));
                AggregateLevel = SetAggregateLevel(str.AggregateLevel, pattern.AggregateLevel);
                TypedOperator  = result => str.TypedOperator(result).Change(o => StringBefore(o, (string)pattern.TypedOperator(result).Content));
                break;

            case NP.leftNull:
                Operator       = result => StringBefore(str.Operator(result), (string)pattern.Const.Content);
                TypedOperator  = result => pattern.Const.Change(o => StringBefore(str.Operator(result), o));
                AggregateLevel = str.AggregateLevel;
                break;

            case NP.rigthNull:
                Operator       = result => StringBefore((string)str.Const.Content, pattern.Operator(result));
                TypedOperator  = result => str.Const.Change(o => StringBefore(o, (string)pattern.Operator(result).Content));
                AggregateLevel = pattern.AggregateLevel;
                break;

            case NP.bothNotNull:
                Const = new OV_bool(StringBefore((string)str.Const.Content, (string)pattern.Const.Content));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #8
0
        public SparqlStrDataType(SparqlExpression sparqlExpression1, SparqlExpression sparqlExpression2, NodeGenerator q)
        {
            // TODO: Complete member initialization
            switch (NullablePairExt.Get(sparqlExpression1.Const, sparqlExpression2.Const))
            {
            case NP.bothNull:
                TypedOperator  = result => q.CreateLiteralNode((string)sparqlExpression1.Operator(result), (string)sparqlExpression2.Operator(result));
                Operator       = res => sparqlExpression1.Operator(res);
                AggregateLevel = SetAggregateLevel(sparqlExpression1.AggregateLevel, sparqlExpression2.AggregateLevel);
                break;

            case NP.leftNull:
                TypedOperator  = result => q.CreateLiteralNode((string)sparqlExpression1.Operator(result), (string)sparqlExpression2.Const.Content);
                Operator       = res => sparqlExpression1.Operator(res);
                AggregateLevel = sparqlExpression1.AggregateLevel;
                break;

            case NP.rigthNull:
                TypedOperator  = result => q.CreateLiteralNode((string)sparqlExpression1.Const.Content, (string)sparqlExpression2.Operator(result));
                Operator       = res => sparqlExpression1.Const.Content;
                AggregateLevel = sparqlExpression2.AggregateLevel;

                break;

            case NP.bothNotNull:
                Const = q.CreateLiteralNode((string)sparqlExpression1.Const.Content, (string)sparqlExpression2.Const.Content);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #9
0
        //internal static SparqlExpression EqualsExpression(SparqlExpression l, SparqlExpression r)
        //{
        //  return new SparqlEqualsExpression(l, r, TODO);
        //}

        //public static SparqlExpression NotEquals(SparqlExpression l, SparqlExpression r)
        //{
        // return new SparqlNotEqualsExpression(l, r);
        //}



        public static SparqlExpression Smaller(SparqlExpression l, SparqlExpression r)
        {
            var sparqlBinaryExpression = new SparqlBinaryExpression <OV_bool>(l, r, (o, o1) => o < o1, b => new OV_bool(b));//((IComparable) o).CompareTo((IComparable)o1) == -1

            //   sparqlBinaryExpression.SetExprType(ObjectVariantEnum.Bool);
            return(sparqlBinaryExpression);
        }
Exemple #10
0
        public SparqlStrStarts(SparqlExpression str, SparqlExpression pattern)
        {
            switch (NullablePairExt.Get(str.Const, pattern.Const))
            {
            case NP.bothNull:
                Operator      = result => str.Operator(result).StartsWith(pattern.Operator(result));
                TypedOperator =
                    result => str.TypedOperator(result).Change(o => o.StartsWith(pattern.Operator(result)));
                AggregateLevel = SetAggregateLevel(str.AggregateLevel, pattern.AggregateLevel);
                break;

            case NP.leftNull:
                Operator       = result => str.Operator(result).StartsWith(pattern.Const.Content);
                TypedOperator  = result => str.TypedOperator(result).Change(o => o.StartsWith(pattern.Const.Content));
                AggregateLevel = str.AggregateLevel;
                break;

            case NP.rigthNull:

                Operator       = result => ((string)str.Const.Content).StartsWith(pattern.Operator(result));
                TypedOperator  = result => str.Const.Change(o => o.StartsWith(pattern.Operator(result)));
                AggregateLevel = pattern.AggregateLevel;
                break;

            case NP.bothNotNull:
                Const = str.Const.Change(o => o.StartsWith(pattern.Const.Content));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #11
0
        public static SparqlExpression GreatherOrEquals(SparqlExpression l, SparqlExpression r)
        {
            var sparqlBinaryExpression = new SparqlBinaryExpression <OV_bool>(l, r, (o, o1) => o >= o1, b => new OV_bool(b));//((IComparable)o).CompareTo(o1) != -1

            //   sparqlBinaryExpression.SetExprType(ObjectVariantEnum.Bool);
            return(sparqlBinaryExpression);
        }
Exemple #12
0
        public SparqlTz(SparqlExpression value)   : base(value.AggregateLevel, value.IsStoreUsed)
        {
            if (value.Const != null)
            {
                var f = value.Const.Content;

                if (f is DateTimeOffset)
                {
                    Const = new OV_string(((DateTimeOffset)f).Offset.ToString());
                }
                else if (f is DateTime)
                {
                    Const = new OV_string("");
                }
                throw new ArgumentException();
            }
            else
            {
                Operator = result =>
                {
                    var f = value.Operator(result);
                    if (f is DateTimeOffset)
                    {
                        return(((DateTimeOffset)f).Offset.ToString());
                    }
                    else if (f is DateTime)
                    {
                        return("");
                    }
                    throw new ArgumentException();
                };
                TypedOperator = result => new OV_string(Operator(result));
            }
        }
Exemple #13
0
        public SparqlStrAfter(SparqlExpression str, SparqlExpression pattern)
        {
            // TODO: Complete member initialization
            // str.SetExprType(ExpressionTypeEnum.@stringOrWithLang);
            // pattern.SetExprType(ExpressionTypeEnum.@stringOrWithLang);

            // SetExprType(ExpressionTypeEnum.@stringOrWithLang);
            switch (NullablePairExt.Get(str.Const, pattern.Const))
            {
            case NP.bothNull:
                this.Operator       = result => StringAfter(str.Operator(result), pattern.Operator(result));
                this.AggregateLevel = SetAggregateLevel(str.AggregateLevel, pattern.AggregateLevel);
                this.TypedOperator  = result => str.TypedOperator(result).Change(o => StringAfter(o, (string)pattern.TypedOperator(result).Content));
                break;

            case NP.leftNull:
                this.Operator       = result => StringAfter(str.Operator(result), (string)pattern.Const.Content);
                this.TypedOperator  = result => pattern.Const.Change(o => StringAfter(str.Operator(result), o));
                this.AggregateLevel = str.AggregateLevel;
                break;

            case NP.rigthNull:
                this.Operator       = result => StringAfter((string)str.Const.Content, pattern.Operator(result));
                this.TypedOperator  = result => str.Const.Change(o => StringAfter(o, (string)pattern.Operator(result).Content));
                this.AggregateLevel = pattern.AggregateLevel;
                break;

            case NP.bothNotNull:
                this.Const = new OV_bool(this.StringAfter((string)str.Const.Content, (string)pattern.Const.Content));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        public void SetStartPosition(SparqlExpression substr)
        {
            this.substExpression = substr;
            switch (NullablePairExt.Get(this.strExpression.Const, this.substExpression.Const))
            {
            case NP.bothNull:
                this.Operator      = result => this.strExpression.Operator(result).Substring(this.substExpression.Operator(result));
                this.TypedOperator =
                    result => this.strExpression.TypedOperator(result)
                    .Change(o => o.Substring(this.substExpression.Operator(result)));
                this.AggregateLevel = SetAggregateLevel(this.strExpression.AggregateLevel, this.substExpression.AggregateLevel);
                break;

            case NP.leftNull:
                this.Operator      = result => this.strExpression.Operator(result).Substring(this.substExpression.Const.Content);
                this.TypedOperator =
                    result => this.substExpression.Const.
                    Change(o => this.strExpression.Operator(result).Substring(o));
                this.AggregateLevel = this.strExpression.AggregateLevel;
                break;

            case NP.rigthNull:
                this.Operator       = result => ((string)this.strExpression.Const.Content).Substring(this.substExpression.Operator(result));
                this.TypedOperator  = result => this.strExpression.Const.Change(o => o.Substring(this.substExpression.Operator(result)));
                this.AggregateLevel = this.substExpression.AggregateLevel;
                break;

            case NP.bothNotNull:
                this.Const = this.strExpression.Const.Change(o => o.Substring(this.substExpression.Const.Content));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #15
0
        internal void SetRegex(SparqlExpression patternExpression)
        {
            var varConst = this.variableExpression.Const;

            this.pattern = patternExpression;
            var   patternConst = patternExpression.Const;
            Regex regex;

            switch (NullablePairExt.Get(this.pattern, varConst))
            {
            case NP.bothNull:
                break;

            case NP.leftNull:
                this.Operator = result =>
                {
                    string patternStr = (string)patternExpression.TypedOperator(result).Content;
                    regex = this.CreateRegex(patternStr);
                    return(regex.IsMatch((string)varConst.Content));
                };
                this.AggregateLevel = patternExpression.AggregateLevel;
                break;

            case NP.rigthNull:
                var content = (string)patternConst.Content;
                regex = this.CreateRegex(content);
                var varExpression = this.variableExpression as SparqlVarExpression;
                if (varExpression != null && isSimple.IsMatch(content))
                {
                    this.Operator = result =>
                    {
                        if (result.ContainsKey(varExpression.Variable))
                        {
                            return(regex.IsMatch(varExpression.Operator(result)));
                        }
                        return(this.store.GetTriplesWithTextObject(varExpression.Operator(result))
                               .Select(this.Selector(result, varExpression.Variable)));
                    };
                }
                else
                {
                    this.Operator = result => regex.IsMatch(this.variableExpression.Operator(result));
                }

                this.AggregateLevel = this.variableExpression.AggregateLevel;
                break;

            case NP.bothNotNull:
                regex      = this.CreateRegex((string)patternConst.Content);
                this.Const = new OV_bool(regex.IsMatch((string)this.variableExpression.Const.Content));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            this.TypedOperator = result => new OV_bool(this.Operator(result));
        }
        public SparqlLangMatches(SparqlExpression value, SparqlExpression langExpression)
        {
            // value.SetExprType(ObjectVariantEnum.Str); //todo lang
            // langExpression.SetExprType(ObjectVariantEnum.Str); //todo lang
            switch (NullablePairExt.Get(value.Const, langExpression.Const))
            {
            case NP.bothNull:
                this.Operator = result =>
                {
                    var lang      = value.Operator(result);
                    var langRange = langExpression.Operator(result);
                    return(Equals(langRange.Content, "*")
                    ? !string.IsNullOrWhiteSpace(langRange.Content)
                    : Equals(lang, langRange));
                };

                this.AggregateLevel = SetAggregateLevel(value.AggregateLevel, langExpression.AggregateLevel);
                break;

            case NP.leftNull:
                var rlang = langExpression.Const.Content;
                this.Operator = result =>
                {
                    var lang = value.Operator(result);
                    return(Equals(rlang, "*")
                            ? !string.IsNullOrWhiteSpace(lang)
                            : Equals(lang, rlang));
                };
                this.AggregateLevel = value.AggregateLevel;
                break;

            case NP.rigthNull:
                var llang = value.Const.Content;
                if (llang.Equals("*"))
                {
                    this.Operator = result => !string.IsNullOrWhiteSpace(langExpression.Operator(result));
                }
                else
                {
                    this.Operator = result => Equals(llang, langExpression.Operator(result));
                }
                this.AggregateLevel = langExpression.AggregateLevel;
                break;

            case NP.bothNotNull:
                var ll = value.Const.Content;
                var rl = langExpression.Const.Content;
                this.Const = new OV_bool(Equals(rl, "*")
                            ? !string.IsNullOrWhiteSpace((string)ll)
                            : Equals(ll, rl));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            this.TypedOperator = result => new OV_bool(this.Operator(result));
        }
 public SparqlDivideExpression(SparqlExpression l, SparqlExpression r) : base(l, r, (o, o1) =>
 {
     if (o is int && o1 is int)
     {
         return(Convert.ToDecimal(o) / o1);
     }
     return(o / o1);
 })
 {
 }
        internal void SetLength(SparqlExpression lengthExpression)
        {
            this.lengthExpression = lengthExpression;
            switch (NullableTripleExt.Get(this.strExpression.Const, this.substExpression.Const, lengthExpression.Const))
            {
            case NT.AllNull:
                this.TypedOperator  = result => this.strExpression.TypedOperator(result).Change(o => o.Substring(this.substExpression.Operator(result), lengthExpression.Operator(result)));
                this.Operator       = result => this.strExpression.Operator(result).Substring(this.substExpression.Operator(result), lengthExpression.Operator(result));
                this.AggregateLevel = SetAggregateLevel(this.strExpression.AggregateLevel, this.substExpression.AggregateLevel, lengthExpression.AggregateLevel);
                break;

            case NT.FirstNotNull:
                this.TypedOperator  = result => this.strExpression.Const.Change(o => o.Substring(this.substExpression.Operator(result), lengthExpression.Operator(result)));
                this.Operator       = result => ((string)this.strExpression.Const.Content).Substring(this.substExpression.Operator(result), lengthExpression.Operator(result));
                this.AggregateLevel = SetAggregateLevel(this.substExpression.AggregateLevel, lengthExpression.AggregateLevel);
                break;

            case NT.SecondNotNull:
                this.TypedOperator  = result => this.strExpression.TypedOperator(result).Change(o => o.Substring(this.substExpression.Const.Content, lengthExpression.Operator(result)));
                this.Operator       = result => this.strExpression.Operator(result).Substring(this.substExpression.Const.Content, lengthExpression.Operator(result));
                this.AggregateLevel = SetAggregateLevel(this.strExpression.AggregateLevel, lengthExpression.AggregateLevel);
                break;

            case NT.ThirdNotNull:
                this.TypedOperator  = result => this.strExpression.TypedOperator(result).Change(o => o.Substring(this.substExpression.Operator(result), lengthExpression.Const.Content));
                this.Operator       = result => this.strExpression.Operator(result).Substring(this.substExpression.Operator(result), lengthExpression.Const.Content);
                this.AggregateLevel = SetAggregateLevel(this.strExpression.AggregateLevel, this.substExpression.AggregateLevel);
                break;

            case (NT)254:    // ~ NT.FirstNotNull
                this.TypedOperator  = result => this.strExpression.TypedOperator(result).Change(o => o.Substring(this.substExpression.Const.Content, lengthExpression.Const.Content));
                this.Operator       = result => this.strExpression.Operator(result).Substring(this.substExpression.Const.Content, lengthExpression.Const.Content);
                this.AggregateLevel = this.strExpression.AggregateLevel;
                break;

            case (NT)253:   // ~NT.SecondNotNull
                this.TypedOperator  = result => this.strExpression.Const.Change(o => o.Substring(this.substExpression.Operator(result), lengthExpression.Const.Content));
                this.Operator       = result => ((string)this.strExpression.Const.Content).Substring(this.substExpression.Operator(result), (int)lengthExpression.Const.Content);
                this.AggregateLevel = this.substExpression.AggregateLevel;
                break;

            case (NT)252:    // ~ NT.ThirdNotNull
                this.TypedOperator  = result => this.strExpression.Const.Change(o => o.Substring(this.substExpression.Const.Content, lengthExpression.Operator(result)));
                this.Operator       = result => ((string)this.strExpression.Const.Content).Substring((int)this.substExpression.Const.Content, lengthExpression.Operator(result));
                this.AggregateLevel = lengthExpression.AggregateLevel;
                break;

            case (NT)255:    // ~NT.AllNull
                this.Const = this.strExpression.Const.Change(o => o.Substring(this.substExpression.Const.Content, lengthExpression.Const.Content));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
 public SparqlStrLength(SparqlExpression value) : base(value.AggregateLevel, value.IsStoreUsed)
 {
     if (value.Const != null)
     {
         Const = new OV_int(((string)value.Const.Content).Length);
     }
     else
     {
         Operator      = result => ((string)value.TypedOperator(result).Content).Length;
         TypedOperator = result => new OV_int(((string)value.TypedOperator(result).Content).Length);
     }
 }
 public SparqlMonth(SparqlExpression value)  : base(value.AggregateLevel, value.IsStoreUsed)
 {
     if (value.Const != null)
     {
         Const = new OV_int(GetMonth(value.Const.Content));
     }
     else
     {
         Operator      = result => GetMonth(value.Operator(result));
         TypedOperator = result => new OV_int(Operator(result));
     }
 }
Exemple #21
0
        internal static SparqlExpression SmallerOrEquals(SparqlExpression l, SparqlExpression r)
        {
            var sparqlBinaryExpression = new SparqlBinaryExpression <OV_bool>(
                l,
                r,
                (o, o1) => o <= o1,
                b => new OV_bool(b),
                "smallerEqual"); // ((IComparable)o).CompareTo(o1) != 1

            // sparqlBinaryExpression.SetExprType(ObjectVariantEnum.Bool);
            return(sparqlBinaryExpression);
        }
Exemple #22
0
 protected void Create(SparqlExpression value)
 {
     if (value.Const != null)
     {
         this.Const = new OV_string(this.CreateHash((string)value.Const.Content));
     }
     else
     {
         this.Operator      = result => CreateHash(value.Operator(result));
         this.TypedOperator = result => new OV_string(this.Operator(result));
     }
 }
Exemple #23
0
 public SparqlMinutes(SparqlExpression value) : base(value.AggregateLevel, value.IsStoreUsed)
 {
     if (value.Const != null)
     {
         this.Const = new OV_int(GetMinute(value.Const.Content));
     }
     else
     {
         this.Operator      = result => GetMinute(value.Operator(result));
         this.TypedOperator = result => new OV_int(this.Operator(result));
     }
 }
Exemple #24
0
 public SparqlIsBlank(SparqlExpression value)  : base(value.AggregateLevel, value.IsStoreUsed)
 {
     //SetExprType(ObjectVariantEnum.Bool);
     if (value.Const != null)
     {
         Const = new OV_bool(value.Const is IBlankNode);
     }
     else
     {
         Operator      = result => value.TypedOperator(result) is IBlankNode;
         TypedOperator = result => new OV_bool(value.TypedOperator(result) is IBlankNode); //todo
     }
 }
        public SparqlOrExpression(SparqlExpression l, SparqlExpression r)
        {
            this._l = l;
            this._r = r;

            // l.SetExprType(ObjectVariantEnum.Bool);
            // r.SetExprType(ObjectVariantEnum.Bool);
            // SetExprType(ObjectVariantEnum.Bool);
            switch (NullablePairExt.Get(l.Const, r.Const))
            {
            case NP.bothNull:
                this.Operator       = res => l.Operator(res) || r.Operator(res);
                this.AggregateLevel = SetAggregateLevel(l.AggregateLevel, r.AggregateLevel);
                break;

            case NP.leftNull:
                if ((bool)l.Const.Content)
                {
                    this.Const = new OV_bool(true);
                }
                else
                {
                    this.Operator       = r.Operator;
                    this.AggregateLevel = r.AggregateLevel;
                }

                break;

            case NP.rigthNull:
                if ((bool)r.Const.Content)
                {
                    this.Const = new OV_bool(true);
                }
                else
                {
                    this.Operator       = l.Operator;
                    this.AggregateLevel = l.AggregateLevel;
                }

                break;

            case NP.bothNotNull:
                this.Const = new OV_bool((bool)l.Const.Content || (bool)r.Const.Content);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            this.TypedOperator = result => new OV_bool(this.Operator(result));
        }
Exemple #26
0
 public SparqlUri(SparqlExpression value, RdfQuery11Translator q)  : base(value.AggregateLevel, value.IsStoreUsed)
 {
     if (value.Const != null)
     {
         Const = new OV_iri(q.prolog.GetFromString((string)value.Const.Content));
     }
     else
     {
         Operator = result => new OV_iri(q.prolog.GetFromString((string)value.Operator(result).Content));
         //SetExprType(ObjectVariantEnum.Iri);
         TypedOperator =
             result => new OV_iri(q.prolog.GetFromString((string)value.TypedOperator(result).Content));
     }
 }
Exemple #27
0
        public static SparqlExpression Greather(SparqlExpression l, SparqlExpression r)
        {
            //Func<object, object, object> @operator;
            //if (l.RealType == ObjectVariantEnum.Int || r.RealType == ObjectVariantEnum.Int)
            //    @operator = (o, o1) => (int)o > (int)o1;
            //else
            //    if (l.RealType == ObjectVariantEnum.Date|| r.RealType == ObjectVariantEnum.Date)
            //    @operator = (o, o1) => (DateTimeOffset)o > (DateTimeOffset)o1;
            //else                                                          throw new NotImplementedException();
            var sparqlBinaryExpression = new SparqlBinaryExpression <OV_bool>(l, r, (o, o1) => o > o1, b => new OV_bool(b));// ((IComparable)o).CompareTo(o1) == 1

            //     sparqlBinaryExpression.SetExprType(ObjectVariantEnum.Bool);
            return(sparqlBinaryExpression);
        }
Exemple #28
0
 public SparqlEncodeForUri(SparqlExpression value, RdfQuery11Translator q)   : base(value.AggregateLevel, value.IsStoreUsed)
 {
     //SetExprType(ObjectVariantEnum.Str);
     //  value.SetExprType(ExpressionTypeEnum.stringOrWithLang);
     if (value.Const != null)
     {
         Const = new OV_string(HttpUtility.UrlEncode((string)value.Const.Content));
     }
     else
     {
         Operator      = result => HttpUtility.UrlEncode((string)value.Operator(result).Content);
         TypedOperator = result => new OV_string(Operator(result));
     }
 }
Exemple #29
0
        // private SparqlExpression sparqlExpression;

        public SparqlToString(SparqlExpression child) : base(child.AggregateLevel, child.IsStoreUsed)

        {
            var childConst = child.Const;

            if (childConst != null)
            {
                Const = new OV_string(childConst.Content.ToString());
            }
            else
            {
                Operator      = result => child.Operator(result).ToString();
                TypedOperator = result => new OV_string(child.Operator(result).ToString());
            }
        }
        public SparqlUnaryExpression(Func <dynamic, dynamic> @operator, SparqlExpression child)
            : base(child.AggregateLevel, child.IsStoreUsed)
        {
            var childConst = child.Const;

            if (childConst != null)
            {
                Const = childConst.Change(@operator(childConst.Content));
            }
            else
            {
                Operator      = result => @operator(child.Operator(result));
                TypedOperator = results => child.TypedOperator(results).Change(@operator);
            }
        }