grafter-2.rdf4j.io
added in 0.12.1
Functions & Protocols for serializing Grafter Statements to (and from)
any Linked Data format supported by RDF4j.
backend-literal->grafter-type
multimethod
A multimethod to convert a backend RDF literal into a corresponding
Clojure type. This method can be extended to provide custom
conversions. You should typically not need to call this directly,
instead see backend-quad->grafter-quad.
backend-quad->grafter-quad
(backend-quad->grafter-quad st)
Convert an RDF4j backend quad into a grafter Quad.
default-prefixes
A default set of common prefixes
IRDF4jConverter
protocol
members
->backend-type
(->backend-type this)
Convert an arbitrary statement type into an RDF4j Statement type
quad->backend-quad
(quad->backend-quad is)
Convert a grafter IStatement into a backend (RDF4j) statement type.
rdf-writer
(rdf-writer destination & {:keys [append format encoding prefixes], :or {append false, encoding "UTF-8", prefixes default-prefixes}})
Coerces destination into an java.io.Writer using
clojure.java.io/writer and returns an RDFWriter.
Use this to capture the intention to write to a location in a
specific RDF format, e.g.
(grafter-2.rdf/add (rdf-writer "/tmp/foo.nt" :format :nt) quads)
Accepts also the following optional options:
- :append If set to true it will append new values to the end of
the file destination (default: `false`).
- :format If a String or a File are provided the format parameter
can be optional (in which case it will be infered from
the file extension). This should be a clojure keyword
representing the format extension e.g. :nt.
- :encoding The character encoding to be used (default: UTF-8)
- :prefixes A map of RDF prefix names to URI prefixes.
statements
(statements this & {:keys [format buffer-size base-uri], :as options})
Attempts to coerce an arbitrary source of RDF statements into a
sequence of grafter Statements, using the RDF4j backend.
If the source is a quad store quads from all the named graphs will
be returned. Any triples in an unnamed graph will be ignored.
Takes optional parameters which may be used depending on the
context e.g. specifiying the format of the source triples.
The `:format` option is supplied by the wrapping function and may be
nil, or act as an indicator about the format of the triples to read.
Implementers can choose whether or not to ignore or require the
format parameter.
The `:buffer-size` option can be used to configure the buffer size
at which statements are parsed from an RDF stream. Its default
value of 32 was found to work well in practice, and also aligns with
chunk size of Clojure's lazy sequences.
The `:base-uri` option can be supplied to automatically re`@base`
URI's on a new prefix when reading.
ToRDF4JURI
protocol
members
->rdf4j-uri
(->rdf4j-uri this)
Coerce an object into a sesame URIImpl