Package com.hp.hpl.jena.util

Examples of com.hp.hpl.jena.util.FileManager


import com.hp.hpl.jena.util.FileManager;

public class ExampleLARQ_01 {

  public static void main(String[] args) throws CorruptIndexException, IOException {
        FileManager fm = FileManager.get();
        fm.addLocatorClassLoader(ExampleTDB_01.class.getClassLoader());
        InputStream in = fm.open("data/data.nt");

        Location location = new Location ("tmp/TDB");
        // build the Lucene index when pointed to a non existing directory
        DatasetGraphTDB dsg = (DatasetGraphTDB)TDBFactory.createDatasetGraph(location);
View Full Code Here


import com.hp.hpl.jena.util.FileManager;

public class ExampleTDB_03 {

    public static void main(String[] args) {
        FileManager fm = FileManager.get();
        fm.addLocatorClassLoader(ExampleTDB_03.class.getClassLoader());
        InputStream in = fm.open("data/data.nt");

        Location location = new Location ("target/TDB");
        Dataset dataset = TDBFactory.createDataset(location);
        dataset.begin(ReadWrite.WRITE);
        try {
View Full Code Here

import com.hp.hpl.jena.util.FileManager;

public class ExampleTDB_01 {

    public static void main(String[] args) {
        FileManager fm = FileManager.get();
        fm.addLocatorClassLoader(ExampleTDB_01.class.getClassLoader());
        InputStream in = fm.open("data/data.nt");

        Location location = new Location ("target/TDB");

        // Load some initial data
        TDBLoader.load(TDBInternal.getBaseDatasetGraphTDB(TDBFactory.createDatasetGraph(location)), in, false);
View Full Code Here

public class ExampleJenaJUNG_01 {

  // From: https://github.com/shellac/JenaJung/blob/master/src/main/java/net/rootdev/jenajung/examples/ToImage.java
  public static void main(String[] args) {
        FileManager fm = FileManager.get();
        fm.addLocatorClassLoader(ExampleJenaJUNG_01.class.getClassLoader());
        Model model = fm.loadModel("data/data.nt");

        Graph<RDFNode, Statement> g = new JenaJungGraph(model);
        Layout<RDFNode, Statement> layout = new FRLayout<RDFNode, Statement>(g);

        int width = 1400;
View Full Code Here

import com.hp.hpl.jena.util.FileManager;

public class ExampleIO_03 {

    public static void main(String[] args) {
        FileManager fm = FileManager.get();
        fm.addLocatorClassLoader(ExampleAPI_01.class.getClassLoader());
        // load an RDF file using the FileManager
        Model model = fm.loadModel("data/data.ttl", null, "TURTLE");
        model.write(System.out, "TURTLE");
    }
View Full Code Here

import com.hp.hpl.jena.vocabulary.RDFS;

public class ExampleTDB_04 {

    public static void main(String[] args) {
        FileManager fm = FileManager.get();
        fm.addLocatorClassLoader(ExampleTDB_04.class.getClassLoader());
        InputStream in = fm.open("data/data.nt");

        DatasetGraphTDB dsg =  TDBInternal.getBaseDatasetGraphTDB(TDBFactory.createDatasetGraph());

        GraphListener listener = new MyListener();
        dsg.getDefaultGraph().getEventManager().register(listener);
        Iterator<Node> iter = dsg.listGraphNodes();
        while ( iter.hasNext() ) {
          Graph graph = dsg.getGraph(iter.next());
          graph.getEventManager().register(listener);
        }

        // this does not send events to the GraphListener
        TDBLoader.load(dsg, in, false);
       
        // this does not uses the Graph SPI
        dsg.add(new Quad(Quad.defaultGraphIRI, Node.createURI("x"), Node.createURI("y"), Node.createURI("z")));
       
        // this does
        Graph graph = dsg.getDefaultGraph();
        graph.add(new Triple(Node.createURI("x"), Node.createURI("y"), Node.createURI("z")));

        // this sends events to the GraphListener
        Model model = ModelFactory.createModelForGraph(dsg.getDefaultGraph()) ;
        model.add(ResourceFactory.createProperty("foo:x1"), RDFS.label, "X1");

        // this does it too
        in = fm.open("data/data.nt");
        model.read(in, "", "N-TRIPLES");

        dsg.close();
    }
View Full Code Here

public class ExampleJenaJUNG_02 {
 
  // from: https://github.com/shellac/JenaJung
  public static void main(String[] args) {
        FileManager fm = FileManager.get();
        fm.addLocatorClassLoader(ExampleJenaJUNG_02.class.getClassLoader());
        Model model = fm.loadModel("data/data.nt");

        Graph<RDFNode, Statement> g = new JenaJungGraph(model);

    Layout<RDFNode, Statement> layout = new FRLayout<RDFNode, Statement>(g);
    layout.setSize(new Dimension(600, 400));
View Full Code Here

import com.hp.hpl.jena.util.FileManager;

public class ExampleLARQ_02 {

  public static void main(String[] args) throws Exception {
        FileManager fm = FileManager.get();
        fm.addLocatorClassLoader(ExampleTDB_01.class.getClassLoader());
        InputStream in = fm.open("data/data.nt");
               
        Location location = new Location ("tmp/TDB");
        DatasetGraphTDB dsg = (DatasetGraphTDB)TDBFactory.createDatasetGraph(location);

        TDBLoader.load(dsg, in, false); // load data into TDB
View Full Code Here

        assertNotSame(m1, m2) ;
    }
   
    public void testCache2()
    {
        FileManager fileManager = FileManager.get() ;
        fileManager.addLocatorFile(testingDir) ;
        fileManager.setModelCaching(true) ;
        Model m1 = fileManager.loadModel(fileModel) ;
        Model m2 = fileManager.loadModel(fileModel) ;
        assertSame(m1, m2) ;
    }
View Full Code Here

        assertSame(m1, m2) ;
    }
   
    public void testCache3()
    {
        FileManager fileManager = FileManager.get() ;
        fileManager.addLocatorFile(testingDir) ;
        fileManager.setModelCaching(true) ;
        Model m1 = fileManager.loadModel(fileModel) ;
        Model m2 = fileManager.loadModel(fileModel) ;
        assertSame(m1, m2) ;
       
        fileManager.removeCacheModel(fileModel) ;
        Model m3 = fileManager.loadModel(fileModel) ;
        assertNotSame(m1, m3) ;
       
        fileManager.resetCache() ;
        Model m4 = fileManager.loadModel(fileModel) ;
        Model m5 = fileManager.loadModel(fileModel) ;

        assertSame(m4, m5) ;
        assertNotSame(m1, m4) ;
        assertNotSame(m3, m4) ;
    }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.util.FileManager

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.