From deeed3224f89ecea187f906d3c4e8c900bd0dace Mon Sep 17 00:00:00 2001 From: Marcel Otto Date: Wed, 24 May 2017 23:37:09 +0200 Subject: [PATCH] core: RDF.Data protocol --- lib/rdf/data.ex | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 lib/rdf/data.ex diff --git a/lib/rdf/data.ex b/lib/rdf/data.ex new file mode 100644 index 0000000..b669d30 --- /dev/null +++ b/lib/rdf/data.ex @@ -0,0 +1,66 @@ +defprotocol RDF.Data do + @moduledoc """ + An abstraction over the different data structures for collections of RDF statements. + """ + + @doc """ + Add statements to a RDF data structure. + """ + def add(data, statements) + + @doc """ + Adds statements to a RDF data structure and overwrites all existing statements with the same subjects and predicates. + """ + def put(data, statements) + + @doc """ + Deletes statements from a RDF data structure. + """ + def delete(data, statements) + + @doc """ + Deletes one statement from a RDF data structure and returns a tuple with deleted statement and the changed data structure. + """ + def pop(data) + + @doc """ + Checks if the given statement exists within a RDF data structure. + """ + def include?(data, statements) + + @doc """ + Returns the list of all statements of a RDF data structure. + """ + def statements(data) + + @doc """ + Returns the set of all resources which are subject of the statements of a RDF data structure. + """ + def subjects(data) + + @doc """ + Returns the set of all properties used within the statements of RDF data structure. + """ + def predicates(data) + + @doc """ + Returns the set of all resources used in the objects within the statements of a RDF data structure. + """ + def objects(data) + + @doc """ + Returns the set of all resources used within the statements of a RDF data structure + """ + def resources(data) + + @doc """ + Returns the count of all resources which are subject of the statements of a RDF data structure. + """ + def subject_count(data) + + @doc """ + Returns the count of all statements of a RDF data structure. + """ + def statement_count(data) + +end