Package org.openrdf.result

Examples of org.openrdf.result.NamespaceResult


    if (namespaces == null || !namespaces.isFresh(now)) {
      NamespaceClient client = this.client.namespaces();
      if (namespaces != null) {
        client.ifNoneMatch(namespaces.getETag());
      }
      NamespaceResult result = client.list();
      if (result == null) {
        assert namespaces != null;
        namespaces.refreshed(now, client.getMaxAge());
      }
      else {
        namespaces = new CachedNamespaceResult(result.asMap(), client.getETag());
      }
    }
    return namespaces.getNamespaces();
  }
View Full Code Here


    throws StoreException, RDFHandlerException
  {
    try {
      handler.startRDF();
      // Export namespace information
      NamespaceResult nsIter = getNamespaces();
      try {
        while (nsIter.hasNext()) {
          Namespace ns = nsIter.next();
          handler.handleNamespace(ns.getPrefix(), ns.getName());
        }
      }
      finally {
        nsIter.close();
      }
      // Export statemnts
      while (stIter.hasNext()) {
        handler.handleStatement(stIter.next());
      }
View Full Code Here

    RepositoryConnection con;
    try {
      con = repository.getConnection();

      try {
        NamespaceResult namespaces = con.getNamespaces();

        try {
          if (namespaces.hasNext()) {
            writeln("+----------");
            while (namespaces.hasNext()) {
              Namespace ns = namespaces.next();
              writeln("|" + ns.getPrefix() + "  " + ns.getName());
            }
            writeln("+----------");
          }
          else {
            writeln("--no namespaces found--");
          }
        }
        finally {
          namespaces.close();
        }
      }
      finally {
        con.close();
      }
View Full Code Here

  {
    Map<String, Namespace> namespaces = new HashMap<String, Namespace>();
    Set<String> prefixes = new HashSet<String>();

    for (RepositoryConnection member : members) {
      NamespaceResult ns = member.getNamespaces();
      try {
        while (ns.hasNext()) {
          Namespace next = ns.next();
          String prefix = next.getPrefix();

          if (prefixes.add(prefix)) {
            namespaces.put(prefix, next);
          }
          else if (!next.equals(namespaces.get(prefix))) {
            namespaces.remove(prefix);
          }
        }
      }
      finally {
        ns.close();
      }
    }

    return new CollectionCursor<Namespace>(namespaces.values());
  }
View Full Code Here

  @Override
  public void clearNamespaces()
    throws StoreException
  {
    if (activated && reportDeltas()) {
      NamespaceResult namespaces;
      namespaces = getDelegate().getNamespaces();
      List<String> prefix = new ArrayList<String>();
      try {
        while (namespaces.hasNext()) {
          Namespace ns = namespaces.next();
          prefix.add(ns.getPrefix());
        }
      }
      finally {
        namespaces.close();
      }
      getDelegate().clearNamespaces();
      for (String p : prefix) {
        removeNamespace(p);
      }
View Full Code Here

    throws StoreException, RDFHandlerException
  {
    handler.startRDF();

    // Export namespace information
    NamespaceResult nsIter = getNamespaces();
    try {
      while (nsIter.hasNext()) {
        Namespace ns = nsIter.next();
        handler.handleNamespace(ns.getPrefix(), ns.getName());
      }
    }
    finally {
      nsIter.close();
    }

    // Export statements
    ModelResult stIter = match(subj, pred, obj, includeInferred, contexts);
View Full Code Here

    rdfFragment.append("  </rdf:Description>\n");
    rdfFragment.append("</rdf:RDF>");

    testCon.add(new StringReader(rdfFragment.toString()), "", RDFFormat.RDFXML);

    NamespaceResult nsIter = testCon.getNamespaces();
    try {
      Map<String, String> map = new HashMap<String, String>();
      int nsCount = 0;
      while (nsIter.hasNext()) {
        nsCount++;
        Namespace ns = nsIter.next();
        map.put(ns.getPrefix(), ns.getName());
      }

      assertEquals("There should be exactly three namespaces", 3, nsCount);
      assertTrue("namespace for prefix 'example' should exist", map.containsKey("example"));
      assertTrue("namespace for prefix 'rdfs' should exist", map.containsKey("rdfs"));
      assertTrue("namespace for prefix 'rdf' should exist", map.containsKey("rdf"));

      assertEquals("namespace name for 'example' not well-defined", "http://example.org/",
          map.get("example"));
      assertEquals("namespace name for 'rdfs' not well-defined", "http://www.w3.org/2000/01/rdf-schema#",
          map.get("rdfs"));
      assertEquals("namespace name for 'rdf' not well-defined",
          "http://www.w3.org/1999/02/22-rdf-syntax-ns#", map.get("rdf"));
    }
    finally {
      nsIter.close();
    }
  }
View Full Code Here

  {
    try {
      List<String> columnNames = Arrays.asList("prefix", "namespace");
      List<BindingSet> namespaces = new ArrayList<BindingSet>();

      NamespaceResult iter = getConnection().getNamespaces();

      try {
        while (iter.hasNext()) {
          Namespace ns = iter.next();

          Literal prefix = new LiteralImpl(ns.getPrefix());
          Literal namespace = new LiteralImpl(ns.getName());

          BindingSet bindingSet = new ListBindingSet(columnNames, prefix, namespace);
          namespaces.add(bindingSet);
        }
      }
      finally {
        iter.close();
      }

      return new TupleResultImpl(columnNames, namespaces);
    }
    catch (StoreException e) {
View Full Code Here

    throws StoreException, RDFHandlerException
  {
    handler.startRDF();

    // Export namespace information
    NamespaceResult nsIt = getNamespaces();
    try {
      while (nsIt.hasNext()) {
        Namespace ns = nsIt.next();
        handler.handleNamespace(ns.getPrefix(), ns.getName());
      }
    }
    finally {
      nsIt.close();
    }

    // Export statements
    ModelResult stIt = match(subj, pred, obj, includeInferred, contexts);
    try {
View Full Code Here

TOP

Related Classes of org.openrdf.result.NamespaceResult

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.