Package com.hp.hpl.jena.graph

Examples of com.hp.hpl.jena.graph.Graph


    }
   
    @Override
    protected Iter<Quad> findInSpecificNamedGraph(Node g, Node s, Node p , Node o)
    {
        Graph graph = fetchGraph(g) ;
        if ( g == null )
            return Iter.nullIter() ;
        return triples2quads(g, graph.find(s, p, o)) ;
    }
View Full Code Here


            TypedInputStream s = RDFDataMgr.open(source) ;
            Lang lang = RDFDataMgr.determineLang(source, s.getContentType(), null) ;
           
            if ( RDFLanguages.isTriples(lang) ) {
                // Triples
                Graph g = GraphFactory.createGraphMem() ;
                StreamRDF stream = StreamRDFLib.graph(g) ;
                RDFDataMgr.parse(stream, s, source) ;
                Graph g2 = graph(graphStore, dest) ;
                GraphUtil.addInto(g2, g) ;
            } else {
                // Quads
                if ( dest != null )
                    throw new UpdateException("Attempt to load quads into a graph") ;
View Full Code Here

        gsCopyTriples(gStore, src, dest) ;
    }

    protected static void gsCopyTriples(GraphStore gStore, Target src, Target dest)
    {
        Graph gSrc = graph(gStore, src) ;
        Graph gDest = graph(gStore, dest) ;
       
        // Avoids concurrency problems by reading fully before writing
        ThresholdPolicy<Triple> policy = ThresholdPolicyFactory.policyFromContext(gStore.getContext());
        DataBag<Triple> db = BagFactory.newDefaultBag(policy, SerializationFactoryFinder.tripleSerializationFactory()) ;
        try
View Full Code Here

    }

    protected static void gsClear(GraphStore gStore, Target target, boolean isSilent)
    {
        // No create - we tested earlier.
        Graph g = graph(gStore, target) ;
        g.clear() ;
    }
View Full Code Here

    protected DatasetGraph processWith(UpdateModify update)
    {
        Node withGraph = update.getWithIRI() ;
        if ( withGraph == null )
            return null ;
        Graph g = graphOrDummy(graphStore, withGraph) ;
        DatasetGraph dsg = new DatasetGraphAltDefaultGraph(graphStore, g) ;
        return dsg ;
    }
View Full Code Here

        return dsg ;
    }
   
    private Graph graphOrDummy(DatasetGraph dsg, Node gn)
    {
        Graph g = graph(graphStore, gn) ;
        if ( g == null )
            g = GraphFactory.createGraphMem() ;
        return g ;
    }
View Full Code Here

        DatasetGraph dsg = graphStore ;
        if ( query != null )
        {
            if ( dftGraph != null )
            {
                Graph g = graphOrDummy(dsg, dftGraph) ;
                dsg = new DatasetGraphAltDefaultGraph(dsg, g) ;
            }
        }
       
        return evalBindings(query, dsg, inputBinding, context) ;
View Full Code Here

    private void loadOne(String filename, boolean replace)
    {
        Monitor monitor = null ;
       
        Model model = modGraph.getModel(getStore()) ;
        Graph graph = model.getGraph() ;   

        if ( isVerbose() && replace )
            System.out.println("Emptying: "+filename) ;
        if (replace)
            model.removeAll();

        if ( isVerbose() || getModTime().timingEnabled() )
            System.out.println("Start load: "+filename) ;
        if ( getModTime().timingEnabled() )
        {
            monitor = new Monitor(getStore().getLoader().getChunkSize(), isVerbose()) ;
            graph.getEventManager().register(monitor) ;
        }

        // Crude but convenient
        if ( filename.indexOf(':') == -1 )
            filename = "file:"+filename ;

        String lang = FileUtils.guessLang(filename) ;
       
        // Always time, only print if enabled.
        getModTime().startTimer() ;
       
        // Load here
        model.read(filename, lang) ;

        long timeMilli = getModTime().endTimer() ;
           
        if ( monitor != null )
        {
            System.out.println("Added "+monitor.addCount+" triples") ;
       
            if ( getModTime().timingEnabled() && !isQuiet() )
                System.out.printf("Loaded in %.3f seconds [%d triples/s]\n",
                                  timeMilli/1000.0, (1000*monitor.addCount/timeMilli)) ;
            graph.getEventManager().unregister(monitor) ;
        }
    }
View Full Code Here

     *
     * @return The distinguished updateable graph, or null if there are no graphs
     *         in this composition
     */
    public Graph getRequiredBaseGraph() {
        Graph base = getBaseGraph();
        if (base == null) {
            throw new JenaException( "This polyadic graph should have a base graph, but none is defined" );
        }
        else {
            return base;
View Full Code Here

         <code>s</code> rooted at <code>r</code>, bounded by this instances
         <code>boundary</code>.
    */
    public Model extractInto( Model model, Resource r, Model s )
        { TripleBoundary tb = boundary.asTripleBoundary( s );
        Graph g = getGraphExtract( tb ) .extractInto( model.getGraph(), r.asNode(), s.getGraph() );
        return ModelFactory.createModelForGraph( g ); }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.graph.Graph

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.