source: Dev/branches/rest-dojo-ui/server/rdfapi/model/Blanknode.php @ 274

Last change on this file since 274 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 2.6 KB
Line 
1<?php
2require_once RDFAPI_INCLUDE_DIR . 'model/Resource.php';
3
4// ----------------------------------------------------------------------------------
5// Class: BlankNode
6// ----------------------------------------------------------------------------------
7
8
9/**
10 * An RDF blank node.
11 * In model theory, blank nodes are considered to be drawn from some set of
12 * 'anonymous' entities which have no label but are unique to the graph.
13 * For serialization they are labeled with a URI or a _:X identifier.
14 *
15 *
16 * @version  $Id: Blanknode.php 453 2007-06-20 21:19:09Z cweiske $
17 * @authors Chris Bizer <chris@bizer.de>,
18 *          Radoslaw Oldakowski <radol@gmx.de>
19 *
20 * @package model
21 * @access      public
22 *
23 */
24 class BlankNode extends Resource {
25 
26   /**
27    * Constructor
28        * You can supply a label or You supply a model and a unique ID is gernerated.
29    *
30    * @param    mixed   $namespace_or_uri_or_model
31        * @param        string $localName
32        * @access       public
33    */
34    function BlankNode($namespace_or_uri_or_model , $localName = NULL) {
35               
36        if (is_a($namespace_or_uri_or_model, 'Model')) {
37                        // generate identifier
38                        $id = $namespace_or_uri_or_model->getUniqueResourceURI(BNODE_PREFIX);
39                       
40                        $this->uri = $id;
41
42                } else {
43                        // set identifier
44                        if ($localName == NULL) {
45                                $this->uri = $namespace_or_uri_or_model;
46                        } else {
47                                $this->uri = $namespace_or_uri_or_model . $localName;
48                    }
49                 }
50    }
51
52  /**
53   * Returns the ID of the blank node.
54   *
55   * @return    string
56   * @access    public 
57   */   
58  function getID() {
59                        return $this->uri;
60   }
61
62  /**
63   * Returns the ID of the blank node.
64   *
65   * @return    string
66   * @access    public 
67   */   
68  function getLabel() {
69                return $this->uri;
70   }
71
72  /**
73   * Dumps bNode.
74   *
75   * @access    public
76   * @return    string
77   */ 
78  function toString() {
79
80        return 'bNode("' . $this->uri . '")';
81  }
82       
83  /**
84   * Checks if two blank nodes are equal.
85   * Two blank nodes are equal, if they have the same temporary ID.
86   *
87   * @access    public
88   * @param             object  resource $that
89   * @return    boolean
90   */ 
91   function equals ($that) {
92       
93            if ($this == $that) {
94              return true;
95            }
96        if (($that == NULL) or !(is_a($that, 'BlankNode'))) {
97              return false;
98            }
99               
100                if ($this->getURI() == $that->getURI()) {
101              return true;
102            }
103       
104            return false;
105        }
106
107
108    /**
109    *   Doing string magic in PHP5
110    *   @return string String representation of this Blank Node
111    */
112    function __toString()
113    {
114        return $this->toString();
115    }
116
117} // end: BlankNode
118
119
120?>
Note: See TracBrowser for help on using the repository browser.