本文整理了Java中org.apache.jena.query.Query.getQueryType
方法的一些代码示例,展示了Query.getQueryType
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.getQueryType
方法的具体详情如下:
包路径:org.apache.jena.query.Query
类名称:Query
方法名:getQueryType
暂无
代码示例来源:origin: SmartDataAnalytics/Sparqlify
public int getQueryType() {
int result;
if(isExplain) {
result = Query.QueryTypeSelect;
} else {
result = query.getQueryType();
}
return result;
}
代码示例来源:origin: apache/jena
@Override
public void visitResultForm(Query query1)
{ check("Query result form", query1.getQueryType() == query2.getQueryType()) ; }
代码示例来源:origin: ontodev/robot
/**
* Given a SPARQL query, return its default file format as a string.
*
* @param query the SPARQL query
* @return the format name
* @throws IllegalArgumentException on bad query
*/
public static String getDefaultFormatName(Query query) throws IllegalArgumentException {
String formatName;
switch (query.getQueryType()) {
case Query.QueryTypeAsk:
formatName = "txt";
break;
case Query.QueryTypeConstruct:
formatName = "ttl";
break;
case Query.QueryTypeDescribe:
formatName = "ttl";
break;
case Query.QueryTypeSelect:
formatName = "csv";
break;
default:
throw new IllegalArgumentException(String.format(queryTypeError, query.getQueryType()));
}
return formatName;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public QueryExecutionAndType createQueryExecutionAndType(Query query) {
QueryExecution qe = createQueryExecution(query);
QueryExecutionAndType result = new QueryExecutionAndType(qe, query.getQueryType());
return result;
}
代码示例来源:origin: ontodev/robot
/**
* Given a SPARQL query, return its type as a string: ASK, CONSTRUCT, DESCRIBE, or SELECT.
*
* @param queryString the SPARQL query string
* @return the query type string
* @throws IllegalArgumentException on bad query
*/
public static String getQueryTypeName(String queryString) {
QueryExecution qExec = QueryExecutionFactory.create(queryString, createEmptyDataset());
Query query = qExec.getQuery();
String queryType;
switch (query.getQueryType()) {
case Query.QueryTypeAsk:
queryType = "ASK";
break;
case Query.QueryTypeConstruct:
queryType = "CONSTRUCT";
break;
case Query.QueryTypeDescribe:
queryType = "DESCRIBE";
break;
case Query.QueryTypeSelect:
queryType = "SELECT";
break;
default:
throw new IllegalArgumentException(String.format(queryTypeError, query.getQueryType()));
}
return queryType;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
/**
* Override this for special stuff, such as adding the EXPLAIN keyword
*
* @param queryString
* @return
*/
public QueryExecutionAndType createQueryExecutionAndType(String queryString) {
//Query query = new Query();
//query.setPrefix("bif", "http://www.openlinksw.com/schemas/bif#");
//QueryFactory.parse(query, queryString, "http://example.org/base-uri/", Syntax.syntaxSPARQL_11);
// TODO We should not have to parse the query string here, as this is the parser's job
Query query = QueryFactory.create(queryString, Syntax.syntaxARQ);
QueryExecution qe = createQueryExecution(query);
QueryExecutionAndType result = new QueryExecutionAndType(qe, query.getQueryType());
return result;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public static void abortAfterFirstRow(QueryExecution qe) {
Query query = qe.getQuery();
assert query != null : "QueryExecution did not tell us which query it is bound to - query was null";
int queryType = query.getQueryType();
try {
switch (queryType) {
case Query.QueryTypeAsk:
qe.execAsk();
break;
case Query.QueryTypeConstruct:
Iterator<Triple> itC = qe.execConstructTriples();
itC.hasNext();
break;
case Query.QueryTypeDescribe:
Iterator<Triple> itD = qe.execDescribeTriples();
itD.hasNext();
break;
case Query.QueryTypeSelect:
ResultSet rs = qe.execSelect();
rs.hasNext();
break;
default:
throw new RuntimeException("Unknown query type - should not happen: queryType = " + queryType);
}
} finally {
qe.abort();
}
}
代码示例来源:origin: ontodev/robot
/**
* Given a query execution, a format name, and an output stream, run the query and write to
* output.
*
* @param qExec QueryExecution to run
* @param formatName format of output
* @param output output stream to write to
* @return true if there are results
*/
public static boolean runSparqlQuery(
QueryExecution qExec, String formatName, OutputStream output) {
Query query = qExec.getQuery();
if (formatName == null) {
formatName = getDefaultFormatName(query);
}
switch (query.getQueryType()) {
case Query.QueryTypeAsk:
writeResult(qExec.execAsk(), output);
return true;
case Query.QueryTypeConstruct:
return maybeWriteResult(qExec.execConstruct(), formatName, output);
case Query.QueryTypeDescribe:
return maybeWriteResult(qExec.execDescribe(), formatName, output);
case Query.QueryTypeSelect:
return maybeWriteResult(qExec.execSelect(), formatName, output);
default:
throw new IllegalArgumentException(String.format(queryTypeError, query.getQueryType()));
}
}
代码示例来源:origin: apache/jena
switch (query.getQueryType())
throw new IllegalStateException( "Internal query is not a known type: "+q.getQueryType());
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
Query query = qe.getQuery();
assert query != null : "QueryExecution did not tell us which query it is bound to - query was null";
int queryType = query.getQueryType();
代码示例来源:origin: org.apache.jena/jena-querybuilder
switch (query.getQueryType())
throw new IllegalStateException( "Internal query is not a known type: "+q.getQueryType());
内容来源于网络,如有侵权,请联系作者删除!