RDF::Trine::Model - Model class
This document describes RDF::Trine::Model version 1.019
- "new ( $store )"
- Returns a new model over the supplied rdf store or a new temporary model.
If you provide an unblessed value, it will be used to create a new rdf
store.
- "temporary_model"
- Returns a new temporary (non-persistent) model.
- "dataset_model ( default => \@dgraphs, named => \@ngraphs
)"
- Returns a new model object with the default graph mapped to the union of
the graphs named in @dgraphs, and with available
named graphs named in @ngraphs.
- "begin_bulk_ops"
- Provides a hint to the backend that many update operations are about to
occur. The backend may use this hint to, for example, aggregate many
operations into a single operation, or delay index maintenence. After the
update operations have been executed,
"end_bulk_ops" should be called to
ensure the updates are committed to the backend.
- "end_bulk_ops"
- Provides a hint to the backend that a set of bulk operations have been
completed and may be committed to the backend.
- "logger ( [ $logger ] )"
- Returns the logging object responsible for recording data inserts and
deletes.
If $logger is passed as an argument,
sets the logger to this object.
- "add_statement ( $statement [, $context] )"
- Adds the specified $statement to the rdf
store.
- "add_hashref ( $hashref [, $context] )"
- Add triples represented in an RDF/JSON-like manner to the model.
See "as_hashref" for full
documentation of the hashref format.
- "add_iterator ( $iter )"
- Add triples from the statement iterator to the model.
- "add_list ( @elements )"
- Adds an rdf:List to the model with the given elements. Returns the node
object that is the head of the list.
- "get_list ( $head )"
- Returns a list of nodes that are elements of the rdf:List represented by
the supplied head node.
- "remove_list ( $head [, orphan_check => 1] )"
- Removes the nodes of type rdf:List that make up the list. Optionally
checks each node before removal to make sure that it is not used in any
other statements. Returns false if the list was removed completely;
returns the first remaining node if the removal was abandoned because of
an orphan check.
- "get_sequence ( $seq )"
- Returns a list of nodes that are elements of the rdf:Seq sequence.
- "remove_statement ( $statement [, $context])"
- Removes the specified $statement from the rdf
store.
- "remove_statements ( $subject, $predicate, $object [, $context]
)"
- Removes all statements matching the supplied
$statement pattern from the rdf store.
- "size"
- Returns the number of statements in the model.
- "etag"
- If the model is based on a store that has the capability and knowledge to
support caching, this method returns a persistent token that will remain
consistent as long as the store's data doesn't change. This token is
acceptable for use as an HTTP ETag.
- "supports ( [ $feature ] )"
- If $feature is specified, returns true if the
feature is supported by the underlying store, false otherwise. If
$feature is not specified, returns a list of
supported features.
- "count_statements ( $subject, $predicate, $object )"
- Returns a count of all the statements matching the specified subject,
predicate and objects. Any of the arguments may be undef to match any
value.
- "get_statements ($subject, $predicate, $object [, $context]
)"
- Returns an iterator of all statements matching the specified subject,
predicate and objects from the rdf store. Any of the arguments may be
undef to match any value.
If three or fewer arguments are given, the statements returned
will be matched based on triple semantics (the graph union of triples
from all the named graphs). If four arguments are given (even if
$context is undef), statements will be matched
based on quad semantics (the union of all quads in the underlying
store).
- "get_pattern ( $bgp [, $context] [, %args ] )"
- Returns a stream object of all bindings matching the specified graph
pattern.
If $context is given, restricts BGP
matching to only quads with the $context
value.
%args may contain an 'orderby'
key-value pair to request a specific ordering based on variable name.
The value for the 'orderby' key should be an ARRAY reference containing
variable name and direction ('ASC' or 'DESC') tuples. A valid
%args hash, therefore, might look like
"orderby => [qw(name ASC)]"
(corresponding to a SPARQL-like request to 'ORDER BY ASC(?name)').
- "get_sparql ( $sparql )"
- Returns a stream object of all bindings matching the specified graph
pattern.
- "get_graphs"
- "get_contexts"
- Returns an iterator containing the nodes representing the named graphs in
the model.
- "as_stream"
- Returns an iterator containing every statement in the model.
- "as_hashref"
- Returns a hashref representing the model in an RDF/JSON-like manner.
A graph like this (in Turtle):
@prefix ex: <http://example.com/> .
ex:subject1
ex:predicate1
"Foo"@en ,
"Bar"^^ex:datatype1 .
_:bnode1
ex:predicate2
ex:object2 ;
ex:predicate3 ;
_:bnode3 .
Is represented like this as a hashref:
{
"http://example.com/subject1" => {
"http://example.com/predicate1" => [
{ 'type'=>'literal', 'value'=>"Foo", 'lang'=>"en" },
{ 'type'=>'literal', 'value'=>"Bar", 'datatype'=>"http://example.com/datatype1" },
],
},
"_:bnode1" => {
"http://example.com/predicate2" => [
{ 'type'=>'uri', 'value'=>"http://example.com/object2" },
],
"http://example.com/predicate2" => [
{ 'type'=>'bnode', 'value'=>"_:bnode3" },
],
},
}
Note that the type of subjects (resource or blank node) is
indicated entirely by the convention of starting blank nodes with
"_:".
This hashref structure is compatible with RDF/JSON and with
the ARC2 library for PHP.
- "as_graphviz"
- Returns a GraphViz object of the RDF graph of this model, ignoring graph
names/contexts.
This method will attempt to load the GraphViz module at
runtime and will fail if the module is unavailable.
- "subjects ( $predicate, $object )"
- Returns a list of the nodes that appear as the subject of statements with
the specified $predicate and
$object. Either of the two arguments may be undef
to signify a wildcard.
- "predicates ( $subject, $object )"
- Returns a list of the nodes that appear as the predicate of statements
with the specified $subject and
$object. Either of the two arguments may be undef
to signify a wildcard.
- "objects ( $subject, $predicate [, $graph ] [, %options ]
)"
- Returns a list of the nodes that appear as the object of statements with
the specified $subject and
$predicate. Either of the two arguments may be
undef to signify a wildcard. You can further filter objects using the
%options argument. Keys in
%options indicate the restriction type and may be
'type', 'language', or 'datatype'. The value of the 'type' key may be one
of 'node', 'nil', 'blank', 'resource', 'literal', or 'variable'. The use
of either 'language' or 'datatype' restrict objects to literal nodes with
a specific language or datatype value, respectively.
- "objects_for_predicate_list ( $subject, @predicates )"
- Given the RDF::Trine::Node objects $subject and
@predicates, finds all matching triples in the
model with the specified subject and any of the given predicates, and
returns a list of object values (in the partial order given by the
ordering of @predicates).
- "bounded_description ( $node )"
- Returns an RDF::Trine::Iterator::Graph object over the bounded description
triples for $node (all triples resulting from a
graph traversal starting with "node" and
stopping at non-blank nodes).
- "as_string"
Please report any bugs or feature requests to through the GitHub
web interface at <https://github.com/kasei/perlrdf/issues>.
Gregory Todd Williams
"<gwilliams@cpan.org>"
Copyright (c) 2006-2012 Gregory Todd Williams. This program is
free software; you can redistribute it and/or modify it under the same terms
as Perl itself.