Package org.ontoware.rdf2go.model.node

Examples of org.ontoware.rdf2go.model.node.URI


      throw new RDFDataException(
          "Cannot convert a language tagged literal to an Double - it makes no sense");
    }

    if (node instanceof DatatypeLiteral) {
      URI datatype = node.asDatatypeLiteral().getDatatype();

      if (datatype.equals(XSD._double)) {
        return toDouble(node.asDatatypeLiteral());
      } else {
        throw new RDFDataException("Cannot convert from datatype "
            + datatype + " to URI");
      }
View Full Code Here


   
    JPackage jp = new JPackage("Package");
    JClass root = new JClass(jp,"Rootclass", new URIImpl("urn:java:class.Rootclass"));
    JModel jm = new JModel(root);
   
    URI testURI = new URIImpl("urn:test:classX");
    JClass testClass = new JClass(jp,"Testclass", testURI);
   
    jm.addMapping( testURI, testClass );
   
    Assert.assertNotNull(jm.getMapping(testURI));
View Full Code Here

  public abstract ModelFactory getModelFactory();
 
  @Override
  @Before
  public void setUp() {
    URI u = getModelFactory().createModel().newRandomUniqueURI();
    this.model = getModelFactory().createModel(u);
    this.model.open();
  }
View Full Code Here

    // a rdf:type classA
    // classA rdfs:subClassOf classB
    // -->
    // a rdf:type classB
   
    URI a = this.model.createURI("urn:test:a");
    URI classA = this.model.createURI("urn:test:classA");
    URI classB = this.model.createURI("urn:test:classB");
   
    this.model.addStatement(a, RDF.type, classA);
    this.model.addStatement(classA, RDFS.subClassOf, classB);
   
    boolean inferencedStatement = this.model.contains(Variable.ANY, RDF.type, classB);
View Full Code Here

    // replace model with RDFS based one
    this.model.close();
    this.model = getModelFactory().createModel(Reasoning.rdfs);
    this.model.open();
   
    URI resourceA = new URIImpl("urn:resource:A");
    URI resourceB = new URIImpl("urn:resource:B");
    URI propertyA = new URIImpl("urn:prop:A");
    URI propertyB = new URIImpl("urn:prop:B");
    URI propertyC = new URIImpl("urn:prop:C");
   
    this.model.addStatement(propertyA, propertyB, propertyC);
    this.model.addStatement(propertyB, RDFS.subPropertyOf, RDFS.subPropertyOf);
    Assert.assertTrue(this.model.contains(propertyA, RDFS.subPropertyOf, propertyC));
   
View Full Code Here

    Assert.assertTrue(this.model.contains(resourceA, propertyC, resourceB));
  }
 
  @Test
  public void testSimpleQuery1() throws Exception {
    URI a = new URIImpl("test://a");
    URI b = new URIImpl("test://b");
    URI c = new URIImpl("test://c");
    this.model.addStatement(a, b, c);
    ClosableIterator<? extends Statement> it = this.model.findStatements(a, b, c);
    assertTrue(it.hasNext());
    it.close();
  }
View Full Code Here

    it.close();
  }
 
  @Test
  public void testSimpleQuery() throws Exception {
    URI a = new URIImpl("test://a");
    URI b = new URIImpl("test://b");
    URI c = new URIImpl("test://c");
    this.model.addStatement(a, b, c);
    assertEquals(1, this.model.size());
   
    ClosableIterator<? extends Statement> it = this.model.findStatements(Variable.ANY, b, c);
    assertTrue(it.hasNext());
View Full Code Here

    Model modelRDFS = getModelFactory().createModel(Reasoning.rdfs);
    modelRDFS.open();
   
    modelRDFS.removeAll();
   
    URI hasContent = new URIImpl("prop://hasContent");
    URI hasTag = new URIImpl("prop://hasTag");
    URI tagSemweb = new URIImpl("tag://semweb");
    URI tagPaper = new URIImpl("tag://paper");
    URI fileA = new URIImpl("file://a");
    URI fileB = new URIImpl("file://b");
    URI assignment1 = new URIImpl("ass://1");
    URI assignment2 = new URIImpl("ass://2");
    URI assignment3 = new URIImpl("ass://1");
   
    // a = 'paper'
    modelRDFS.addStatement(assignment1, hasTag, tagPaper);
    modelRDFS.addStatement(assignment1, hasContent, fileA);
    // a = 'semweb'
View Full Code Here

 
  @Test
  public void testSparqlAsk() throws Exception {
    Model modelRDFS = getModelFactory().createModel(Reasoning.rdfs);
    modelRDFS.open();
    URI hasTag = new URIImpl("prop://hasTag");
    URI tagSemweb = new URIImpl("tag://semweb");
    URI fileA = new URIImpl("file://a");
    modelRDFS.addStatement(fileA, hasTag, tagSemweb);
    Assert.assertTrue(modelRDFS.sparqlAsk("ASK WHERE { " + fileA.toSPARQL() + " "
            + hasTag.toSPARQL() + " ?tag . }"));
    Assert.assertTrue(modelRDFS.sparqlAsk("ASK WHERE { " + fileA.toSPARQL() + " " + " ?prop "
            + tagSemweb.toSPARQL() + " . }"));
    Assert.assertFalse(modelRDFS.sparqlAsk("ASK WHERE { " + fileA.toSPARQL() + " "
            + "<prop://bogus>" + " ?tag . }"));
    Assert.assertTrue(modelRDFS.sparqlAsk("ASK WHERE { ?s ?p ?o . }"));
    modelRDFS.close();
  }
View Full Code Here

  @Test
  public void testSparqlSelectWithStrings() throws Exception {
    Model modelRDFS = getModelFactory().createModel(Reasoning.rdfs);
    modelRDFS.open();
   
    URI hasContent = new URIImpl("prop://hasContent");
    URI hasTag = new URIImpl("prop://hasTag");
    String tagSemweb = "semweb";
    String tagPaper = "paper";
    URI fileA = new URIImpl("file://a");
    URI fileB = new URIImpl("file://b");
    URI assignment1 = new URIImpl("ass://1");
    URI assignment2 = new URIImpl("ass://2");
    URI assignment3 = new URIImpl("ass://1");
   
    // a = 'paper'
    modelRDFS.addStatement(assignment1, hasTag, tagPaper);
    modelRDFS.addStatement(assignment1, hasContent, fileA);
    // a = 'semweb'
View Full Code Here

TOP

Related Classes of org.ontoware.rdf2go.model.node.URI

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.