Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.hp.hpl.jena.rdf.model
Class SimpleSelector

    java.lang.Object
      com.hp.hpl.jena.rdf.model.SimpleSelector

All Implemented Interfaces:
  Selector

    public class SimpleSelector

extends java.lang.Object
implements Selector

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.

Version:
  Release='$Name: $ $Revision: 1.16 $ $Date: 2008/01/02 12:05:46 $
Author:
  bwm

Constructor Summary
`SimpleSelector()` Create a selector.
`SimpleSelector(Resource subject, Property predicate, boolean object)` Create a selector.
`SimpleSelector(Resource subject, Property predicate, char object)` Create a selector.
`SimpleSelector(Resource subject, Property predicate, double object)` Create a selector.
`SimpleSelector(Resource subject, Property predicate, float object)` Create a selector.
`SimpleSelector(Resource subject, Property predicate, long object)` Create a selector.
`SimpleSelector(Resource subject, Property predicate, java.lang.Object object)` Create a selector.
`SimpleSelector(Resource subject, Property predicate, RDFNode object)` Create a selector.
`SimpleSelector(Resource subject, Property predicate, java.lang.String object)` Create a selector.
`SimpleSelector(Resource subject, Property predicate, java.lang.String object, java.lang.String language)` Create a selector.

Method Summary
`RDFNode` | `getObject()` Return the object constraint of this selector.
`Property` | `getPredicate()` Return the predicate constraint of this selector.
`Resource` | `getSubject()` Return the subject constraint of this selector.
`boolean` | `isSimple()` Answer true iff this Selector is completely characterised by its S/P/O triple.
`boolean` | `selects(Statement s)` This method is designed to be over ridden by subclasses to define application specific constraints on the statements selected.
`boolean` | `test(Statement s)` Test whether a statement should be included in a selection.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SimpleSelector

    public SimpleSelector()

  Create a selector. Since no subject, predicate or object constraints are specified a model will test all statements.

### SimpleSelector

    public SimpleSelector(Resource subject,
                          Property predicate,
                          RDFNode object)

  Create a selector. A model may restrict statements that are tested using the `selects` method to those whose subject matches the subject parameter, whose predicate matches the predicate parameter and whose object matches the object paramater. Any null parameter is considered to match anything.

  Parameters:
    `subject` - if not null, the subject of selected statements must equal this argument.
    `predicate` - if not null, the predicate of selected statements must equal this argument.
    `object` - if not null, the object of selected statements must equal this argument.

### SimpleSelector

    public SimpleSelector(Resource subject,
                          Property predicate,
                          boolean object)

  Create a selector. A model may restrict statements that are tested using the `selects` method to those whose subject matches the subject parameter, whose predicate matches the predicate parameter and whose object matches the object paramater. Any null parameter is considered to match anything.

  Parameters:
    `subject` - if not null, the subject of selected statements must equal this argument.
    `predicate` - if not null, the predicate of selected statements must equal this argument.
    `object` - if not null, the object of selected statements must equal this argument.

### SimpleSelector

    public SimpleSelector(Resource subject,
                          Property predicate,
                          long object)

  Create a selector. A model may restrict statements that are tested using the `selects` method to those whose subject matches the subject parameter, whose predicate matches the predicate parameter and whose object matches the object paramater. Any null parameter is considered to match anything.

  Parameters:
    `subject` - if not null, the subject of selected statements must equal this argument.
    `predicate` - if not null, the predicate of selected statements must equal this argument.
    `object` - the object of selected statements must equal this argument.

### SimpleSelector

    public SimpleSelector(Resource subject,
                          Property predicate,
                          char object)

  Create a selector. A model may restrict statements that are tested using the `selects` method to those whose subject matches the subject parameter, whose predicate matches the predicate parameter and whose object matches the object paramater. Any null parameter is considered to match anything.

  Parameters:
    `subject` - if not null, the subject of selected statements must equal this argument.
    `predicate` - if not null, the predicate of selected statements must equal this argument.
    `object` - the object of selected statements must equal this argument.

