Interface TripleStore

  • All Known Implementing Classes:
    AbstractPowsyblTripleStore, EmptyTripleStore, TripleStoreRDF4J

    public interface TripleStore
    A Triplestore database. A Triplestore database is a database for the storage and retrieval of triples. A triple is a data entity composed of subject-predicate-object. Adding a name to a triple allows to separate them in contexts or named graphs.
    Author:
    Luma ZamarreƱo
    • Method Detail

      • getOptions

        default TripleStoreOptions getOptions()
        Obtain the options that have been used to configure this Triplestore
        Returns:
        options Triplestore configuration options
      • read

        void read​(InputStream is,
                  String base,
                  String contextName)
        Read statements from an input stream and store them in the Triplestore under the given context name.
        Parameters:
        is - input stream containing statements that will be added to the Triplestore
        base - the base URI used to convert relative URI's to absolute URI's
        contextName - name of the context where statements will be added
      • write

        void write​(DataSource ds)
        Write the contents of the Triplestore in the given data source. Statements in each context will be written to separate fileNames in the output data source
        Parameters:
        ds - the output data source
      • write

        default void write​(DataSource ds,
                           String contextName)
        Write the contents of a context in the given data source.
        Parameters:
        ds - the output data source
        contextName - the context to write
      • print

        void print​(PrintStream out)
        Print a summary of the contents of the Triplestore. Typically a list of contexts and its size (number of statements).
        Parameters:
        out - output stream where the summary will be written
      • print

        void print​(Consumer<String> liner)
        Print a summary of the contents of the Triplestore. Typically a list of contexts and its size (number of statements).
        Parameters:
        liner - a function that accepts strings (the lines of the summary report)
      • clear

        void clear​(String contextName)
        Delete all the statements in a given context.
        Parameters:
        contextName - the context to be cleared
      • defineQueryPrefix

        void defineQueryPrefix​(String prefix,
                               String namespace)
        Define namespace prefix bindings that will be used in the text of queries. Example: tripleStore.defineQueryPrefix("foaf", "http://xmlns.com/foaf/0.1/");
        Parameters:
        prefix - the prefix to be used in the text of queries as a replacement for the namespace
        namespace - the URL of the namespace
      • query

        PropertyBags query​(String query)
        Perform a SPARQL query on the Triplestore.
        Parameters:
        query - the text of the query, written in SPARQL query language
        Returns:
        the solution sequence of the query (the ways in which the query matches the data)
      • add

        void add​(String contextName,
                 String namespace,
                 String type,
                 PropertyBags objects)
        Add to the triple store statements for creating new resources, instances of a specific class
        Parameters:
        contextName - context where the statements are added
        namespace - the namespace of the class of the new resources
        type - the class of the new resources
        objects - properties of the resources
      • add

        String add​(String contextName,
                   String namespace,
                   String type,
                   PropertyBag properties)
        Add to the triple store statements for creating a new resource, instance of a specific class
        Parameters:
        contextName - the context where the statements are added
        namespace - the namespace of the class of the new resource
        type - the class of the new resource
        properties - properties of the resource
        Returns:
        the id of the new resource
      • add

        void add​(TripleStore source)
        Add all statements of the source Triplestore to this Triplestore.
        Parameters:
        source - the Triplestore containing statements to be added to this Triplestore
      • contextNames

        Set<String> contextNames()
        Get all the context names currently defined in the Triplestore.
        Returns:
        a set of all context names
      • update

        void update​(String queryText)
        Perform a SPARQL update on the Triplestore.
        Parameters:
        queryText - the text of the query, written in SPARQL Update language
      • addNamespace

        void addNamespace​(String prefix,
                          String namespace)
        Add a namespace to the triple store
        Parameters:
        prefix - the prefix of the namespace
        namespace - the namespace
      • getNamespaces

        List<PrefixNamespace> getNamespaces()
        Return the namespaces defined in the triple store
        Returns:
        the list of namespaces defined in the triple store
      • getImplementationName

        String getImplementationName()
        Return the implementation name defined in the triple store
        Returns:
        the string implementation name of the triplestore object