Source for file Resource.php

Documentation is available at Resource.php

  1. <?php
  2. require_once RDFAPI_INCLUDE_DIR 'model/Node.php';
  3.  
  4. // ----------------------------------------------------------------------------------
  5. // Class: Resource
  6. // ----------------------------------------------------------------------------------
  7.  
  8. /**
  9.  * An RDF resource.
  10.  * Every RDF resource must have a URIref.
  11.  * URIrefs are treated as logical constants, i.e. as names which denote something
  12.  * (the things are called 'resources', but no assumptions are made about the nature of resources.)
  13.  * Many RDF resources are pieces of vocabulary. They typically have a namespace
  14.  * and a local name. In this case, a URI is composed as a
  15.  * concatenation of the namespace and the local name.
  16.  *
  17.  *
  18.  * @version  $Id: fsource_model__modelResource.php.html 443 2007-06-01 16:25:38Z cax $
  19.  * @author Chris Bizer <chris@bizer.de>
  20.  *
  21.  * @package model
  22.  * @access    public
  23.  *
  24.  */
  25.  class Resource extends Node {
  26.  
  27.      /**
  28.     * URIref to the resource
  29.     * @var        string 
  30.     * @access    private
  31.     */
  32.     var $uri;
  33.  
  34.  
  35.    /**
  36.     * Constructor
  37.     * Takes an URI or a namespace/localname combination
  38.     *
  39.     * @param    string    $namespace_or_uri 
  40.      * @param string $localName 
  41.     * @access    public
  42.     */
  43.     function Resource($namespace_or_uri $localName NULL{
  44.         if ($localName == NULL{
  45.             $this->uri $namespace_or_uri;
  46.           else {
  47.             $this->uri $namespace_or_uri $localName;
  48.           }
  49.     }
  50.  
  51.  
  52.   /**
  53.    * Returns the URI of the resource.
  54.    * @return string 
  55.    * @access    public
  56.    */
  57.   function getURI({
  58.               return $this->uri;
  59.    }
  60.  
  61.     /**
  62.      * Returns the label of the resource, which is the URI of the resource.
  63.      * @access    public
  64.      * @return string 
  65.      */
  66.     function getLabel({
  67.         return $this->getURI();
  68.     }
  69.  
  70.   /**
  71.    * Returns the namespace of the resource. May return null.
  72.    * @access    public
  73.    * @return string 
  74.    */
  75.   function getNamespace({
  76.       // Import Package Utility
  77.        include_once(RDFAPI_INCLUDE_DIR.PACKAGE_UTILITY);
  78.  
  79.        return RDFUtil::guessNamespace($this->uri);
  80.   }
  81.  
  82.   /**
  83.    * Returns the local name of the resource.
  84.    * @access    public
  85.    * @return string 
  86.    */
  87.     function getLocalName({
  88.         // Import Package Utility
  89.            include_once(RDFAPI_INCLUDE_DIR.PACKAGE_UTILITY);
  90.  
  91.         return RDFUtil::guessName($this->uri);
  92.       }
  93.  
  94.   /**
  95.    * Dumps resource.
  96.    * @access    public
  97.    * @return string 
  98.    */
  99.   function toString({
  100.     return 'Resource("' $this->uri .'")';
  101.   }
  102.  
  103.   /**
  104.    * Checks if the resource equals another resource.
  105.    * Two resources are equal, if they have the same URI
  106.    *
  107.    * @access    public
  108.    * @param        object    resource $that 
  109.    * @return    boolean 
  110.    */
  111.    function equals ($that{
  112.  
  113.         if ($this == $that{
  114.           return true;
  115.         }
  116.  
  117.         if (($that == NULLor !(is_a($that'Resource')) or (is_a($that'BlankNode'))) {
  118.           return false;
  119.         }
  120.  
  121.         if ($this->getURI(== $that->getURI()) {
  122.           return true;
  123.         }
  124.  
  125.         return false;
  126.     }
  127.  
  128.  
  129. }
  130.  
  131. ?>

Documentation generated on Fri, 1 Jun 2007 16:51:37 +0200 by phpDocumentor 1.3.2