org.eclipse.rdf4j.repository.RepositoryConnection.prepareGraphQuery()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(9.8k)|赞(0)|评价(0)|浏览(70)

本文整理了Java中org.eclipse.rdf4j.repository.RepositoryConnection.prepareGraphQuery方法的一些代码示例,展示了RepositoryConnection.prepareGraphQuery的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RepositoryConnection.prepareGraphQuery方法的具体详情如下:
包路径:org.eclipse.rdf4j.repository.RepositoryConnection
类名称:RepositoryConnection
方法名:prepareGraphQuery

RepositoryConnection.prepareGraphQuery介绍

[英]Prepares SPARQL queries that produce RDF graphs, that is, SPARQL CONSTRUCT or DESCRIBE queries. In case the query contains relative URIs that need to be resolved against an external base URI, one should use #prepareGraphQuery(QueryLanguage,String,String) instead.
[中]准备生成RDF图的SPARQL查询,即SPARQL构造或描述查询。如果查询包含需要根据外部基URI解析的相对URI,则应使用#prepareGraphQuery(QueryLanguage,String,String)。

代码示例

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client

/**
 * Prepares SPARQL queries that produce RDF graphs, that is, SPARQL CONSTRUCT or DESCRIBE queries. In case
 * the query contains relative URIs that need to be resolved against an external base URI, one should use
 * {@link #prepareGraphQuery(QueryLanguage, String, String)} instead.
 * 
 * @param query
 *        The query string, in SPARQL syntax.
 * @return a {@link GraphQuery} ready to be evaluated on this {@link RepositoryConnection}.
 * @throws IllegalArgumentException
 *         If the supplied query is not a graph query.
 * @throws MalformedQueryException
 *         If the supplied query is malformed.
 * @see #prepareGraphQuery(QueryLanguage, String)
 */
public default GraphQuery prepareGraphQuery(String query)
  throws RepositoryException, MalformedQueryException
{
  return prepareGraphQuery(QueryLanguage.SPARQL, query);
}

代码示例来源:origin: eclipse/rdf4j

/**
 * Prepares SPARQL queries that produce RDF graphs, that is, SPARQL CONSTRUCT or DESCRIBE queries. In case
 * the query contains relative URIs that need to be resolved against an external base URI, one should use
 * {@link #prepareGraphQuery(QueryLanguage, String, String)} instead.
 * 
 * @param query
 *        The query string, in SPARQL syntax.
 * @return a {@link GraphQuery} ready to be evaluated on this {@link RepositoryConnection}.
 * @throws IllegalArgumentException
 *         If the supplied query is not a graph query.
 * @throws MalformedQueryException
 *         If the supplied query is malformed.
 * @see #prepareGraphQuery(QueryLanguage, String)
 */
