org.apache.jena.sparql.syntax.ElementVisitorBase Java Examples

The following examples show how to use org.apache.jena.sparql.syntax.ElementVisitorBase. 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: ARQFactory.java    From shacl with Apache License 2.0 6 votes vote down vote up
/**
 * Gets a list of named graphs (GRAPH elements) mentioned in a given
 * Query.
 * @param query  the Query to traverse
 * @return a List of those GRAPHs
 */
public static List<String> getNamedGraphURIs(Query query) {
	final List<String> results = new LinkedList<String>();
	ElementWalker.walk(query.getQueryPattern(), new ElementVisitorBase() {
		@Override
		public void visit(ElementNamedGraph el) {
			Node node = el.getGraphNameNode();
			if(node != null && node.isURI()) {
				String uri = node.getURI();
				if(!results.contains(uri)) {
					results.add(uri);
				}
			}
		}
	});
	return results;
}
 
Example #2
Source File: StatisticsVisitor.java    From IGUANA with GNU Affero General Public License v3.0 4 votes vote down vote up
public StatisticsVisitor() {
	super(new ElementVisitorBase());
}