Package com.complexible.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:
- 6.0
- Author:
- Michael Grove
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
ask()
Returns whether or notstatements()
returns any results, that is, whether or not there are any statements which match the current state of thisGetter
.boolean
ask(Statement theStatement)
Check to see if the statement exists in the database.Getter
context(Resource theContext)
Set the context to get from the databaseGetter
object(Value theObj)
Set the object to get from the databaseGetter
predicate(IRI theURI)
Set the predicate to get from the database.Getter
reasoning(boolean theReasoningType)
Sets the reasoning flag for this getter.void
reset()
Reset the state of this Getterjava.util.stream.Stream<Statement>
statements()
Return theStream
of results resulting from the get operation.java.util.stream.Stream<Statement>
statements(Resource theSubj, IRI thePredicate, Value theObj, Resource theContext)
Shortcut function for usingstatements()
.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(IRI 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
-
statements
java.util.stream.Stream<Statement> statements(Resource theSubj, IRI thePredicate, Value theObj, Resource theContext) throws StardogException
Shortcut function for usingstatements()
. Instead of having to set the subject, predicate, and/or object separately and then call iterator, you can get thestatements
directly. *NOTE* The `Stream` corresponds to a result set from the server and *MUST* be closed when no longer in use.- Parameters:
theSubj
- the subject to get, or null for anythePredicate
- the predicate to get, or null for anytheObj
- the object to get, or null for anytheContext
- 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
-
ask
boolean ask() throws StardogException
Returns whether or notstatements()
returns any results, that is, whether or not there are any statements which match the current state of thisGetter
.- Returns:
true
if there is at least one result orfalse
if there are no results- Throws:
StardogException
- if there is an error while retrieving the statement
-
ask
boolean ask(Statement theStatement) throws StardogException
Check to see if the statement exists in the database. Sugar forGetter.subject(theStatement.getSubject()) .predicate(theStatement.getPredicate()) .object(theStatement.getObject()) .context(theStatement.getContext()) .ask()
- Parameters:
theStatement
- the statement to check- Returns:
true
if the statement is in the database,false
otherwise- Throws:
StardogException
-
statements
java.util.stream.Stream<Statement> statements() throws StardogException
Return theStream
of results resulting from the get operation. The caller should ensure that theBaseStream.close()
method is called on the result to close any resources used to retrieve the statements.- Returns:
- an iterator over the results
- Throws:
StardogException
- if there is an error while retrieving the statements
-
reasoning
Getter reasoning(boolean theReasoningType)
Sets the reasoning flag for this getter. If no reasoning flag is specified, the default reasoning flag of the connection will be used.- Parameters:
theReasoningType
- the reasoning flag to use for the Getter- Returns:
- this getter
-
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 connection is no longer open
-
-