Class SparqlScriptProcessor

java.lang.Object
org.aksw.jena_sparql_api.rx.script.SparqlScriptProcessor

public class SparqlScriptProcessor extends Object
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
  • Field Details

  • Constructor Details

    • SparqlScriptProcessor

      public SparqlScriptProcessor(Function<? super org.apache.jena.sparql.core.Prologue,? extends SparqlStmtParser> sparqlParserFactory, org.apache.jena.shared.PrefixMapping globalPrefixes)
  • Method Details

    • addPostTransformer

      public void addPostTransformer(Function<? super SparqlStmt,? extends SparqlStmt> transformer)
    • addPostMutator

      public void addPostMutator(Consumer<? super SparqlStmt> mutator)
    • getSparqlStmts

    • getPlainSparqlStmts

      public List<SparqlStmt> getPlainSparqlStmts()
    • getSparqlParser

      public SparqlStmtParser 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)
    • createWithEnvSubstitution

      public static SparqlScriptProcessor createWithEnvSubstitution(org.apache.jena.shared.PrefixMapping globalPrefixes)
      Create a script processor that substitutes references to environment variables with the appropriate values.
      Parameters:
      pm -
      Returns:
    • createWithEnvSubstitution

      public static SparqlScriptProcessor createWithEnvSubstitution(org.apache.jena.shared.PrefixMapping globalPrefixes, Function<String,String> lookup)
    • createPlain

      public static SparqlScriptProcessor createPlain(org.apache.jena.shared.PrefixMapping globalPrefixes, String base)
    • process

      public void process(List<String> filenames)
    • processPaths

      public void processPaths(Collection<Path> paths)
    • process

      public void process(int index, Path path)
    • process

      public void process(String filename)
    • process

      public void process(int index, String filename)
    • createParser

      public SparqlStmtParser createParser(String baseIri)
    • process

      public void process(int index, String filename, List<Map.Entry<SparqlStmt,SparqlScriptProcessor.Provenance>> result)
    • tryLoadFileAsUpdateRequest

      public static org.apache.jena.update.UpdateRequest tryLoadFileAsUpdateRequest(String filename, org.apache.jena.graph.Node targetGraph, org.apache.jena.shared.PrefixMapping globalPrefixes, Collection<Map.Entry<org.apache.jena.riot.Lang,Throwable>> errorCollector) throws IOException
      Throws:
      IOException
    • tryLoadFileAsUpdateRequestOld

      public static org.apache.jena.update.UpdateRequest tryLoadFileAsUpdateRequestOld(String filename, org.apache.jena.shared.PrefixMapping globalPrefixes) throws IOException
      Throws:
      IOException