Package org.ontoware.rdf2go.model.node

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


    String foafURI = "http://xmlns.com/foaf/0.1/";
    URI max = model.createURI("http://xam.de/foaf.rdf.xml#i");
    URI name = model.createURI(foafURI+"#term_name");
    URI icqId = model.createURI(foafURI+"#term_icqChatID");
    URI typeInteger = XSD._integer;
    BlankNode konrad = model.createBlankNode();
    PlainLiteral maxNameAsPlainLiteral = model.createPlainLiteral("Max Völkel");
    DatatypeLiteral number = model.createDatatypeLiteral("123", typeInteger);
    LanguageTagLiteral konradNameEnglish = model.createLanguageTagLiteral("Konrad Voelkel", "en");
    LanguageTagLiteral konradNameGerman = model.createLanguageTagLiteral("Konrad Völkel", "de");
View Full Code Here


    URI foafPerson = model.createURI("http://xmlns.com/foaf/0.1/Person");
    URI foafTitle = model.createURI("http://xmlns.com/foaf/0.1/title");
    URI foafKnows = model.createURI("http://xmlns.com/foaf/0.1/knows");
    URI foafHomepage = model.createURI("http://xmlns.com/foaf/0.1/homepage");
    // use a blank node for the person
    BlankNode werner = model.createBlankNode();
   
    /*
     * now we can add statements to the model (for easier reading we
     * replaced the blank nodes cryptical letters with a human readable
     * version - you will see something different when exectuing this
     * example
     */
    // _:blankNodeWerner
    // <http://xmlns.com/foaf/0.1/homepage>
    // <http://www.blue-agents.com> .
    model.addStatement(werner, foafHomepage, model.createURI("http://www.blue-agents.com"));
    // _:blankNodeWerner
    // <http://xmlns.com/foaf/0.1/title>
    // "Mr" .
    model.addStatement(werner, foafTitle, "Mr");
    // _:blankNodeWerner
    // <http://xmlns.com/foaf/0.1/name>
    // "Werner Thiemann" .
    model.addStatement(werner, foafName, "Werner Thiemann");
   
    // _:blankNodeWerner
    // <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
    // <http://xmlns.com/foaf/0.1/Person> .
    model.addStatement(werner, RDF.type, foafPerson);
   
    BlankNode max = model.createBlankNode();
    // _:blankNodeMax
    // <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
    // <http://xmlns.com/foaf/0.1/Person> .
    model.addStatement(max, RDF.type, foafPerson);
    // _:blankNodeMax
View Full Code Here

      try {
        URI uri = ((org.ontoware.rdf2go.model.node.Resource)object).asURI();
        return toOpenRDF(uri, factory);
      } catch(ClassCastException e) {
        // if a resource is not a URI it must be a blank node
        BlankNode blankNode = ((org.ontoware.rdf2go.model.node.Resource)object)
                .asBlankNode();
        return toOpenRDF(blankNode, factory);
      }
    } else {
      throw new IllegalArgumentException("Unexpected object type: "
View Full Code Here

  /* subclasses should overwrite this method for better performance */
  @Override
    public BlankNode createBlankNode() {
    // delegate to factory methods of the defaultModel
    Model defaultModel = this.getDefaultModel();
    BlankNode blankNode = defaultModel.createBlankNode();
    defaultModel.close();
    return blankNode;
  }
View Full Code Here

  /* subclasses should overwrite this method for better performance */
  @Override
    public BlankNode createBlankNode(String internalID) {
    // delegate to factory methods of the defaultModel
    Model defaultModel = this.getDefaultModel();
    BlankNode blankNode = defaultModel.createBlankNode(internalID);
    defaultModel.close();
    return blankNode;
  }
View Full Code Here

  }

  /* fast, no need to override */
  @Override
    public BlankNode addReificationOf(Statement statement) {
    BlankNode bnode = createBlankNode();
    return (BlankNode) addReificationOf(statement, bnode);
  }
View Full Code Here

        } catch(NoSuchMethodException nsme) {
          log.debug("Class " + targetType + " has no constructor for BlankNode");
          constructor = targetType.getConstructor(new java.lang.Class[] { Model.class,
                  Resource.class, boolean.class });
        }
        BlankNode bnode = (BlankNode)node;
        return constructor.newInstance(new Object[] { model, bnode, false });
      } catch(ClassCastException cce) {
        throw new RuntimeException(cce);
      } catch(NoSuchMethodException nsme) {
        throw new RuntimeException("found no constructor " + targetType
View Full Code Here

   * Class under test for void addStatement(URI, URI, Object) and
   * removeStatement(URI, URI, Object)
   */
  @Test
  public void testAddRemoveStatementBlankNode() throws Exception {
    BlankNode blankNode = this.model.createBlankNode();
   
    this.model.addStatement(subject, predicate, blankNode);
    ClosableIterator<? extends Statement> sit = this.model.findStatements(subject, predicate,
            blankNode);
    assertTrue(sit.hasNext());
View Full Code Here

   * Class under test for void addStatement(Object, URI, URI) and
   * removeStatement(Object, URI, URI)
   */
  @Test
  public void testAddRemoveStatementBlankNode2() throws Exception {
    BlankNode blankNode = this.model.createBlankNode();
   
    this.model.addStatement(blankNode, predicate, object);
    ClosableIterator<? extends Statement> sit = this.model.findStatements(blankNode, predicate,
            object);
    assertTrue(sit.hasNext());
    while(sit.hasNext()) {
      // should be just one
      Statement s = sit.next();
      assertNotNull(s);
      assertTrue(s.getSubject() instanceof BlankNode);
      BlankNode back = (BlankNode)s.getSubject();
     
      assertTrue(blankNode.equals(back));
      assertEquals(blankNode, s.getSubject());
      assertEquals(predicate, s.getPredicate());
      assertEquals(object, s.getObject());
View Full Code Here

   * Class under test for void addStatement(Object, URI, String) and
   * removeStatement(Object, URI, String)
   */
  @Test
  public void testAddRemoveStatementObjectURIString() throws Exception {
    BlankNode blankNode = this.model.createBlankNode();
   
    this.model.addStatement(blankNode, predicate, "Test");
    ClosableIterator<? extends Statement> sit = this.model
            .findStatements(new TriplePatternImpl(blankNode, predicate, "Test"));
    assertTrue(sit.hasNext());
View Full Code Here

TOP

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

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.