A general selector class for use when querying models.
An instance of this class is passed with query calls to models. The model will use the test
method of this class to decide whether a statement should be included in the selection.
Instances of this class can be provided with subject, predicate and object constraints. If a subject, a predicate or an object are provided, the model implementation may restrict the statements that it tests to statements whose subject, predicate and object match those provided in the constructor. This can provide for considerably more efficient searching. However, the model implementation is not required to do this. If no subject, predicate or object are provided in the constructor, then all statements in the model must be tested.
This class is designed to be subclassed by the application, defining defining further selection criteria of its own by providing its own selects
method.
A direct instance of SimpleSelector returns true
for the Selector::isSimple() predicate. Instances of subclasses of SimpleSelector return false
, since the only reason to have such subclasses is to provide a non-trivial test
predicate or S/P/O tests other than equality.
The test
method first verifies that a statement satisfies any subject, predicate or object constraints and the calls the selects
method to test for any application supplied constraint. The default selects
method simply returns true.