Source for file Resource.php

Documentation is available at Resource.php

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

Documentation generated on Mon, 26 Jun 2006 14:26:10 +0200 by phpDocumentor 1.3.0RC6