Class SparqlScriptProcessor
java.lang.Object
org.aksw.jena_sparql_api.rx.script.SparqlScriptProcessor
Convenient SPARQL statement loader. Probes arguments whether they are inline SPARQL statements or refer to files.
Referred files may contain RDF or sequences of SPARQL statements.
RDF files are loaded fully into memory as UpdateModify statements.
Usually the SparqlQueryParserWrapperSelectShortForm should be active which allows omitting the SELECT keyword making
querying even less verbose
Prefixes from an input source carry over to the next. Hence, if an RDF file is loaded, its prefixes can be used in
subsequent SPARQL statements without need for declaration.
For example assuming that mydata defines a foo prefix
ad-hoc querying becomes possible simply using the arguments ["people.ttl", "?s { ?s a foaf:Person }"]
Arguments that start with cwd=/some/path sets the current working directory on which SPARQL queries operate.
Effectively it sets the base URL of the following SPARQL queries.
Relative paths are resolved against the current working directory as reported by the JVM.
Use "cwd=" (with an empty string) to reset the CWD to that of the JVM
Graphs can be pinned for all subsequent arguments using
"graph=your://graph.name". Use "graph=" (nothing after the =) to use the default graph.
- Author:
- Claus Stadler
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classProvenance of SPARQL statements - file:line:column -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Pathstatic final Stringstatic final Stringprotected org.apache.jena.shared.PrefixMappingThe set of global prefixes will be extended with the prefixes of every parsed query.static final Stringstatic final Stringprotected List<Function<? super SparqlStmt,? extends SparqlStmt>> protected Function<? super org.apache.jena.sparql.core.Prologue,? extends SparqlStmtParser> protected List<Map.Entry<SparqlStmt,SparqlScriptProcessor.Provenance>> protected org.apache.jena.graph.NodeGraph name in which to insert triples -
Constructor Summary
ConstructorsConstructorDescriptionSparqlScriptProcessor(Function<? super org.apache.jena.sparql.core.Prologue, ? extends SparqlStmtParser> sparqlParserFactory, org.apache.jena.shared.PrefixMapping globalPrefixes) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPostMutator(Consumer<? super SparqlStmt> mutator) voidaddPostTransformer(Function<? super SparqlStmt, ? extends SparqlStmt> transformer) createParser(String baseIri) static SparqlStmtParsercreateParserPlain(org.apache.jena.sparql.core.Prologue prologue, String base) static SparqlStmtParsercreateParserWithEnvSubstitution(org.apache.jena.sparql.core.Prologue prologue) static SparqlStmtParsercreateParserWithEnvSubstitution(org.apache.jena.sparql.core.Prologue prologue, Function<String, String> lookup) static SparqlScriptProcessorcreatePlain(org.apache.jena.shared.PrefixMapping globalPrefixes, String base) static SparqlScriptProcessorcreateWithEnvSubstitution(org.apache.jena.shared.PrefixMapping globalPrefixes) Create a script processor that substitutes references to environment variables with the appropriate values.static SparqlScriptProcessorcreateWithEnvSubstitution(org.apache.jena.shared.PrefixMapping globalPrefixes, Function<String, String> lookup) voidvoidprocess(int index, String filename, List<Map.Entry<SparqlStmt, SparqlScriptProcessor.Provenance>> result) voidvoidvoidvoidprocessPaths(Collection<Path> paths) static org.apache.jena.update.UpdateRequesttryLoadFileAsUpdateRequest(String filename, org.apache.jena.graph.Node targetGraph, org.apache.jena.shared.PrefixMapping globalPrefixes, Collection<Map.Entry<org.apache.jena.riot.Lang, Throwable>> errorCollector)
-
Field Details
-
cwdKey
- See Also:
-
cwdResetCwd
- See Also:
-
graphKey
- See Also:
-
graphResetKey
- See Also:
-
sparqlParserFactory
protected Function<? super org.apache.jena.sparql.core.Prologue,? extends SparqlStmtParser> sparqlParserFactory -
globalPrefixes
protected org.apache.jena.shared.PrefixMapping globalPrefixesThe set of global prefixes will be extended with the prefixes of every parsed query. Set this attribute to null to disable global prefixes. -
cwd
-
targetGraph
protected org.apache.jena.graph.Node targetGraphGraph name in which to insert triples -
sparqlStmts
-
postTransformers
-
-
Constructor Details
-
Method Details
-
addPostTransformer
-
addPostMutator
-
getSparqlStmts
-
getPlainSparqlStmts
-
getSparqlParser
-
createParserPlain
public static SparqlStmtParser createParserPlain(org.apache.jena.sparql.core.Prologue prologue, String base) -
createParserWithEnvSubstitution
public static SparqlStmtParser createParserWithEnvSubstitution(org.apache.jena.sparql.core.Prologue prologue) -
createParserWithEnvSubstitution
public static SparqlStmtParser createParserWithEnvSubstitution(org.apache.jena.sparql.core.Prologue prologue, Function<String, String> lookup) -
process
-
processPaths
-
process
-
process
-
process
-
createParser
-
process
public void process(int index, String filename, List<Map.Entry<SparqlStmt, SparqlScriptProcessor.Provenance>> result)
-