All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mindswap.pellet.jena.graph.query.SubjectObjectVarHandler Maven / Gradle / Ivy

// Copyright (c) 2006 - 2008, Clark & Parsia, LLC. 
// This source code is available under the terms of the Affero General Public License v3.
//
// Please see LICENSE.txt for full license terms, including the availability of proprietary exceptions.
// Questions, comments, or requests for clarification: [email protected]

package org.mindswap.pellet.jena.graph.query;

import java.util.Collection;
import java.util.Iterator;

import org.mindswap.pellet.KnowledgeBase;
import org.mindswap.pellet.jena.JenaUtils;
import org.mindswap.pellet.jena.graph.loader.GraphLoader;
import org.mindswap.pellet.utils.iterator.NestedIterator;

import aterm.ATermAppl;

import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.graph.Triple;
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
import com.hp.hpl.jena.util.iterator.WrappedIterator;

abstract class SubjectObjectVarHandler extends TripleQueryHandler {
	public abstract Collection getSubjects(KnowledgeBase kb);
	
	public abstract Iterator getObjects(KnowledgeBase kb, ATermAppl subj);

	@Override
	public final ExtendedIterator find(final KnowledgeBase kb, GraphLoader loader, final Node s, final Node p, final Node o) {
		return WrappedIterator.create( 
			new NestedIterator( getSubjects( kb ) ) {
				@Override
				public Iterator getInnerIterator(ATermAppl subj) {
					Node s = JenaUtils.makeGraphNode( subj );
					return objectFiller( s, p, getObjects( kb, subj ) );
				}
			}
		);
	}			
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy