Package com.hp.hpl.jena.sparql.core

Examples of com.hp.hpl.jena.sparql.core.TriplePath


    {
        if ( triplePath.isTriple() )
        {
            // Fake it.  This happens only for API constructed situations.
            Path path = new P_Link(triplePath.getPredicate()) ;
            triplePath = new TriplePath(triplePath.getSubject(),
                                        path,
                                        triplePath.getObject()) ;
        }
       
        return execTriplePath(binding,
View Full Code Here


    public TransformPathFlatternStd() { }
   
    @Override
    public Op transform(OpPath opPath)
    {
        TriplePath tp = opPath.getTriplePath() ;
        Op op = transformPath(opPath, tp.getSubject(), tp.getPath(), tp.getObject() ) ;
        // And combine adjacent triple patterns.
        return op ;
    }
View Full Code Here

        return r ;
    }
   
    static OpPath make(Node subject, Path path, Node object)
    {
        TriplePath tp = new TriplePath(subject, path, object) ;
        return new OpPath(tp) ;
    }
View Full Code Here

        return new OpBGP(bgp2) ;
    }
   
    @Override public Op transform(OpPath opPath)
    {
        TriplePath tp = opPath.getTriplePath() ;
        Node s = tp.getSubject() ;
        Node s1 = transform.convert(s) ;
        Node o = tp.getObject() ;
        Node o1 = transform.convert(o) ;
       
        if ( s1 == s && o1 == o )
            // No change.
            return super.transform(opPath) ;
       
        Path path = tp.getPath() ;
        TriplePath tp2 ;

        if ( path != null )
            tp2 = new TriplePath(s1, path, o1) ;
        else
        {
            Triple t = new Triple(s1, tp.getPredicate(), o1) ;
            tp2 = new TriplePath(t) ;
        }
        return new OpPath(tp2) ;
    }
View Full Code Here

    }
   
    protected void insert(TripleCollector acc, Node s, Node p, Path path, Node o)
    {
        if ( p == null )
            acc.addTriplePath(new TriplePath(s, path, o)) ;
        else
            acc.addTriple(new Triple(s, p, o)) ;
    }
View Full Code Here

    }
   
    protected void insert(TripleCollectorMark acc, int index, Node s, Node p, Path path, Node o)
    {
        if ( p == null )
            acc.addTriplePath(index, new TriplePath(s, path, o)) ;
        else
            acc.addTriple(index, new Triple(s, p, o)) ;
    }
View Full Code Here

        }
       
        Node s = BuilderNode.buildNode(list.get(0)) ;
        Path p = BuilderPath.buildPath(list.get(1)) ;
        Node o = BuilderNode.buildNode(list.get(2)) ;
        return new TriplePath(s, p, o) ;
    }
View Full Code Here

    @Override
    public QueryIterator execEvaluated(Binding binding,
                                       Node subject, Node predicate, Node object,
                                       ExecutionContext execCxt)
    {
        return new QueryIterPath(new TriplePath(subject, path, object),
                                 QueryIterSingleton.create(binding, execCxt),
                                 execCxt) ;
    }
View Full Code Here

       
        if ( path instanceof P_Link )
        {
            Node pred = ((P_Link)path).getNode() ;
            Triple t = new Triple(startNode, pred, endNode) ;
            x.add(new TriplePath(t)) ;
            return ;
        }

        if ( path instanceof P_Seq )
        {
            P_Seq ps = (P_Seq)path ;
            Node v = varAlloc.allocVar() ;
            reduce(x, varAlloc, startNode, ps.getLeft(), v) ;
            reduce(x, varAlloc, v, ps.getRight(), endNode) ;
            return ;
        }

        if ( path instanceof P_Inverse )
        {
            reduce(x, varAlloc, endNode, ((P_Inverse)path).getSubPath(), startNode) ;
            return ;
        }

        if ( path instanceof P_FixedLength )
        {
            P_FixedLength pFixed = (P_FixedLength)path ;
            long N = pFixed.getCount() ;
            if ( N > 0 )
            {
                // Don't do {0}
                Node stepStart = startNode ;
   
                for ( long i = 0 ; i < N-1 ; i++ )
                {
                    Node v = varAlloc.allocVar() ;
                    reduce(x, varAlloc, stepStart, pFixed.getSubPath(), v) ;
                    stepStart = v ;
                }
                reduce(x, varAlloc, stepStart, pFixed.getSubPath(), endNode) ;
                return ;
            }
        }
       
        if ( path instanceof P_Mod )
        {
            P_Mod pMod = (P_Mod)path ;
            if ( pMod.isFixedLength() && pMod.getFixedLength() > 0 )
            {
                long N = pMod.getFixedLength() ;
                if ( N > 0 )
                {
                    Node stepStart = startNode ;

                    for ( long i = 0 ; i < N-1 ; i++ )
                    {
                        Node v = varAlloc.allocVar() ;
                        reduce(x, varAlloc, stepStart, pMod.getSubPath(), v) ;
                        stepStart = v ;
                    }
                    reduce(x, varAlloc, stepStart, pMod.getSubPath(), endNode) ;
                    return ;
                }
            }

            // This is the rewrite of
            //    "x {N,} y" to "x :p{N} ?V . ?V :p* y"
            //    "x {N,M} y" to "x :p{N} ?V . ?V {0,M} y"
            // The spec defines {n,m} to be
            //   {n} union {n+1} union ... union {m}
            // which leads to a lot of repeated work.
           
            if ( pMod.getMin() > 0 )
            {
                Path p1 = PathFactory.pathFixedLength(pMod.getSubPath(), pMod.getMin()) ;
                Path p2 ;
               
                if ( pMod.getMax() < 0 )
                    p2 = PathFactory.pathZeroOrMoreN(pMod.getSubPath()) ;
                else
                {
                    long len2 = pMod.getMax()-pMod.getMin() ;
                    if ( len2 < 0 ) len2 = 0 ;
                    p2 = PathFactory.pathMod(pMod.getSubPath(),0, len2) ;
                }
               
                Node v = varAlloc.allocVar() ;
               
                // Start at the fixed end.
                if ( ! startNode.isVariable() || endNode.isVariable() )
                {
                    reduce(x, varAlloc, startNode, p1, v) ;
                    reduce(x, varAlloc, v, p2, endNode) ;
                }
                else
                {
                    // endNode fixed, start node not.
                    reduce(x, varAlloc, v, p2, endNode) ;
                    reduce(x, varAlloc, startNode, p1, v) ;
                }
                return ;
            }
           
           
            // Else drop through
        }
       
        // Nothing can be done.
        x.add(new TriplePath(startNode, path, endNode)) ;
    }
View Full Code Here

    {
        if ( triplePath.isTriple() )
        {
            // Fake it.  This happens only for API constructed situations.
            Path path = new P_Link(triplePath.getPredicate()) ;
            triplePath = new TriplePath(triplePath.getSubject(),
                                        path,
                                        triplePath.getObject()) ;
        }
       
        return execTriplePath(binding,
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.sparql.core.TriplePath

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.