Package org.openrdf.model

Examples of org.openrdf.model.Namespace


    Map<String,String> nsMap = new HashMap<String,String>();
    try {
      RepositoryResult<Namespace> openrdfMap = this.connection.getNamespaces();
      openrdfMap.enableDuplicateFilter();
      while (openrdfMap.hasNext()) {
        Namespace openrdfNamespace = openrdfMap.next();
        nsMap.put(openrdfNamespace.getPrefix(), openrdfNamespace.getName());
      }
      return nsMap;
    } catch(RepositoryException e) {
      throw new ModelRuntimeException(e);
    }
View Full Code Here


  public Map<Value, ComplexProvenance> metaEvaluateQuery(String queryString) throws RepositoryException{
    SesameSparqlEvaluator eval = new SesameSparqlEvaluator(dataRepository);
   
    if (this.nsr == null) {
      RepositoryResult<Namespace> nsi = dataRepository.getConnection().getNamespaces();
      Namespace ns;
      this.nsr = new SPARQLNSResolver();
      while (nsi.hasNext()){
        ns = nsi.next();
        this.nsr.addPrefixBinding(ns.getPrefix(), ns.getName());
      }
    }
   
    Hashtable prologPrefixTable = new Hashtable();   
    if (queryString.contains(_PREFIX)){
View Full Code Here

    public Map<String, String> getNamespaces() {
        Map<String, String> namespaces = new HashMap<String, String>();
        try {
            final CloseableIteration<? extends Namespace, SailException> results = this.sailConnection.get().getNamespaces();
            while (results.hasNext()) {
                Namespace namespace = results.next();
                namespaces.put(namespace.getPrefix(), namespace.getName());
            }
            results.close();
        } catch (SailException e) {
            throw new RuntimeException(e.getMessage(), e);
        }
View Full Code Here

     */
    public String prefixNamespace(String uri) {
        try {
            CloseableIteration<? extends Namespace, SailException> namespaces = this.sailConnection.get().getNamespaces();
            while (namespaces.hasNext()) {
                Namespace namespace = namespaces.next();
                if (uri.contains(namespace.getName()))
                    uri = uri.replace(namespace.getName(), namespace.getPrefix() + SailTokens.NAMESPACE_SEPARATOR);
            }
            namespaces.close();
        } catch (SailException e) {
            throw new RuntimeException(e.getMessage(), e);
        }
View Full Code Here

        }
    }

    private static void addNamespace(final String prefix,
                                     final String uri) {
        Namespace n = new NamespaceImpl(prefix, uri);
        namespaces.put(prefix, n);
    }
View Full Code Here

    protected CloseableIteration<? extends Namespace, SailException> getNamespacesInternal() throws SailException {
        return new SimpleCloseableIteration<Namespace, SailException>(namespaces.values().iterator());
    }

    protected String getNamespaceInternal(final String prefix) throws SailException {
        Namespace n = namespaces.get(prefix);
        return null == n ? null : n.getName();
    }
View Full Code Here

    private void showNamespaces(final SailConnection c) throws SailException {
        System.out.println("namespaces:");
        CloseableIteration<? extends Namespace, SailException> iter = c.getNamespaces();
        try {
            while (iter.hasNext()) {
                Namespace n = iter.next();
                System.out.println("\t" + n.getPrefix() + ":\t" + n.getName());
            }
        } finally {
            iter.close();
        }
    }
View Full Code Here

            CloseableIteration<? extends Namespace, SailException> namespaces;
            int before = 0, during = 0, after = 0;
            // just iterate through all namespaces
            namespaces = sc.getNamespaces();
            while (namespaces.hasNext()) {
                Namespace ns = namespaces.next();
                before++;
                // System.out.println("namespace: " + ns);
            }
            namespaces.close();
            // Note: assumes that these namespace prefixes are unused.
            int nTests = 10;
            String prefixPrefix = "testns";
            String namePrefix = "http://example.org/test";
            for (int i = 0; i < nTests; i++) {
                sc.setNamespace(prefixPrefix + i, namePrefix + i);
            }
            sc.commit();
            sc.begin();
            namespaces = sc.getNamespaces();
            while (namespaces.hasNext()) {
                Namespace ns = namespaces.next();
                during++;
                String prefix = ns.getPrefix();
                String name = ns.getName();
                if (prefix.startsWith(prefixPrefix)) {
                    assertEquals(name, namePrefix + prefix.substring(prefixPrefix.length()));
                }
            }
            namespaces.close();
View Full Code Here

    // Export namespace information
    CloseableIteration<? extends Namespace, RepositoryException> nsIter = getNamespaces();
    try {
      while (nsIter.hasNext()) {
        Namespace ns = nsIter.next();
        handler.handleNamespace(ns.getPrefix(), ns.getName());
      }
    }
    finally {
      nsIter.close();
    }
View Full Code Here

      handler.startRDF();
      // Export namespace information
      RepositoryResult<Namespace> nsIter = getNamespaces();
      try {
        while (nsIter.hasNext()) {
          Namespace ns = nsIter.next();
          handler.handleNamespace(ns.getPrefix(), ns.getName());
        }
      }
      finally {
        nsIter.close();
      }
View Full Code Here

TOP

Related Classes of org.openrdf.model.Namespace

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.