NAME

RDF::Trine::Model - Model class

VERSION

This document describes RDF::Trine::Model version 0.114_02

METHODS

new ( @stores )

Returns a new model over the supplied rdf store.

temporary_model

Returns a new temporary (non-persistent) model.

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.

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.

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 a stream object 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.

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_contexts
as_stream

Returns an iterator object 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.

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).

AUTHOR

Gregory Todd Williams <gwilliams@cpan.org>

COPYRIGHT

Copyright (c) 2006-2010 Gregory Todd Williams. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.