model
[ class tree: model ] [ index: model ] [ all elements ]

Class: RDF_Model_Memory

Source Location: /RDF-0.2.0/RDF/Model/Memory.php

Class Overview

RDF_Object
   |
   --RDF_Model
      |
      --RDF_Model_Memory

A model is a programming interface to an RDF graph.


Author(s):

Version:

  • V0.7

Variables

Methods


Inherited Variables

Inherited Methods

Class: RDF_Model

RDF_Model::getBaseURI()
Return current baseURI.
RDF_Model::load()
Load a model from a file containing RDF, N3 or N-Triples.
RDF_Model::_addStatementFromAnotherModel()
Adds a statement from another model to this model.

Class: RDF_Object

RDF_Object::factory()
RDF_Object::toString()
Serializes a object into a string

Class Details

[line 20]
A model is a programming interface to an RDF graph.

An RDF graph is a directed labeled graph, as described in http://www.w3.org/TR/rdf-mt/. It can be defined as a set of <S, P, O> triples, where P is a uriref, S is either a uriref or a blank node, and O is either a uriref, a blank node, or a literal.



[ Top ]


Class Variables

$index =

[line 36]

Search index
  • Access: protected

Type:   array


[ Top ]

$indexed =

[line 44]

This is set to true if the Model_Memory is indexed
  • Access: protected

Type:   boolean


[ Top ]

$triples = array()

[line 28]

Triples of the Model_Memory
  • Access: protected

Type:   array


[ Top ]



Method Detail

RDF_Model_Memory (Constructor)   [line 52]

RDF_Model_Memory RDF_Model_Memory( [string $baseURI = null])

You can supply a base_uri
  • Access: public

Parameters:

string   $baseURI   — 

[ Top ]

add   [line 112]

void add( object Statement $statement)

Adds a new triple to the Model_Memory without checking if the statement is already in the Model_Memory.

The function doesn't check if the statement is already in the Model_Memory. So if you want a duplicate free Model_Memory use the addWithoutDuplicates() function (which is slower then add())

  • Throws: PhpError
  • Access: public

Parameters:

object Statement   $statement   — 

[ Top ]

addModel   [line 897]

void addModel( &$model, object Model $model)

Adds another model to this Model_Memory.

Duplicate statements are not removed. If you don't want duplicates, use unite().

  • Throws: phpErrpr
  • Access: public

Parameters:

object Model   $model   — 
   &$model   — 

[ Top ]

addWithoutDuplicates   [line 132]

void addWithoutDuplicates( object Statement $statement)

Checks if a new statement is already in the Model_Memory and adds the statement, if it is not in the Model_Memory.

addWithoutDuplicates() is significantly slower then add().

  • Throws: PhpError
  • Access: public

Parameters:

object Statement   $statement   — 

[ Top ]

close   [line 963]

void close( )

Close the Model_Memory and free up resources held.
  • Access: public

[ Top ]

contains   [line 273]

boolean contains( object Statement &$statement)

Tests if the Model_Memory contains the given triple.

TRUE if the triple belongs to the Model_Memory; FALSE otherwise. To improve the search speed with big Model_Memorys, call index() before seaching.

  • Access: public

Parameters:

object Statement   &$statement   — 

[ Top ]

containsAll   [line 310]

boolean containsAll( object Model &$model)

Determine if all of the statements in a model are also contained in this Model_Memory.

True if all of the statements in $model are also contained in this Model_Memory and false otherwise.

  • Access: public

Parameters:

object Model   &$model   — 

[ Top ]

containsAny   [line 336]

boolean containsAny( object Model &$model)

Determine if any of the statements in a model are also contained in this Model_Memory.

True if any of the statements in $model are also contained in this Model_Memory and false otherwise.

  • Access: public

Parameters:

object Model   &$model   — 

[ Top ]

equals   [line 727]

boolean equals( object model &$that)

Checks if two models are equal.

Two models are equal if and only if the two RDF graphs they represent are isomorphic.

Warning: This method doesn't work correct with models where the same blank node has different identifiers in the two models. We will correct this in a future version.

  • Throws: phpErrpr
  • Access: public

Parameters:

object model   &$that   — 

[ Top ]

find   [line 413]

