org.eclipse.rdf4j.query.Query类的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(291)

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

Query介绍

[英]A query on a repository that can be formulated in one of the supported query languages (for example SeRQL or SPARQL). It allows one to predefine bindings in the query to be able to reuse the same query with different bindings.
[中]对存储库的查询,可以用受支持的查询语言之一(例如SeRQL或SPARQL)表示。它允许在查询中预定义绑定,以便能够使用不同的绑定重用同一查询。

代码示例

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

private void setBindings(Query query, Resource subj, IRI pred, Value obj, Resource... contexts)
  throws RepositoryException
{
  if (subj != null) {
    query.setBinding("s", subj);
  }
  if (pred != null) {
    query.setBinding("p", pred);
  }
  if (obj != null) {
    query.setBinding("o", obj);
  }
  if (contexts != null && contexts.length > 0) {
    SimpleDataset dataset = new SimpleDataset();
    for (Resource ctx : contexts) {
      if (ctx == null || ctx instanceof IRI) {
        dataset.addDefaultGraph((IRI)ctx);
      }
      else {
        throw new RepositoryException("Contexts must be URIs");
      }
    }
    query.setDataset(dataset);
  }
}

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

private <O extends Query> O initQuery(O query) {
  initOperation(query);
  query.setMaxQueryTime(getMaxQueryTime());
  return query;
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-http-server-spring

result = repositoryCon.prepareQuery(queryLn, queryStr, baseURI);
result.setIncludeInferred(includeInferred);
  result.setMaxQueryTime(maxQueryTime);
  result.setDataset(dataset);
    Value bindingValue = ProtocolUtil.parseValueParam(request, parameterName,
        repository.getValueFactory());
    result.setBinding(bindingName, bindingValue);

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-http-server-spring

result.setIncludeInferred(includeInferred);
  result.setMaxExecutionTime(maxQueryTime);
  result.setDataset(dataset);
    Value bindingValue = ProtocolUtil.parseValueParam(request, parameterName,
        SimpleValueFactory.getInstance());
    result.setBinding(bindingName, bindingValue);

代码示例来源:origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-spin

private static void addBindings(Query query, List<Argument> arguments, Value... args) {
    for (int i = 0; i < args.length; i++) {
      Argument argument = arguments.get(i);
      query.setBinding(argument.getPredicate().getLocalName(), args[i]);
    }
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-spin

private static void addBindings(Query query, List<Argument> arguments, Value... args) {
    for (int i = 0; i < args.length; i++) {
      Argument argument = arguments.get(i);
      query.setBinding(argument.getPredicate().getLocalName(), args[i]);
    }
  }
}

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

private void setBindings(Query query, Resource subj, IRI pred, Value obj, Resource... contexts)
  throws RepositoryException
{
  if (subj != null) {
    query.setBinding("s", subj);
  }
  if (pred != null) {
    query.setBinding("p", pred);
  }
  if (obj != null) {
    query.setBinding("o", obj);
  }
  if (contexts != null && contexts.length > 0) {
    SimpleDataset dataset = new SimpleDataset();
    for (Resource ctx : contexts) {
      if (ctx == null || ctx instanceof IRI) {
        dataset.addDefaultGraph((IRI)ctx);
      }
      else {
        throw new RepositoryException("Contexts must be URIs");
      }
    }
    query.setDataset(dataset);
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-spin

protected static void addArguments(Query query, Value... args)
    throws ValueExprEvaluationException
  {
    for (int i = 1; i < args.length; i += 2) {
      if (!(args[i] instanceof URI)) {
        throw new ValueExprEvaluationException("Argument " + i + " must be a URI");
      }
      query.setBinding(((URI)args[i]).getLocalName(), args[i + 1]);
    }
  }
}

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

private <O extends Query> O initQuery(O query) {
  initOperation(query);
  query.setMaxQueryTime(getMaxQueryTime());
  return query;
}

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

private void setBindings(Query query, Resource subj, IRI pred, Value obj, Resource... contexts)
  throws RepositoryException
{
  if (subj != null) {
    query.setBinding("s", subj);
  }
  if (pred != null) {
    query.setBinding("p", pred);
  }
  if (obj != null) {
    query.setBinding("o", obj);
  }
  if (contexts != null && contexts.length > 0) {
    SimpleDataset dataset = new SimpleDataset();
    for (Resource ctx : contexts) {
      if (ctx == null || ctx instanceof IRI) {
        dataset.addDefaultGraph((IRI)ctx);
      }
      else {
        throw new RepositoryException("Contexts must be URIs");
      }
    }
    query.setDataset(dataset);
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-spin

protected static void addBindings(Query query, Value... args)
    throws ValueExprEvaluationException
  {
    for (int i = 1; i < args.length; i += 2) {
      if (!(args[i] instanceof Literal)) {
        throw new ValueExprEvaluationException("Argument " + i + " must be a literal");
      }
      query.setBinding(((Literal)args[i]).getLabel(), args[i + 1]);
    }
  }
}

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

private <O extends Query> O initQuery(O query) {
  initOperation(query);
  query.setMaxQueryTime(getMaxQueryTime());
  return query;
}

相关文章