Package org.apache.jena.query
Class ResultSetFactory
- java.lang.Object
-
- org.apache.jena.query.ResultSetFactory
-
public class ResultSetFactory extends java.lang.ObjectResultSetFactory - make result sets from places other than a query.
-
-
Constructor Summary
Constructors Constructor Description ResultSetFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ResultSetCloseablecloseableResultSet(QueryExecution queryExecution)Return a closable resultset for aQueryExecution.static ResultSetRewindablecopyResults(ResultSet results)Take a copy of a result set - the result set returns is an in-memory copy.static ResultSetcreate(QueryIterator queryIterator, java.util.List<java.lang.String> vars)Build a result set from one of ARQ's lower level query iterator.static ResultSetfromJSON(java.io.InputStream in)Read from an input stream which is the format of the SPARQL result set format in JSON.static ResultSetfromSSE(java.io.InputStream in)Read from an input stream which is the format of the SPARQL result set format in SSE.static ResultSetfromTSV(java.io.InputStream in)Read from an input stream which is the format of the SPARQL result set format in TSV.static ResultSetfromXML(java.io.InputStream in)Read XML which is the format of the SPARQL result set format.static ResultSetload(java.io.InputStream input, ResultsFormat format)Load a result set from input stream into a result set (memory backed).static ResultSetload(java.lang.String filenameOrURI)Load a result set from file or URL into a result set (memory backed).static ResultSetload(java.lang.String filenameOrURI, ResultsFormat format)Load a result set from file or URL into a result set (memory backed).static ModelloadAsModel(java.lang.String filenameOrURI)Load a result set (or any other model) from file or URLstatic ModelloadAsModel(java.lang.String filenameOrURI, ResultsFormat format)Load a result set (or any other model) from file or URLstatic ModelloadAsModel(Model model, java.lang.String filenameOrURI)Load a result set (or any other model) from file or URLstatic ModelloadAsModel(Model model, java.lang.String filenameOrURI, ResultsFormat format)Load a result set (or any other model) from file or URL.static ResultSetPeekablemakePeekable(ResultSet resultSet)Turns an existing result set into one with peeking capabilitiesstatic ResultSetmakeResults(Model model)Turns an RDF model, with properties and classes from the result set vocabulary, into a SPARQL result set.static ResultSetRewindablemakeRewindable(ResultSet resultSet)Turn an existing result set into a rewindable one.static ResultSetRewindablemakeRewindable(Model model)Turns an RDF model, with properties and classes from the result set vocabulary, into a SPARQL result set which is rewindable (has a .reset()operation).static SPARQLResultresult(java.lang.String filenameOrURI)Read in any kind of result kind (result set, boolean, graph) Guess the syntax based on filename/URL extension.
-
-
-
Method Detail
-
load
public static ResultSet load(java.lang.String filenameOrURI)
Load a result set from file or URL into a result set (memory backed).- Parameters:
filenameOrURI-- Returns:
- ResultSet
-
load
public static ResultSet load(java.lang.String filenameOrURI, ResultsFormat format)
Load a result set from file or URL into a result set (memory backed).- Parameters:
filenameOrURI-format-- Returns:
- ResultSet
-
load
public static ResultSet load(java.io.InputStream input, ResultsFormat format)
Load a result set from input stream into a result set (memory backed).- Parameters:
input-format-- Returns:
- ResultSet
-
loadAsModel
public static Model loadAsModel(java.lang.String filenameOrURI)
Load a result set (or any other model) from file or URL- Parameters:
filenameOrURI-- Returns:
- Model
-
loadAsModel
public static Model loadAsModel(Model model, java.lang.String filenameOrURI)
Load a result set (or any other model) from file or URL- Parameters:
model- Load into this model (returned)filenameOrURI-- Returns:
- Model
-
loadAsModel
public static Model loadAsModel(java.lang.String filenameOrURI, ResultsFormat format)
Load a result set (or any other model) from file or URL- Parameters:
filenameOrURI-format-- Returns:
- Model
-
loadAsModel
public static Model loadAsModel(Model model, java.lang.String filenameOrURI, ResultsFormat format)
Load a result set (or any other model) from file or URL. Does not have to be a result set (e.g. CONSTRUCt results) but it does interpret the ResultSetFormat possibilities.- Parameters:
model- Load into this model (returned)filenameOrURI-format-- Returns:
- Model
-
result
public static SPARQLResult result(java.lang.String filenameOrURI)
Read in any kind of result kind (result set, boolean, graph) Guess the syntax based on filename/URL extension.
-
fromXML
public static ResultSet fromXML(java.io.InputStream in)
Read XML which is the format of the SPARQL result set format.- Parameters:
in- InputStream- Returns:
- ResultSet
-
fromJSON
public static ResultSet fromJSON(java.io.InputStream in)
Read from an input stream which is the format of the SPARQL result set format in JSON.- Parameters:
in- InputStream- Returns:
- ResultSet
-
fromTSV
public static ResultSet fromTSV(java.io.InputStream in)
Read from an input stream which is the format of the SPARQL result set format in TSV.- Parameters:
in- InputStream- Returns:
- ResultSet
-
fromSSE
public static ResultSet fromSSE(java.io.InputStream in)
Read from an input stream which is the format of the SPARQL result set format in SSE.- Parameters:
in- InputStream- Returns:
- ResultSet
-
makeResults
public static ResultSet makeResults(Model model)
Turns an RDF model, with properties and classes from the result set vocabulary, into a SPARQL result set. The result set formed is a copy in memory.- Parameters:
model-- Returns:
- ResultSet
-
makeRewindable
public static ResultSetRewindable makeRewindable(Model model)
Turns an RDF model, with properties and classes from the result set vocabulary, into a SPARQL result set which is rewindable (has a .reset()operation). The result set formed is a copy in memory.- Parameters:
model-- Returns:
- ResultSetRewindable
-
makeRewindable
public static ResultSetRewindable makeRewindable(ResultSet resultSet)
Turn an existing result set into a rewindable one. May take a copy but this is not guaranteed Uses up the result set passed in which is no longer valid as a ResultSet.- Parameters:
resultSet-- Returns:
- ResultSetRewindable
-
makePeekable
public static ResultSetPeekable makePeekable(ResultSet resultSet)
Turns an existing result set into one with peeking capabilitiesUsing the returned result set consumes the result set passed in, the underlying result set must be at the start in order to be made peeking. If you create such a result set you should avoid accessing the underlying result set directly as this may cause results to be missed or put the returned peekable result set into an invalid state.
Note that rewindable results may typically also be peekable so may be more broadly applicable if you can afford the cost of loading all the results into memory.- Parameters:
resultSet- Result set to wrap- Returns:
- Peekable results
-
closeableResultSet
public static ResultSetCloseable closeableResultSet(QueryExecution queryExecution)
Return a closable resultset for aQueryExecution. TheQueryExecutionmust be for aSELECTquery.Example:
QueryExecution qExec = QueryExecutionFactory.create(...); try (ResultSetCloseable rs = ResultSetFactory.closableResultSet(qExec) ) { ... }- Parameters:
queryExecution-QueryExecutionmust be for aSELECTquery.- Returns:
- ResultSetCloseable
-
copyResults
public static ResultSetRewindable copyResults(ResultSet results)
Take a copy of a result set - the result set returns is an in-memory copy. It is not attached to the original query execution object which can be closed.- Parameters:
results-- Returns:
- ResultSet
-
create
public static ResultSet create(QueryIterator queryIterator, java.util.List<java.lang.String> vars)
Build a result set from one of ARQ's lower level query iterator.- Parameters:
queryIterator-vars- List of variables, by name, for the result set- Returns:
- ResultSet
-
-