object Model_Memory find( object Node $subject, object Node $predicate, object Node $object)

General method to search for triples.

null input for any parameter will match anything. Example: $result = $m->find( null, null, $node ); Finds all triples with $node as object. Returns an empty Model_Memory if nothing is found. To improve the search speed with big Model_Memorys, call index() before seaching.

  • Throws: PhpError
  • Access: public

Parameters:

object Node   $subject   — 
object Node   $predicate   — 
object Node   $object   — 

[ Top ]

findCount   [line 571]

integer findCount( object Node $subject, object Node $predicate, object Node $object)

Searches for triples and returns the number of matches.

null input for any parameter will match anything. Example: $result = $m->findCount( null, null, $node ); Finds all triples with $node as object.

  • Access: public

Parameters:

object Node   $subject   — 
object Node   $predicate   — 
object Node   $object   — 

[ Top ]

findFirstMatchingStatement   [line 546]

object Statement findFirstMatchingStatement( object Node $subject, object Node $predicate, object Node $object)

Searches for triples and returns the first matching statement.

null input for any parameter will match anything. Example: $result = $m->findFirstMatchingStatement( null, null, $node ); Returns the first statement of the Model_Memory where the object equals $node. Returns an null if nothing is found.

  • Access: public

Parameters:

object Node   $subject   — 
object Node   $predicate   — 
object Node   $object   — 

[ Top ]

findRegex   [line 474]

object Model_Memory findRegex( string $subject_regex, string $predicate_regex, string $object_regex)

Method to search for triples using Perl-style regular expressions.

null input for any parameter will match anything. Example: $result = $m->find_regex( null, null, $regex ); Finds all triples where the label of the object node matches the regular expression. Returns an empty Model_Memory if nothing is found.

  • Access: public

Parameters:

string   $subject_regex   — 
string   $predicate_regex   — 
string   $object_regex   — 

[ Top ]

findVocabulary   [line 511]

object Model_Memory findVocabulary( string $vocabulary)

Returns all tripels of a certain vocabulary.

$vocabulary is the namespace of the vocabulary inluding a # : / char at the end. e.g. http://www.w3.org/2000/01/rdf-schema# Returns an empty Model_Memory if nothing is found.

  • Access: public

Parameters:

string   $vocabulary   — 

[ Top ]

getStatementIterator   [line 953]

object StatementIterator &getStatementIterator( )

Returns a StatementIterator for traversing the Model_Memory.
  • Access: public

[ Top ]

getUniqueResourceURI   [line 690]

string getUniqueResourceURI( string $prefix)

Internal method, that returns a resource URI that is unique for the Model_Memory.

URIs are generated using the base_uri of the Model_Memory, the prefix and a unique number.

  • Access: protected

Parameters:

string   $prefix   — 

[ Top ]

index   [line 365]

void index( )

Builds a search index for the statements in the Model_Memory.

The index is used by the find() and contains() functions. Performance example using a model with 43000 statements on a Linux machine: Find without index takes 1.7 seconds. Indexing takes 1.8 seconds. Find with index takes 0.001 seconds. So if you want to query a model more then once, build a index first.

  • Access: public

[ Top ]

intersect   [line 854]

object Model_Memory &intersect( &$model, object Model $model)

Returns a new Model_Memory containing all the statements which are in both this Model_Memory and another.
  • Throws: phpErrpr
  • Access: public

Parameters:

object Model   $model   — 
   &$model   — 

[ Top ]

isEmpty   [line 94]

boolean isEmpty( )

Checks if Model_Memory is empty
  • Access: public

[ Top ]

isIndexed   [line 393]

boolean isIndexed( )

Returns TRUE if the Model_Memory is indexed.
  • Access: public

[ Top ]

matchStatement   [line 646]

boolean matchStatement( object Statement $statement, object Node $subject, object Node $predicate, object Node $object)

Internal method that checks, if a statement matches a S, P, O or null combination.

null input for any parameter will match anything.

  • Access: protected

Parameters:

object Statement   $statement   — 
object Node   $subject   — 
object Node   $predicate   — 
object Node   $object   — 

[ Top ]

reify   [line 933]

object Model_Memory &reify( )

Reifies the Model_Memory.

