本文整理了Java中org.apache.jena.query.Query.setPrefixMapping
方法的一些代码示例,展示了Query.setPrefixMapping
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setPrefixMapping
方法的具体详情如下:
包路径:org.apache.jena.query.Query
类名称:Query
方法名:setPrefixMapping
暂无
代码示例来源:origin: apache/jena
/**
* Clear the prefix mapping.
*/
public void clearPrefixes() {
query.setPrefixMapping( new PrefixMappingImpl() );
}
代码示例来源:origin: org.apache.jena/jena-querybuilder
/**
* Clear the prefix mapping.
*/
public void clearPrefixes() {
query.setPrefixMapping( new PrefixMappingImpl() );
}
代码示例来源:origin: stackoverflow.com
public static String replacePrefixes(String query, PrefixMapping pmap){
/* With Prologue and the parse method,
* the queryString gets parsed without an error
*/
Prologue prog = new Prologue();
prog.setPrefixMapping(pmap);
Query q = QueryFactory.parse(new Query(prog), query, null, null);
//Set Prefix Mapping
q.setPrefixMapping(pmap);
//remove PrefixMapping so the prefixes will get replaced by the full uris
q.setPrefixMapping(null);
return q.serialize();
}
代码示例来源:origin: apache/jena
public static Expr parse(String s, PrefixMapping pmap)
{
Query query = QueryFactory.make() ;
query.setPrefixMapping(pmap) ;
return parse(query, s, true) ;
}
代码示例来源:origin: org.aksw.jena-sparql-api/jena-sparql-api-cache
public QueryRunner trySelect(String queryString) {
Stopwatch sw = Stopwatch.createStarted();
Query query = new Query();
query.setPrefixMapping(prefixMapping);
QueryFactory.parse(query, queryString, "http://example.org/", syntax);
QueryExecution qe = sparqlService.createQueryExecution(query);
ResultSet rs = qe.execSelect();
ResultSetFormatter.consume(rs);
System.out.println("Time taken: " + sw.elapsed(TimeUnit.MILLISECONDS));
return this;
}
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public QueryRunner trySelect(String queryString) {
Stopwatch sw = Stopwatch.createStarted();
Query query = new Query();
query.setPrefixMapping(prefixMapping);
QueryFactory.parse(query, queryString, "http://example.org/", syntax);
QueryExecution qe = sparqlService.createQueryExecution(query);
ResultSet rs = qe.execSelect();
ResultSetFormatter.consume(rs);
System.out.println("Time taken: " + sw.elapsed(TimeUnit.MILLISECONDS));
return this;
}
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public static Element parseElement(String elementStr, PrefixMapping prefixMapping) {
String tmp = elementStr.trim();
boolean isEnclosed = tmp.startsWith("{") && tmp.endsWith("}");
if(!isEnclosed) {
tmp = "{" + tmp + "}";
}
//ParserSparql10 p;
tmp = "SELECT * " + tmp;
Query query = new Query();
query.setPrefixMapping(prefixMapping);
// TODO Make parser configurable
SPARQLParser parser = new ParserSPARQL11();
parser.parse(query, tmp);
Element result = query.getQueryPattern();
return result;
}
代码示例来源:origin: apache/jena
@Override
public void visitPrologue(Prologue prologue) {
// newQuery.setBaseURI(prologue.getResolver()) ;
PrefixMapping pmap = new PrefixMappingImpl().setNsPrefixes(prologue.getPrefixMapping());
newQuery.setPrefixMapping(pmap);
}
代码示例来源:origin: apache/jena
private Expr parseExpr(String expression) {
Query query = new Query();
query.setPrefixMapping(prefixHandler.getPrefixes());
return ExprUtils.parse(query, expression, true);
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
@Override
public void visitPrologue(Prologue prologue) {
// newQuery.setBaseURI(prologue.getResolver()) ;
PrefixMapping pmap = new PrefixMappingImpl().setNsPrefixes(prologue.getPrefixMapping()) ;
newQuery.setPrefixMapping(pmap) ;
}
代码示例来源:origin: org.aksw.sparqlify/obda-api-sml
public ConstructViewDefinition(String name, String queryString, PrefixMapping prefixMapping) {
this.name = name;
this.query = new Query();
query.setPrefixMapping(prefixMapping);
SPARQLParser parser = SPARQLParser.createParser(Syntax.syntaxSPARQL_11);
parser.parse(query, queryString);
//query = QueryFactory.create("Prefix ft:<http://fintrans.publicdata.eu/ec/ontology/> Construct { ?s a ft:LabeledThing . } { ?s <" + RDFS.label + "> ?x }", Syntax.syntaxSPARQL_11)))
}
代码示例来源:origin: org.apache.jena/jena-querybuilder
private Expr parseExpr(String expression) {
Query query = new Query();
query.setPrefixMapping(prefixHandler.getPrefixes());
return ExprUtils.parse(query, expression, true);
}
代码示例来源:origin: SmartDataAnalytics/Sparqlify
public ConstructViewDefinition(String name, String queryString, PrefixMapping prefixMapping) {
this.name = name;
this.query = new Query();
query.setPrefixMapping(prefixMapping);
SPARQLParser parser = SPARQLParser.createParser(Syntax.syntaxSPARQL_11);
parser.parse(query, queryString);
//query = QueryFactory.create("Prefix ft:<http://fintrans.publicdata.eu/ec/ontology/> Construct { ?s a ft:LabeledThing . } { ?s <" + RDFS.label + "> ?x }", Syntax.syntaxSPARQL_11)))
}
代码示例来源:origin: TopQuadrant/shacl
/**
* Creates the "physical" Jena Query instance.
* Can be overloaded to create engine-specific Query objects such as those
* for AllegroGraph.
* @param queryString the parsable query string
* @param prefixMapping an optional PrefixMapping to initialize the Query with
* (this object may be modified)
* @return the ARQ Query object
*/
protected Query doCreateQuery(String queryString, PrefixMapping prefixMapping) {
Query query = new Query();
if(prefixMapping != null) {
query.setPrefixMapping(prefixMapping);
}
return QueryFactory.parse(query, queryString, null, getSyntax());
}
代码示例来源:origin: ch.epfl.bluebrain.nexus.org.topbraid/shacl
/**
* Creates the "physical" Jena Query instance.
* Can be overloaded to create engine-specific Query objects such as those
* for AllegroGraph.
* @param queryString the parsable query string
* @param prefixMapping an optional PrefixMapping to initialize the Query with
* (this object may be modified)
* @return the ARQ Query object
*/
protected Query doCreateQuery(String queryString, PrefixMapping prefixMapping) {
Query query = new Query();
if(prefixMapping != null) {
query.setPrefixMapping(prefixMapping);
}
return QueryFactory.parse(query, queryString, null, getSyntax());
}
代码示例来源:origin: SmartDataAnalytics/DL-Learner
query.setPrefixMapping(pm);
代码示例来源:origin: apache/jena
ARQParser parser = new ARQParser(new StringReader("SELECT " + s));
parser.setQuery(new Query());
parser.getQuery().setPrefixMapping( query.getPrefixMapping());
parser.SelectClause();
Query q = parser.getQuery();
代码示例来源:origin: org.apache.jena/jena-querybuilder
ARQParser parser = new ARQParser(new StringReader("SELECT " + s));
parser.setQuery(new Query());
parser.getQuery().setPrefixMapping( query.getPrefixMapping());
parser.SelectClause();
Query q = parser.getQuery();
代码示例来源:origin: dice-group/NLIWOD
q1.setPrefixMapping(pmap);
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
cQuery.setPrefixMapping(query.getPrefixMapping());
cQuery.getProject().add(Vars.c, new ExprAggregator(Vars.x, agg));
if(needsWrapping) {
Query q = query.cloneQuery();
q.setPrefixMapping(new PrefixMappingImpl());
queryPattern = new ElementSubQuery(q);
} else {
内容来源于网络,如有侵权,请联系作者删除!