org.apache.jena.query.Query.getSyntax()方法的使用及代码示例

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

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

Query.getSyntax介绍

暂无

代码示例

代码示例来源:origin: apache/jena

private Element process(BasicPattern pattern) {
  // The different SPARQL versions (1.0, 1.1) use different internal
  // structures for BGPs.
  if ( query.getSyntax() == Syntax.syntaxSPARQL_10 ) {
    ElementTriplesBlock e = new ElementTriplesBlock() ;
    for ( Triple t : pattern )
      // Leave bNode variables as they are
      // Query serialization will deal with them.
      e.addTriple(t) ;
    return e ;
  }
  if ( query.getSyntax() == Syntax.syntaxSPARQL_11 || query.getSyntax() == Syntax.syntaxARQ ) {
    ElementPathBlock e = new ElementPathBlock() ;
    for ( Triple t : pattern )
      // Leave bNode variables as they are
      // Query serialization will deal with them.
      e.addTriple(t) ;
    return e ;
  }
  throw new ARQInternalErrorException("Unrecognized syntax: " + query.getSyntax()) ;
}

代码示例来源:origin: apache/jena

/**
 * Makes a copy of this query.  Copies by parsing a query from the serialized form of this query
 * @return Copy of this query
 */
public Query cloneQuery() {
  // A little crude.
  // Must use toString() rather than serialize() because we may not know how to serialize extended syntaxes
  String qs = this.toString();
  return QueryFactory.create(qs, getSyntax()) ;
}

代码示例来源:origin: SmartDataAnalytics/jena-sparql-api

private Element process(BasicPattern pattern)
{
  // The different SPARQL versions use different internal structures for BGPs.
  if ( query.getSyntax() == Syntax.syntaxSPARQL_10 )
  {
    ElementTriplesBlock e = new ElementTriplesBlock() ;
    for (Triple t : pattern)
      // Leave bNode variables as they are
      // Query serialization will deal with them.
      e.addTriple(t) ;
    return e ;
  }
  if ( query.getSyntax() == Syntax.syntaxSPARQL_11 ||
     query.getSyntax() == Syntax.syntaxARQ )
  {
    ElementPathBlock e = new ElementPathBlock() ;
    for (Triple t : pattern)
      // Leave bNode variables as they are
      // Query serialization will deal with them.
      e.addTriple(t) ;
    return e ;
  }
  throw new ARQInternalErrorException("Unrecognized syntax: "+query.getSyntax()) ;
}

代码示例来源:origin: apache/jena

@Override
protected void runTestForReal()
{
  Query query = null ;
  if ( queryString == null )
    query = queryFromTestItem(testItem) ;
  else
    query = queryFromString(queryString) ;
  
  // Whatever was read in.
  runTestWorker(query, query.getSyntax()) ;
}

代码示例来源:origin: apache/jena

public static void checkParse(Query query)
  if ( ! SPARQLParserRegistry.get().containsFactory(query.getSyntax()) )
    return ;
  query.serialize(buff, query.getSyntax()) ;
    query2 = QueryFactory.create(tmp, baseURI, query.getSyntax()) ;

代码示例来源:origin: apache/jena

syntaxURI = query.getSyntax() ;
else
  query.setSyntax(syntaxURI) ;

代码示例来源:origin: apache/jena

private void testOpToSyntax(String opStr, String queryString)
  {
    Op op = SSE.parseOp(opStr) ;
    Query queryConverted = OpAsQuery.asQuery(op) ;
    
    Query queryExpected = QueryFactory.create(queryString, queryConverted.getSyntax()) ;
    
//        if ( ! queryExpected.equals(queryConverted) )
//        {
//            System.err.println("Query Expected: "+queryExpected.getSyntax()) ;
//            System.err.println(queryExpected) ;
//            
//            System.err.println("Query Converted: "+queryConverted.getSyntax()) ;
//            System.err.println(queryConverted) ;
//            System.err.println() ;
//        }
    
    assertEquals(queryExpected, queryConverted) ;
  }

代码示例来源:origin: apache/jena

private static void check(Query query, Collection<Var> vars)
{
  // Check any expressions are assigned to fresh variables.
  checkExprListAssignment(vars, query.getProject()) ;
  
  // Check for SELECT * GROUP BY
  // Legal in ARQ, not in SPARQL 1.1
  if ( ! Syntax.syntaxARQ.equals(query.getSyntax()) )
  {
    if ( query.isQueryResultStar() && query.hasGroupBy() )
      throw new QueryParseException("SELECT * not legal with GROUP BY", -1 , -1) ;
  }
  
  // Check any variable in an expression is in scope (if GROUP BY) 
  checkExprVarUse(query) ;
  
  // Check GROUP BY AS 
  // ENABLE
  if ( false && query.hasGroupBy() )
  {
    VarExprList exprList2 = query.getGroupBy() ;
    checkExprListAssignment(vars, exprList2) ;
  // CHECK 
  }
  
}

代码示例来源:origin: SmartDataAnalytics/jena-sparql-api

@Override
public void startVisit(Query query) {
  newQuery.setSyntax(query.getSyntax()) ;
  if ( query.explicitlySetBaseURI() )
    newQuery.setBaseURI(query.getPrologue().getResolver()) ;
  newQuery.setQueryResultStar(query.isQueryResultStar()) ;
  if ( query.hasDatasetDescription() ) {
    DatasetDescription desc = query.getDatasetDescription() ;
    for (String x : desc.getDefaultGraphURIs())
      newQuery.addGraphURI(x) ;
    for (String x : desc.getDefaultGraphURIs())
      newQuery.addNamedGraphURI(x) ;
  }
  // Aggregators.
  newQuery.getAggregators().addAll(query.getAggregators()) ;
}

代码示例来源:origin: apache/jena

@Override
public void startVisit(Query query) {
  newQuery.setSyntax(query.getSyntax());
  if (query.explicitlySetBaseURI())
    newQuery.setBaseURI(query.getPrologue().getResolver());
  newQuery.setQueryResultStar(query.isQueryResultStar());
  if (query.hasDatasetDescription()) {
    DatasetDescription desc = query.getDatasetDescription();
    for (String x : desc.getDefaultGraphURIs())
      newQuery.addGraphURI(x);
    for (String x : desc.getDefaultGraphURIs())
      newQuery.addNamedGraphURI(x);
  }
  // Aggregators.
  newQuery.getAggregators().addAll(query.getAggregators());
}

相关文章