Returns a new Model_Memory that contains the reifications of all statements of this Model_Memory.

  • Access: public

[ Top ]

remove   [line 153]

void remove( object Statement $statement)

Removes the triple from the Model_Memory.
  • Throws: PhpError
  • Access: public

Parameters:

object Statement   $statement   — 

[ Top ]

replace   [line 594]

void replace( object Node $subject, object Node $predicate, object Node $object, object Node $replacement)

General method to replace nodes of a Model_Memory.

null input for any parameter will match nothing. Example: $m->replace($node, null, $node, $replacement); Replaces all $node objects beeing subject or object in any triple of the Model_Memory with the $needle node.

  • Throws: PhpError
  • Access: public

Parameters:

object Node   $subject   — 
object Node   $predicate   — 
object Node   $object   — 
object Node   $replacement   — 

[ Top ]

saveAs   [line 246]

boolean saveAs( string $filename, [string $type = 'rdf'])

Saves the RDF,N3 or N-Triple serialization of the Model_Memory to a file.

You can decide to which format the model should be serialized by using a corresponding suffix-string as $type parameter. If no $type parameter is placed this method will serialize the model to XML/RDF format. Returns FALSE if the Model_Memory couldn't be saved to the file.

  • Access: public

Parameters:

string   $filename   — 
string   $type   — 

[ Top ]

setBaseURI   [line 66]

void setBaseURI( string $uri)

Set a base URI for the Model_Memory.

Affects creating of new resources and serialization syntax. If the URI doesn't end with # : or /, then a # is added to the URI.

  • Access: public

Parameters:

string   $uri   — 

[ Top ]

size   [line 83]

integer size( )

Number of triples in the Model_Memory
  • Access: public

[ Top ]

subtract   [line 815]

object Model_Memory &subtract( &$model, object Model $model)

Returns a new Model_Memory that is the subtraction of another model from this Model_Memory.
  • Throws: phpErrpr
  • Access: public

Parameters:

object Model   $model   — 
   &$model   — 

[ Top ]

toString   [line 175]

string toString( )

Short Dump of the Model_Memory.
  • Access: public

Overrides RDF_Object::toString() (Serializes a object into a string)
[ Top ]

toStringIncludingTriples   [line 186]

string toStringIncludingTriples( )

Dumps of the Model_Memory including all triples.
  • Access: public

[ Top ]

unite   [line 775]

object Model_Memory &unite( &$model, object Model $model)

Returns a new Model_Memory that is the set-union of the Model_Memory with another model.

Duplicate statements are removed. If you want to allow duplicates, use addModel() which is much faster.

The result of taking the set-union of two or more RDF graphs (i.e. sets of triples) is another graph, which we will call the merge of the graphs. Each of the original graphs is a subgraph of the merged graph. Notice that when forming a merged graph, two occurrences of a given uriref or literal as nodes in two different graphs become a single node in the union graph (since by definition they are the same uriref or literal) but blank nodes are not 'merged' in this way; and arcs are of course never merged. In particular, this means that every blank node in a merged graph can be identified as coming from one particular graph in the original set of graphs.

Notice that one does not, in general, obtain the merge of a set of graphs by concatenating their corresponding N-triples documents and constructing the graph described by the merged document, since if some of the documents use the same node identifiers, the merged document will describe a graph in which some of the blank nodes have been 'accidentally' merged. To merge Ntriples documents it is necessary to check if the same nodeID is used in two or more documents, and to replace it with a distinct nodeID in each of them, before merging the documents. (Not implemented yet !!!!!!!!!!!)

  • Throws: phpErrpr
  • Access: public

Parameters:

object Model   $model   — 
   &$model   — 

[ Top ]

writeAsHtml   [line 200]

void writeAsHtml( )

Writes the RDF serialization of the Model_Memory as HTML.
  • Access: public

[ Top ]

writeAsHtmlTable   [line 215]

void writeAsHtmlTable( )

Writes the RDF serialization of the Model_Memory as HTML table.
  • Access: public

[ Top ]

writeRDFToString   [line 226]

string writeRDFToString( )

Writes the RDF serialization of the Model_Memory as HTML table.
  • Access: public

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:39:28 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.