Source for file ResContainer.php
Documentation is available at ResContainer.php
// ----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------
* This Class defines methods for accessing RDF container resources.
* These methods operate on the RDF statements contained in a model.
* @version $Id: fsource_resModel__resModelResContainer.php.html 443 2007-06-01 16:25:38Z cax $
* @author Daniel Westphal <mail at d-westphal dot de>
* Holds a ResResource of this container type rdf:Seq, rdf:Alt, or rdf:Bag
* Add a new value to a container.
* The new value is added as the last element of the container.
* @param object ResResource/ResLiteral $object
//type this container, if it isn't already typed
$actualSize=
$this->size();
//add the object to the last position
* Determine whether the container contains a value
* @param obejct ResResource/ResLiteral $resResource
//get all container's properties
//if the property matches a container membership property
if ($this->_predicateLabelMatchesMembershipProperty($statement->getLabelPredicate()))
//check, if it's the value, we're looking for.
if ($resResource->equals($statement->getObject()))
* Returns true, if this resource is a container from type rdf:Alt
* Returns true, if this resource is a container from type rdf:Bag
* Returns true, if this resource is a container from type rdf:Seq
* Get an array of all resources that are values of this container
$predicateLabel=
$statement->getLabelPredicate();
if ($this->_predicateLabelMatchesMembershipProperty($predicateLabel))
$return[$this->_getMemberIndexNrFromMembershipPropertyLabel($predicateLabel)] =
$statement->getObject();
* Remove a value from the container.
* Once removed, the values in the container with a higher ordinal value are renumbered.
* The renumbering algorithm depends on the type of container.
* @param obejct ResResource/ResLiteral $resResource
$deleteFromIndex=
array();
//get all container members
//check each container member if it equals the resoure to be removed
foreach ($memberIndex as $key =>
$value)
//save the statements positio in the container
if($object->equals($value))
//delete all found container members
foreach ($deleteFromIndex as $index)
$this->removeAll($this->_getMembershipPropertyWithIndex($index));
//renumber all members with higher ordinal numbers than the deleted one
for ($i =
$index;$i <
count($memberIndex); $i++
)
$this->removeAll($this->_getMembershipPropertyWithIndex($i+
1));
$this->addProperty($this->_getMembershipPropertyWithIndex($i),$memberIndex[$i+
1]);
* Returns the number values in the container.
* Checks, if a predicate label fits a container membership property rdf:_n
* @param string $predicateLabel
function _predicateLabelMatchesMembershipProperty($predicateLabel)
* Get the ordinal number from a membership property rdf:_n
* @param string $predicateLabel
function _getMemberIndexNrFromMembershipPropertyLabel($predicateLabel)
* Get a membership property rdf:_n with index $int
function _getMembershipPropertyWithIndex($int)
Documentation generated on Fri, 1 Jun 2007 16:51:23 +0200 by phpDocumentor 1.3.2