com.clarkparsia.stardog.api
Interface Getter


public interface Getter

Interface for retrieving statements from a Stardog database.

Usage:

        // find a specific statement
        c.get().subject(s).predicate(p).object(o).statement();

        // get all statements w/ a specific subject
        c.get().subject(s).iterator();

        // get all statements w/ a specific predicate as a graph
        c.get().predicate(p).graph();
  

Since:
0.3
Version:
0.4.3
Author:
Michael Grove

Method Summary
 Getter context(Resource theContext)
          Set the context to get from the database
 Graph graph()
          Execute the getter and return the results as a graph.
 Iteration<Statement,StardogException> iterator()
          Return the results of the get operation as an iterator of the statements.
<O> Iteration<O,StardogException>
iterator(Function<Statement,O> theFunctor)
          Execute the Getter and apply the result to the statements returned by the getter.
 Iteration<Statement,StardogException> iterator(Resource theSubj, URI thePredicate, Value theObj, Resource theContext)
          Shortcut function for using iterator().
 Getter object(Value theObj)
          Set the object to get from the database
 Getter predicate(URI theURI)
          Set the predicate to get from the database.
 void reset()
          Reset the state of this Getter
 Statement statement()
          Execute the get operation and return a single result.
 Getter subject(Resource theRes)
          Set the subject to get from the database
 

Method Detail

subject

Getter subject(Resource theRes)
               throws StardogException
Set the subject to get from the database

Parameters:
theRes - the subject
Returns:
this getter
Throws:
StardogException - if the subject is invalid

predicate

Getter predicate(URI theURI)
                 throws StardogException
Set the predicate to get from the database.

Parameters:
theURI - the predicate
Returns:
this getter
Throws:
StardogException - if the predicate is invalid

object

Getter object(Value theObj)
              throws StardogException
Set the object to get from the database

Parameters:
theObj - the object
Returns:
this getter
Throws:
StardogException - if the object is invalid

context

Getter context(Resource theContext)
               throws StardogException
Set the context to get from the database

Parameters:
theContext - the context
Returns:
this getter
Throws:
StardogException - if the subject is invalid

iterator

Iteration<Statement,StardogException> iterator(Resource theSubj,
                                               URI thePredicate,
                                               Value theObj,
                                               Resource theContext)
                                               throws StardogException
Shortcut function for using iterator(). Instead of having to set the subject, predicate, and/or object separately and then call iterator, you can execute

Parameters:
theSubj - the subject to get, or null for any
thePredicate - the predicate to get, or null for any
theObj - the object to get, or null for any
theContext - the context to get, or null for any
Returns:
an iterator over the results of the get
Throws:
StardogException - if there is an error while retrieving the statements

statement

Statement statement()
                    throws StardogException
Execute the get operation and return a single result.

Returns:
the single result of the get
Throws:
StardogException - if there is an error while retrieving the statements

iterator

Iteration<Statement,StardogException> iterator()
                                               throws StardogException
Return the results of the get operation as an iterator of the statements.

Returns:
an iterator over ther results
Throws:
StardogException - if there is an error while retrieving the statements

graph

Graph graph()
            throws StardogException
Execute the getter and return the results as a graph. This method is only recommended if the result of the retrieval is a small set of results because the graph is returned entirely in memory. If the results are expected to be large, iterator(org.openrdf.model.Resource, org.openrdf.model.URI, org.openrdf.model.Value, org.openrdf.model.Resource) is a better choice because the results can be streamed from the database.

Returns:
the results of the get operation as a graph
Throws:
StardogException - if there was an error while retrieving the statements for the graph from the database

iterator

<O> Iteration<O,StardogException> iterator(Function<Statement,O> theFunctor)
                                       throws StardogException
Execute the Getter and apply the result to the statements returned by the getter.

Type Parameters:
O - the result of the function
Parameters:
theFunctor - the function to transform the statements
Returns:
an Iterator over the results
Throws:
StardogException - if there is an error while retrieving the statements from the database

reset

void reset()
           throws StardogException
Reset the state of this Getter

Throws:
StardogException - if there is an error while resetting the state of the getter, such as the connectino is no longer open


Copyright © 2010-2013 Clark & Parsia. All Rights Reserved.