示例#1
0
        /// <summary>
        /// Converts a Path into its Algebra Form.
        /// </summary>
        /// <param name="context">Path Transformation Context.</param>
        /// <returns></returns>
        public override ISparqlAlgebra ToAlgebra(PathTransformContext context)
        {
            bool top = context.Top;

            // The Object becomes a temporary variable then we transform the LHS of the path
            context.Object = context.GetNextTemporaryVariable();
            context.Top    = false;
            context.AddTriplePattern(context.GetTriplePattern(context.Subject, _lhs, context.Object));

            // The Subject is then the Object that results from the LHS transform since the
            // Transform may adjust the Object
            context.Subject = context.Object;

            // We then reset the Object to be the target Object so that if the RHS is the last part
            // of the Path then it will complete the path transformation
            // If it isn't the last part of the path it will be set to a new temporary variable
            context.Top = top;
            if (context.Top)
            {
                context.ResetObject();
            }
            else
            {
                context.Object = context.GetNextTemporaryVariable();
            }
            context.Top = top;
            context.AddTriplePattern(context.GetTriplePattern(context.Subject, _rhs, context.Object));

            return(context.ToAlgebra());
        }
示例#2
0
        /// <summary>
        /// Converts a Path into its Algebra Form
        /// </summary>
        /// <param name="context">Path Transformation Context</param>
        /// <returns></returns>
        public override ISparqlAlgebra ToAlgebra(PathTransformContext context)
        {
            if (this._n > 0)
            {
                // Generate a Triple Pattern for each step in the cardinality
                for (int i = 0; i < this._n; i++)
                {
                    context.Object = context.GetNextTemporaryVariable();

                    if (i < this._n - 1 || !context.Top)
                    {
                        context.AddTriplePattern(context.GetTriplePattern(context.Subject, this._path, context.Object));
                        context.Subject = context.Object;
                    }
                    else
                    {
                        context.ResetObject();
                        context.AddTriplePattern(context.GetTriplePattern(context.Subject, this._path, context.Object));
                    }
                }

                return(context.ToAlgebra());
            }
            else
            {
                return(new ZeroLengthPath(context.Subject, context.Object, this._path));
            }
        }
示例#3
0
        /// <summary>
        /// Converts a Path into its Algebra Form
        /// </summary>
        /// <param name="context">Path Transformation Context</param>
        /// <returns></returns>
        public override ISparqlAlgebra ToAlgebra(PathTransformContext context)
        {
            bool top = context.Top;

            //The Object becomes a temporary variable then we transform the LHS of the path
            context.Object = context.GetNextTemporaryVariable();
            context.Top = false;
            context.AddTriplePattern(context.GetTriplePattern(context.Subject, this._lhs, context.Object));

            //The Subject is then the Object that results from the LHS transform since the
            //Transform may adjust the Object
            context.Subject = context.Object;

            //We then reset the Object to be the target Object so that if the RHS is the last part
            //of the Path then it will complete the path transformation
            //If it isn't the last part of the path it will be set to a new temporary variable
            context.Top = top;
            if (context.Top)
            {
                context.ResetObject();
            }
            else
            {
                context.Object = context.GetNextTemporaryVariable();
            }
            context.Top = top;
            context.AddTriplePattern(context.GetTriplePattern(context.Subject, this._rhs, context.Object));

            return context.ToAlgebra();
        }
示例#4
0
        /// <summary>
        /// Converts a Path into its Algebra Form
        /// </summary>
        /// <param name="context">Path Transformation Context</param>
        /// <returns></returns>
        public override ISparqlAlgebra ToAlgebra(PathTransformContext context)
        {
            PatternItem tempVar = context.GetNextTemporaryVariable();

            context.AddTriplePattern(new PropertyPathPattern(context.Subject, new FixedCardinality(this._path, this._n), tempVar));
            context.AddTriplePattern(new PropertyPathPattern(tempVar, new ZeroOrMore(this._path), context.Object));
            return(context.ToAlgebra());
        }
 /// <summary>
 /// Converts a Path into its Algebra Form
 /// </summary>
 /// <param name="context">Path Transformation Context</param>
 /// <returns></returns>
 public override ISparqlAlgebra ToAlgebra(PathTransformContext context)
 {
     PatternItem tempVar = context.GetNextTemporaryVariable();
     context.AddTriplePattern(new PropertyPathPattern(context.Subject, new FixedCardinality(this._path, this._n), tempVar));
     context.AddTriplePattern(new PropertyPathPattern(tempVar, new ZeroOrMore(this._path), context.Object));
     return context.ToAlgebra();
 }
        /// <summary>
        /// Converts a Path into its Algebra Form
        /// </summary>
        /// <param name="context">Path Transformation Context</param>
        /// <returns></returns>
        public override ISparqlAlgebra ToAlgebra(PathTransformContext context)
        {
            if (this._n > 0)
            {
                //Generate a Triple Pattern for each step in the cardinality
                for (int i = 0; i < this._n; i++)
                {
                    context.Object = context.GetNextTemporaryVariable();

                    if (i < this._n - 1 || !context.Top)
                    {
                        context.AddTriplePattern(context.GetTriplePattern(context.Subject, this._path, context.Object));
                        context.Subject = context.Object;
                    }
                    else
                    {
                        context.ResetObject();
                        context.AddTriplePattern(context.GetTriplePattern(context.Subject, this._path, context.Object));
                    }
                }

                return context.ToAlgebra();
            }
            else
            {
                return new ZeroLengthPath(context.Subject, context.Object, this._path);
            }
        }