* * @package model * @access public * */ class Resource extends Node { /** * URIref to the resource * @var string * @access private */ var $uri; /** * Constructor * Takes an URI or a namespace/localname combination * * @param string $namespace_or_uri * @param string $localName * @access public */ function Resource($namespace_or_uri , $localName = NULL) { if ($localName == NULL) { $this->uri = $namespace_or_uri; } else { $this->uri = $namespace_or_uri . $localName; } } /** * Returns the URI of the resource. * @return string * @access public */ function getURI() { return $this->uri; } /** * Returns the label of the resource, which is the URI of the resource. * @access public * @return string */ function getLabel() { return $this->getURI(); } /** * Returns the namespace of the resource. May return null. * @access public * @return string */ function getNamespace() { // Import Package Utility include_once(RDFAPI_INCLUDE_DIR.PACKAGE_UTILITY); $rdfUtil = new RDFUtil(); return $rdfUtil->guessNamespace($this->uri); } /** * Returns the local name of the resource. * @access public * @return string */ function getLocalName() { // Import Package Utility include_once(RDFAPI_INCLUDE_DIR.PACKAGE_UTILITY); $rdfUtil = new RDFUtil(); return $rdfUtil->guessName($this->uri); } /** * Dumps resource. * @access public * @return string */ function toString() { return 'Resource("' . $this->uri .'")'; } /** * Checks if the resource equals another resource. * Two resources are equal, if they have the same URI * * @access public * @param object resource $that * @return boolean */ function equals ($that) { if ($this == $that) { return true; } if (($that == NULL) or !(is_a($that, 'Resource')) or (is_a($that, 'BlankNode'))) { return false; } if ($this->getURI() == $that->getURI()) { return true; } return false; } /** * Doing string magic in PHP5 * @return string String representation of this Resource */ function __toString() { return $this->toString(); } } ?>