### SimpleSelector

    public SimpleSelector(Resource subject,
                          Property predicate,
                          float object)

  Create a selector. A model may restrict statements that are tested using the `selects` method to those whose subject matches the subject parameter, whose predicate matches the predicate parameter and whose object matches the object paramater. Any null parameter is considered to match anything.

  Parameters:
    `subject` - if not null, the subject of selected statements must equal this argument.
    `predicate` - if not null, the predicate of selected statements must equal this argument.
    `object` - the object of selected statements must equal this argument.

### SimpleSelector

    public SimpleSelector(Resource subject,
                          Property predicate,
                          double object)

  Create a selector. A model may restrict statements that are tested using the `selects` method to those whose subject matches the subject parameter, whose predicate matches the predicate parameter and whose object matches the object paramater. Any null parameter is considered to match anything.

  Parameters:
    `subject` - if not null, the subject of selected statements must equal this argument.
    `predicate` - if not null, the predicate of selected statements must equal this argument.
    `object` - the object of selected statements must equal this argument.

### SimpleSelector

    public SimpleSelector(Resource subject,
                          Property predicate,
                          java.lang.String object)

  Create a selector. A model may restrict statements that are tested using the `selects` method to those whose subject matches the subject parameter, whose predicate matches the predicate parameter and whose object matches the object paramater. Any null parameter is considered to match anything.

  Parameters:
    `subject` - if not null, the subject of selected statements must equal this argument.
    `predicate` - if not null, the predicate of selected statements must equal this argument.
    `object` - the object of selected statements must equal this argument - a null string matches the empty string

### SimpleSelector

    public SimpleSelector(Resource subject,
                          Property predicate,
                          java.lang.String object,
                          java.lang.String language)

  Create a selector. A model may restrict statements that are tested using the `selects` method to those whose subject matches the subject parameter, whose predicate matches the predicate parameter and whose object matches the object paramater. Any null parameter is considered to match anything.

  Parameters:
    `subject` - if not null, the subject of selected statements must equal this argument.
    `predicate` - if not null, the predicate of selected statements must equal this argument.
    `object` - the object of selected statements must equal this argument - the null string matches the empty string
    `language` - the language of the object constraint

### SimpleSelector

    public SimpleSelector(Resource subject,
                          Property predicate,
                          java.lang.Object object)

  Create a selector. A model may restrict statements that are tested using the `selects` method to those whose subject matches the subject parameter, whose predicate matches the predicate parameter and whose object matches the object paramater. Any null parameter is considered to match anything.

  Parameters:
    `subject` - if not null, the subject of selected statements must equal this argument.
    `predicate` - if not null, the predicate of selected statements must equal this argument.
    `object` - if not null, the object of selected statements must equal this argument.

Method Detail

### getSubject

    public Resource getSubject()

  Return the subject constraint of this selector.

  Specified by:
    `getSubject` in interface `Selector`
  Returns:
    the subject constraint

### getPredicate

    public Property getPredicate()

  Return the predicate constraint of this selector.

  Specified by:
    `getPredicate` in interface `Selector`
  Returns:
    the predicate constraint

### getObject

    public RDFNode getObject()

  Return the object constraint of this selector.

  Specified by:
    `getObject` in interface `Selector`
  Returns:
    the object constraint

### isSimple

    public boolean isSimple()

  Answer true iff this Selector is completely characterised by its S/P/O triple. Subclasses will by default return false, so this method need not be over-ridden (the only reason for subclassing SimpleSelector is to make a test not dependent only on the S/P/O identity).

  Specified by:
    `isSimple` in interface `Selector`
  Returns:
    true iff this selector only depends on S/P/O identity.

### test

    public boolean test(Statement s)

  Test whether a statement should be included in a selection. This method tests whether the supplied statement satisfies the subject, predicate and object constraints of the selector and then tests whether it matches the application provided `selects` method.

  Specified by:
    `test` in interface `Selector`
  Parameters:
    `s` - the statement to be tested
  Returns:
    true if the statement satisfies the subject, object and predicate constraints and the selects constraint.

### selects

    public boolean selects(Statement s)

  This method is designed to be over ridden by subclasses to define application specific constraints on the statements selected.

  Parameters:
    `s` - the statement to be tested
  Returns:
    true if the statement satisfies the constraint

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP