当前位置: 首页>>代码示例>>Java>>正文


Java Query.getQueryPattern方法代码示例

本文整理汇总了Java中org.apache.jena.query.Query.getQueryPattern方法的典型用法代码示例。如果您正苦于以下问题:Java Query.getQueryPattern方法的具体用法?Java Query.getQueryPattern怎么用?Java Query.getQueryPattern使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.jena.query.Query的用法示例。


在下文中一共展示了Query.getQueryPattern方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertToSelect

import org.apache.jena.query.Query; //导入方法依赖的package包/类
protected Query convertToSelect(ParameterizedSparqlString pss, Set<String> varNames) {
	Query queryCpy = pss.asQuery();
	queryCpy.getQueryPattern();

	StringBuilder queryStr = new StringBuilder("SELECT DISTINCT ");
	for(String varName : varNames) {
		queryStr.append("?").append(varName).append(" ");
	}
	queryStr.append(queryCpy.getQueryPattern());
	ParameterizedSparqlString pssSelect = new ParameterizedSparqlString();
	pssSelect.setCommandText(queryStr.toString());
	pssSelect.setNsPrefixes(pss.getNsPrefixMap());
	pssSelect.append(" LIMIT ");
	pssSelect.append(this.limit);
	return pssSelect.asQuery();
}
 
开发者ID:dice-group,项目名称:IGUANA,代码行数:17,代码来源:PatternQueryHandler.java

示例2: visitQueryPattern

import org.apache.jena.query.Query; //导入方法依赖的package包/类
@Override
public void visitQueryPattern(Query query) {
    if (query.getQueryPattern() == null) {
        return;
    }
    final ElementNormalizer nzer = new ElementNormalizer();
    query.getQueryPattern().visit(nzer);
    query.setQueryPattern(nzer.getResult());
}
 
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:10,代码来源:QueryNormalizer.java

示例3: visitQueryPattern

import org.apache.jena.query.Query; //导入方法依赖的package包/类
@Override
public void visitQueryPattern(Query query) {
    if (query.getQueryPattern() != null) {
        out.print("WHERE");
        out.incIndent(BLOCK_INDENT);
        out.newline();

        Element el = query.getQueryPattern();

        fmtElement.visitAsGroup(el);
        //el.visit(fmtElement) ;
        out.decIndent(BLOCK_INDENT);
        out.newline();
    }
}
 
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:16,代码来源:SPARQLGenerateQuerySerializer.java

示例4: getJenaPath

import org.apache.jena.query.Query; //导入方法依赖的package包/类
/**
 * Attempts to parse a given string into a Jena Path.
 * Throws an Exception if the string cannot be parsed.
 * @param string  the string to parse
 * @param model  the Model to operate on (for prefixes)
 * @return a Path or a Resource if this is a URI
 */
public static Object getJenaPath(String string, Model model) throws QueryParseException {
	Query query = ARQFactory.get().createQuery(model, "ASK { ?a \n" + string + "\n ?b }");
	Element element = query.getQueryPattern();
	if(element instanceof ElementGroup) {
		Element e = ((ElementGroup)element).getElements().get(0);
		if(e instanceof ElementPathBlock) {
			return ((ElementPathBlock) e).getPattern().get(0).getPath();
		}
		else if(e instanceof ElementTriplesBlock) {
			return model.asRDFNode(((ElementTriplesBlock) e).getPattern().get(0).getPredicate());
		}
	}
	throw new QueryParseException("Not a SPARQL 1.1 Path expression", 2, 1);
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:22,代码来源:SHACLPaths.java

示例5: modifyQuery

import org.apache.jena.query.Query; //导入方法依赖的package包/类
/**
 * Modifies a query so that it operates onto a table. This is achieved
 * by appending the table as a VALUES block to the end of the main
 * query pattern.
 * 
 * @param query Original query; will be modified in place
 * @param table Data table to be added into the query
 */
private void modifyQuery(Query query, final Table table) {
	ElementData tableElement = new ElementData() {
		@Override
		public Table getTable() {
			return table;
		}
	};
	for (Var var: table.getVars()) {
		// Skip ?ROWNUM for "SELECT *" queries -- see further below
		if (query.isSelectType() && query.isQueryResultStar() 
				&& var.equals(TarqlQuery.ROWNUM)) continue;
		tableElement.add(var);
	}
	ElementGroup groupElement = new ElementGroup();
	groupElement.addElement(tableElement);
	if (query.getQueryPattern() instanceof ElementGroup) {
		for (Element element: ((ElementGroup) query.getQueryPattern()).getElements()) {
			groupElement.addElement(element);
		}
	} else {
		groupElement.addElement(query.getQueryPattern());
	}
	query.setQueryPattern(groupElement);
	
	// For SELECT * queries, we don't want to include pseudo
	// columns such as ?ROWNUM that may exist in the table.
	// That's why we skipped ?ROWNUM further up.
	if (query.isSelectType() && query.isQueryResultStar()) {
		// Force expansion of "SELECT *" to actual projection list
		query.setResultVars();
		// Tell ARQ that it actually needs to pay attention to
		// the projection list
		query.setQueryResultStar(false);
		// And now we can add ?ROWNUM to the table, as the "*"
		// has already been expanded.
		tableElement.add(TarqlQuery.ROWNUM);
	}
	// Data can only be added to table after we've finished the
	// ?ROWNUM shenangians
	/*for (Binding binding: table.getRows()) {
		tableElement.add(binding);
	}*/
}
 
开发者ID:tarql,项目名称:tarql,代码行数:52,代码来源:TarqlQueryExecution.java


注:本文中的org.apache.jena.query.Query.getQueryPattern方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。