Exemplo n.º 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)
        {
            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));
            }
        }
Exemplo n.º 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)
        {
            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());
        }
Exemplo n.º 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();
        }
Exemplo n.º 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)
        {
            //Swap the Subject and Object over
            PatternItem tempObj = context.Object;
            PatternItem tempSubj = context.Subject;
            PatternItem tempEnd = context.End;
            context.Object = tempSubj;
            context.Subject = tempObj;
            context.End = tempSubj;

            //Then transform the path
            context.AddTriplePattern(context.GetTriplePattern(context.Subject, this._path, context.Object));

            //Then swap the Subject and Object back
            context.Subject = tempSubj;
            context.Object = tempObj;
            context.End = tempEnd;

            return context.ToAlgebra();
        }
Exemplo n.º 5
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)
        {
            // Swap the Subject and Object over
            PatternItem tempObj  = context.Object;
            PatternItem tempSubj = context.Subject;
            PatternItem tempEnd  = context.End;

            context.Object  = tempSubj;
            context.Subject = tempObj;
            context.End     = tempSubj;

            // Then transform the path
            context.AddTriplePattern(context.GetTriplePattern(context.Subject, _path, context.Object));

            // Then swap the Subject and Object back
            context.Subject = tempSubj;
            context.Object  = tempObj;
            context.End     = tempEnd;

            return(context.ToAlgebra());
        }
Exemplo n.º 6
0
 /// <summary>
 /// Converts a Path into its Algebra Form.
 /// </summary>
 /// <param name="context">Path Transformation Context.</param>
 /// <returns></returns>
 public ISparqlAlgebra ToAlgebra(PathTransformContext context)
 {
     context.AddTriplePattern(context.GetTriplePattern(context.Subject, this, context.Object));
     return(context.ToAlgebra());
 }
Exemplo n.º 7
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);
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// Converts a Path into its Algebra Form
 /// </summary>
 /// <param name="context">Path Transformation Context</param>
 /// <returns></returns>
 public ISparqlAlgebra ToAlgebra(PathTransformContext context)
 {
     context.AddTriplePattern(context.GetTriplePattern(context.Subject, this, context.Object));
     return context.ToAlgebra();
 }