Source for file DatasetMem.php
Documentation is available at DatasetMem.php
require_once RDFAPI_INCLUDE_DIR .
'dataset/Dataset.php';
require_once RDFAPI_INCLUDE_DIR .
'dataset/NamedGraphMem.php';
require_once RDFAPI_INCLUDE_DIR .
'model/MemModel.php';
// ----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------
* In-memory implementation of a RDF dataset.
* A RDF dataset set is a collection of named RDF graphs.
* @version $Id: fsource_dataset__datasetDatasetMem.php.html 442 2007-06-01 16:19:26Z cax $
* @author Daniel Westphal (http://www.d-westphal.de)
* @author Chris Bizer <chris@bizer.de>
* Reference to a Memmodel that holds the default graph.
* Name of the DatasetMem.
* List of all NamedGraphs.
* You can supply a Dataset name.
// === Graph level methods ========================
* Sets the Datasets name.
$this->setName=
$datasetName;
* Returns the Datasets name.
* Adds a NamedGraph to the set. Will replace a NamedGraph with the same name that is already in the set.
$graphNameURI=
$graph->getGraphName();
$this->graphs[$graphNameURI]=
&$graph;
* Overwrites the existting default graph.
$this->defaultGraph=
&$graph;
* Returns a reference to the defaultGraph
return $this->defaultGraph;
* Returns true, if an defaultGraph exists. False otherwise .
return $this->defaultGraph !=
null;
* Removes a NamedGraph from the set. Nothing happens
* if no graph with that name is contained in the set.
unset
($this->graphs[$graphName]);
* Tells wether the Dataset contains a NamedGraph.
return isset
($this->graphs[$graphName]) ===
true;
* Returns the NamedGraph with a specific name from the Dataset.
* Changes to the graph will be reflected in the set.
* @return NamedGraphMem or NULL
if (!isset
($this->graphs[$graphName])) return NULL;
return $this->graphs[$graphName];
* Returns the names of the namedGraphs in this set as strings in an array.
* Creates a new NamedGraph and adds it to the set. An existing
* graph with the same name will be replaced.The name of the NamedGraph to be created ; must be an URI
$this->graphs[$graphName]=
new NamedGraphMem($graphName,$baseURI);
* Deletes all NamedGraphs from the set.
* Returns the number of NamedGraphs in the set. Empty graphs
return count($this->graphs);
* Returns the NamedGraph with a specific offset in the dataset.
* Changes to the graph will be reflected in the set.
* @return NamedGraphMem or null
function &getGraphWithOffset($offset)
foreach ($this->graphs as $graph)
* Returns an iterator over all {@link NamedGraph}s in the set.
* @return IteratorAllGraphsMem
require_once RDFAPI_INCLUDE_DIR .
'dataset/IteratorAllGraphsMem.php';
* Tells wether the set contains any NamedGraphs.
* Adds all named graphs of the other dataset to this dataset.
function addAll($otherDataset)
for($iterator =
$otherDataset->listNamedGraphs(); $iterator->valid(); $iterator->next())
$current=
$iterator->current();
$this->graphs[$current->getGraphName()]=
$current;
if ($otherDataset->hasDefaultGraph())
$this->defaultGraph =
$this->defaultGraph->unite($otherDataset->getDefaultGraph());
// === Quad level methods ========================
* Adds a quad to the Dataset. The argument must not contain any
* wildcards. If the quad is already present, nothing happens. A new
* named graph will automatically be created if necessary.
$graphName=
$quad->getGraphName();
$this->graphs[$graphName->getLabel()]->add($quad->getStatement());
* Tells wether the Dataset contains a quad or
* quads matching a pattern.
* @param Resource $graphName
* @param Resource $subject
* @param Resource $predicate
* @param Resource $object
function containsQuad($graphName,$subject,$predicate,$object)
return ($this->graphs[$graphName->getLabel()]->findFirstMatchingStatement($subject,$predicate,$object)!=
null);
foreach ($this->graphs as $graph)
if ($graph->findFirstMatchingStatement($subject,$predicate,$object)!=
null)
* Deletes a Quad from the RDF dataset.
$graphName=
$quad->getGraphName();
return ($this->graphs[$graphName->getLabel()]->remove($quad->getStatement())!=
null);
foreach ($this->graphs as $graph)
$graph->remove($quad->getStatement());
* Counts the Quads in the RDF dataset. Identical Triples in
* different NamedGraphs are counted individually.
foreach ($this->graphs as $graph)
* Finds Statements that match a quad pattern. The argument may contain
* @param Resource or Null
* @param Resource or Null
* @param Resource or Null
function &findInNamedGraphs($graph,$subject,$predicate,$object,$returnAsTriples =
false)
return $findGraph->iterFind($subject,$predicate,$object);
require_once RDFAPI_INCLUDE_DIR .
'dataset/IteratorFindQuadsMem.php';
* Finds Statements that match a pattern in the default Graph. The argument may contain
* @param Resource or Null
* @param Resource or Null
* @param Resource or Null
return $this->defaultGraph->iterFind($subject,$predicate,$object);
Documentation generated on Fri, 1 Jun 2007 16:48:42 +0200 by phpDocumentor 1.3.2