Package org.ontoware.rdf2go.model.node

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


    init();

    // creating URIs
    // persons
    URI max = model.createURI("http://xam.de/foaf.rdf.xml#i");
    URI konrad = model.createURI("http://example.com/persons#konrad");
    URI guido = model.createURI("http://example.com/persons#guido");
    URI james = model.createURI("http://example.com/persons#james");
    // relations
    URI hasName = model.createURI("http://xmlns.com/foaf/0.1/#term_name");
    URI hasAge = model.createURI("http://example.com/relations#age");
    hasTag = model.createURI("http://example.com/relations#hasTag");
    // tags
    PlainLiteral tagJava = model.createPlainLiteral("Java");
    PlainLiteral tagPython = model.createPlainLiteral("Python");
    PlainLiteral tagComputers = model.createPlainLiteral("Computers");
View Full Code Here


    init();

    // creating URIs
    // persons
    URI max = model.createURI("http://xam.de/foaf.rdf.xml#i");
    URI konrad = model.createURI("http://example.com/persons#konrad");
    URI guido = model.createURI("http://example.com/persons#guido");
    URI james = model.createURI("http://example.com/persons#james");
    // relations
    URI hasName = model.createURI("http://xmlns.com/foaf/0.1/#term_name");
    URI hasAge = model.createURI("http://example.com/relations#age");
    hasTag = model.createURI("http://example.com/relations#hasTag");
    // tags
    PlainLiteral tagJava = model.createPlainLiteral("Java");
    PlainLiteral tagPython = model.createPlainLiteral("Python");
   
View Full Code Here

  public static void main(String[] args) throws ModelRuntimeException, IOException {

    init();

    // creating URIs
    URI max = model.createURI("http://xam.de/foaf.rdf.xml#i");
    URI currentProject = model.createURI(FOAFNS+"#term_currentProject");
    URI name = model.createURI(FOAFNS+"#term_name");
    URI semweb4j = model.createURI("http://semweb4j.org");

    // adding statements
    model.addStatement(max, currentProject, semweb4j);
    model.addStatement(max, name, "Max Völkel");
   
View Full Code Here

  public static void main(String[] args) throws ModelRuntimeException, IOException {

    init();

    // creating URIs
    URI max = model.createURI("http://xam.de/foaf.rdf.xml#i");
    URI currentProject = model.createURI(FOAFNS+"#term_currentProject");
    URI name = model.createURI(FOAFNS+"#term_name");
    URI semweb4j = model.createURI("http://semweb4j.org");

    // adding statements
    model.addStatement(max, currentProject, semweb4j);
    model.addStatement(max, name, "Max Völkel");
   
View Full Code Here

  }

  private URI singleResourceByName(String name, URI Class)
      throws ModelRuntimeException {
    HashSet<URI> resources = resourcesByName(name, Class);
    URI resource;
    // if no resource with this name exists, create a new one
    if (resources.isEmpty()) {
      resource = model.newRandomUniqueURI();
      nameURI(resource, name);
      classifyURI(resource, Class);
View Full Code Here

  public static void main(String[] args) throws ModelRuntimeException {
    // get an instance of our class
    Step8 inst = new Step8();

    // get URIs to play with
    URI max = inst.singlePersonByName("Max Völkel");
    URI konrad = inst.singlePersonByName("Konrad Völkel");
    URI james = inst.singlePersonByName("James Gosling");
    URI guido = inst.singlePersonByName("Guido van Rossum");

    // test naming
    inst.nameURI(max, "Max Völkl");
    inst.nameURI(max, "Max Voelkel");
    assert max.equals(inst.singlePersonByName("Max Völkl"));
View Full Code Here

    init();

    // creating URIs
    // persons
    URI max = model.createURI("http://xam.de/foaf.rdf.xml#i");
    URI konrad = model.createURI("http://example.com/persons#konrad");
    URI guido = model.createURI("http://example.com/persons#guido");
    URI james = model.createURI("http://example.com/persons#james");
    // relations
    URI hasName = model.createURI("http://xmlns.com/foaf/0.1/#term_name");
    URI hasAge = model.createURI("http://example.com/relations#age");
    hasTag = model.createURI("http://example.com/relations#hasTag");
    // tags
    PlainLiteral tagJava = model.createPlainLiteral("Java");
    PlainLiteral tagPython = model.createPlainLiteral("Python");
   
View Full Code Here

            // TODO create names for anonymous resource
            // throw new RuntimeException(
            // "Cannot create names for anonymous resources (yet)");
        }
       
        URI uri = (URI)uriOrBlankNode;
       
        String rawname;
        if(uri != null) {
            if(getLocalPart(uri.toString()) != null) {
                rawname = getLocalPart(uri.toString());
            } else {
                rawname = uri.toString();
            }
        } else {
            // generate name! only needed for blank nodes
            rawname = "genBean" + System.currentTimeMillis();
        }
       
        // remove preceeding 'has'
        if(rawname.toLowerCase().startsWith("has") && rawname.length() > 3) {
            rawname = rawname.substring(3);
        }
       
        // make rawname bean-style
        String beanname = toLegalJavaIdentifier(rawname);
       
        // now we have a nice bean name - but is it unique?
        if(usedNames.contains(beanname)) {
           
            // TODO check when this happens and deal better with it
            if(uri == null) {
                throw new IllegalStateException("");
            }
           
            // try to use namespace prefix for disambiguation
            String namespacePrefix = guessNSPrefix(uri.toString());
            String prefixedBeanName = toLegalJavaIdentifier(namespacePrefix + beanname);
            if(usedNames.contains(prefixedBeanName)) {
                // fallback to plain uri
                beanname = toLegalJavaIdentifier(uri.toString());
            } else {
                beanname = prefixedBeanName;
            }
        }
       
View Full Code Here

        subject, predicate, object);
    assertNotNull(sit);
    assertTrue(sit.hasNext());

    Statement s2 = sit.next();
    URI s2s = (URI) s2.getSubject();
    URI s2p = s2.getPredicate();
    URI s2o = (URI) s2.getObject();

    assertEquals(subject, s2s);
    assertEquals(predicate, s2p);
    assertEquals(object, s2o);
View Full Code Here

  public void testRemoveAll() throws Exception {
    Repository repo = new SailRepository(new MemoryStore());
    repo.initialize();
    RepositoryModelSet modelSet = new RepositoryModelSet(repo);
    modelSet.open();
    URI context1 = new URIImpl("uri:context1");
    URI context2 = new URIImpl("uri:context2");
    modelSet.addStatement(context1, new URIImpl("uri:r1"), new URIImpl(
        "uri:p1"), new URIImpl("uri:r2"));
    modelSet.addStatement(context1, new URIImpl("uri:r1"), new URIImpl(
        "uri:p1"), new URIImpl("uri:r3"));
    modelSet.addStatement(context2, new URIImpl("uri:r4"), new URIImpl(
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.