public default GraphQuery prepareGraphQuery(String query)
  throws RepositoryException, MalformedQueryException
{
  return prepareGraphQuery(QueryLanguage.SPARQL, query);
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client

@Override
public GraphQuery prepareGraphQuery(QueryLanguage ql, String query, String baseURI)
  throws MalformedQueryException, RepositoryException
{
  return getDelegate().prepareGraphQuery(ql, query, baseURI);
}

代码示例来源:origin: eclipse/rdf4j

@Override
public GraphQuery prepareGraphQuery(QueryLanguage ql, String query, String baseURI)
  throws MalformedQueryException, RepositoryException
{
  return getDelegate().prepareGraphQuery(ql, query, baseURI);
}

代码示例来源:origin: eclipse/rdf4j

GraphQuery preparedQuery = conn.prepareGraphQuery(QueryLanguage.SPARQL, query);
try (GraphQueryResult queryResult = preparedQuery.evaluate();) {
  return processFunction.apply(queryResult);

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client

GraphQuery preparedQuery = conn.prepareGraphQuery(QueryLanguage.SPARQL, query);
try (GraphQueryResult queryResult = preparedQuery.evaluate();) {
  return processFunction.apply(queryResult);

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client

GraphQuery preparedQuery = conn.prepareGraphQuery(QueryLanguage.SPARQL, query);
try (GraphQueryResult queryResult = preparedQuery.evaluate();) {
  return processFunction.apply(queryResult);

代码示例来源:origin: eclipse/rdf4j

GraphQuery preparedQuery = conn.prepareGraphQuery(QueryLanguage.SPARQL, query);
try (GraphQueryResult queryResult = preparedQuery.evaluate();) {
  return processFunction.apply(queryResult);

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client

/**
 * Performs a SPARQL Construct or Describe query on the given Repository without opening a transaction and
 * passes the results to the given {@link RDFHandler}.
 * 
 * @param repository
 *        The {@link Repository} to open a connection to.
 * @param query
 *        The SPARQL Construct or Describe query to execute.
 * @param handler
 *        An {@link RDFHandler} that consumes the results.
 * @throws RepositoryException
 *         If there was an exception dealing with the Repository.
 * @throws UnknownTransactionStateException
 *         If the transaction state was not properly recognised. (Optional specific exception)
 * @throws MalformedQueryException
 *         If the supplied query is malformed
 * @throws QueryEvaluationException
 *         If there was an error evaluating the query
 */
public static void graphQueryNoTransaction(Repository repository, String query, RDFHandler handler)
  throws RepositoryException, UnknownTransactionStateException, MalformedQueryException,
  QueryEvaluationException
{
  consumeNoTransaction(repository, conn -> {
    GraphQuery preparedQuery = conn.prepareGraphQuery(QueryLanguage.SPARQL, query);
    preparedQuery.evaluate(handler);
  });
}

代码示例来源:origin: eclipse/rdf4j

/**
 * Performs a SPARQL Construct or Describe query on the given Repository without opening a transaction and
 * passes the results to the given {@link RDFHandler}.
 * 
 * @param repository
 *        The {@link Repository} to open a connection to.
 * @param query
 *        The SPARQL Construct or Describe query to execute.
 * @param handler
 *        An {@link RDFHandler} that consumes the results.
 * @throws RepositoryException
 *         If there was an exception dealing with the Repository.
 * @throws UnknownTransactionStateException
 *         If the transaction state was not properly recognised. (Optional specific exception)
 * @throws MalformedQueryException
 *         If the supplied query is malformed
 * @throws QueryEvaluationException
 *         If there was an error evaluating the query
 */
public static void graphQueryNoTransaction(Repository repository, String query, RDFHandler handler)
  throws RepositoryException, UnknownTransactionStateException, MalformedQueryException,
  QueryEvaluationException
{
  consumeNoTransaction(repository, conn -> {
    GraphQuery preparedQuery = conn.prepareGraphQuery(QueryLanguage.SPARQL, query);
    preparedQuery.evaluate(handler);
  });
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client

/**
 * Performs a SPARQL Construct or Describe query on the given Repository within a transaction and passes
 * the results to the given {@link RDFHandler}.
 * 
 * @param repository
 *        The {@link Repository} to open a connection to.
 * @param query
 *        The SPARQL Construct or Describe query to execute.
 * @param handler
 *        An {@link RDFHandler} that consumes the results.
 * @throws RepositoryException
 *         If there was an exception dealing with the Repository.
 * @throws UnknownTransactionStateException
 *         If the transaction state was not properly recognised. (Optional specific exception)
 * @throws MalformedQueryException
 *         If the supplied query is malformed
 * @throws QueryEvaluationException
 *         If there was an error evaluating the query
 */
public static void graphQuery(Repository repository, String query, RDFHandler handler)
  throws RepositoryException, UnknownTransactionStateException, MalformedQueryException,
  QueryEvaluationException
{
  consume(repository, conn -> {
    GraphQuery preparedQuery = conn.prepareGraphQuery(QueryLanguage.SPARQL, query);
    preparedQuery.evaluate(handler);
  });
}

代码示例来源:origin: eclipse/rdf4j

/**
 * Performs a SPARQL Construct or Describe query on the given Repository within a transaction and passes
 * the results to the given {@link RDFHandler}.
 * 
 * @param repository
 *        The {@link Repository} to open a connection to.
 * @param query
 *        The SPARQL Construct or Describe query to execute.
 * @param handler
 *        An {@link RDFHandler} that consumes the results.
 * @throws RepositoryException
 *         If there was an exception dealing with the Repository.
 * @throws UnknownTransactionStateException
 *         If the transaction state was not properly recognised. (Optional specific exception)
 * @throws MalformedQueryException
 *         If the supplied query is malformed
 * @throws QueryEvaluationException
 *         If there was an error evaluating the query
 */
public static void graphQuery(Repository repository, String query, RDFHandler handler)
  throws RepositoryException, UnknownTransactionStateException, MalformedQueryException,
  QueryEvaluationException
{
  consume(repository, conn -> {
    GraphQuery preparedQuery = conn.prepareGraphQuery(QueryLanguage.SPARQL, query);
    preparedQuery.evaluate(handler);
  });
}

代码示例来源:origin: joshsh/sesametools

private static void translateRDFDocumentUseingConstructQuery(final String query,
                                 final File inputFile,
                                 final OutputStream out,
                                 final RDFFormat inFormat,
                                 final RDFFormat outFormat,
                                 final String baseURI)
      throws SailException, IOException, RDFHandlerException, RDFParseException, RepositoryException,
      MalformedQueryException, QueryEvaluationException {

    Sail sail = new MemoryStore();
    sail.initialize();

    try {
      Repository repo = new SailRepository(sail);
      try (RepositoryConnection rc = repo.getConnection()) {
        rc.add(inputFile, baseURI, inFormat);
        rc.commit();

        RDFWriter w = Rio.createWriter(outFormat, out);

        rc.prepareGraphQuery(QueryLanguage.SPARQL, query).evaluate(w);
      }
    } finally {
      sail.shutDown();
    }
  }
}

代码示例来源:origin: franzinc/agraph-java-client

GraphQueryResult result = conn.prepareGraphQuery(QueryLanguage.SPARQL, query).evaluate();
int i = 0;
for (; result.hasNext(); i++) {
result = conn.prepareGraphQuery(QueryLanguage.SPARQL, query).evaluate();
i = 0;
for (; result.hasNext(); i++) {

代码示例来源:origin: franzinc/agraph-java-client

queryBuilder.append("         ?x foaf:mbox ?mbox .}");
GraphQueryResult result = testCon.prepareGraphQuery(
    QueryLanguage.SPARQL, queryBuilder.toString()).evaluate();

代码示例来源:origin: franzinc/agraph-java-client

queryBuilder.append(" USING NAMESPACE foaf = <" + FOAF_NS + ">");
GraphQueryResult result = testCon.prepareGraphQuery(QueryLanguage.SERQL, queryBuilder.toString()).evaluate();

代码示例来源:origin: franzinc/agraph-java-client

queryBuilder.append("         ?x foaf:mbox ?mbox .}");
GraphQueryResult result = testCon.prepareGraphQuery(
    QueryLanguage.SPARQL, queryBuilder.toString()).evaluate();

代码示例来源:origin: franzinc/agraph-java-client

queryBuilder.append("         ?x foaf:mbox ?mbox .}");
GraphQuery query = testCon.prepareGraphQuery(QueryLanguage.SPARQL,
    queryBuilder.toString());
query.setBinding("name", nameBob);

代码示例来源:origin: franzinc/agraph-java-client

queryBuilder.append("         ?x foaf:mbox ?mbox .}");
GraphQuery query = testCon.prepareGraphQuery(QueryLanguage.SPARQL,
    queryBuilder.toString());
query.setBinding("name", nameBob);

代码示例来源:origin: franzinc/agraph-java-client

queryBuilder.append(" USING NAMESPACE foaf = <" + FOAF_NS + ">");
GraphQuery query = testCon.prepareGraphQuery(QueryLanguage.SERQL, queryBuilder.toString());
query.setBinding("name", nameBob);

相关文章

微信公众号

最新文章

更多