org.openrdf.query.parser.sparql.SPARQLParser Java Examples

The following examples show how to use org.openrdf.query.parser.sparql.SPARQLParser. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BGPGroupGenerator.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
/**
 * Generate BGP groups from a SPARQL query
 * @param parsedQuery TupleExpr of the SPARQL query
 * @return DNFGrps Map of DNF groups
 * @throws MalformedQueryException 
 */
public static HashMap<Integer, List<StatementPattern>>  generateBgpGroups(String strQuery) throws MalformedQueryException
{
	HashMap<Integer, List<StatementPattern>> bgpGrps = new HashMap<Integer, List<StatementPattern>>();
	int grpNo = 0;
	SPARQLParser parser = new SPARQLParser();
	ParsedQuery parsedQuery = parser.parseQuery(strQuery, null);
	TupleExpr query = parsedQuery.getTupleExpr();
	// collect all basic graph patterns

	for (TupleExpr bgp : BasicGraphPatternExtractor.process(query)) {
		//System.out.println(bgp);
		List<StatementPattern> patterns = StatementPatternCollector.process(bgp);	
		bgpGrps.put(grpNo, patterns );
		grpNo++;
	}

	return bgpGrps;
}