source: Dev/branches/rest-dojo-ui/jos-branch/server/rdfapi/dataset/Quad.php @ 312

Last change on this file since 312 was 312, checked in by jkraaijeveld, 13 years ago
File size: 2.7 KB
Line 
1<?php
2// ----------------------------------------------------------------------------------
3// Class: Quad
4// ----------------------------------------------------------------------------------
5
6/**
7*
8* A Triple in a RDF dataset, consisting of four Jena Nodes: graphName,
9* subject, predicate, and object.
10*
11* @version  $Id$
12* @author Daniel Westphal (http://www.d-westphal.de)
13*
14* @package      dataset
15* @access       public
16**/
17class Quad 
18{
19       
20        /**
21        * Name of the NamedGraphMem.
22        *
23        * @var          Resource
24        * @access       private
25        */
26        var $graphName;
27       
28        /**
29        * Statement
30        *
31        * @var          Statement
32        * @access       private
33        */
34        var $statement;
35       
36        /**
37    * Constructor
38        * Creates a Quad from four Nodes.
39        *
40    * @param Resource
41    * @param Resource 
42    * @param Resource 
43    * @param Resource   
44        * @access       public
45    */         
46        function Quad($graphName,$subject,$predicate,$object)
47        {
48                if (!is_a($graphName, 'Resource'))
49                {
50                        $errmsg = RDFAPI_ERROR .
51                          '(class: Quad; method: new): Resource expected as graphName.';
52                        trigger_error($errmsg, E_USER_ERROR);
53                }
54                $this->statement=new Statement($subject,$predicate,$object);
55                $this->graphName=$graphName;
56        }
57       
58        /**
59    * Sets the graph name.
60    *
61    * @param Resource 
62        * @access       public
63    */ 
64        function setGraphName($graphName)
65        {
66                $this->graphName=$graphName;
67        }
68       
69        /**
70    * Returns the graph name.
71    *
72    * @return Resource
73        * @access       public
74    */
75        function getGraphName()
76        {
77                return $this->graphName;
78        }
79       
80        /**
81         * Return a human-readable (sort of) string "graphname { s p o . }"
82         * describing the quad.
83         *
84         * @return string
85         */
86        function toString()
87        {       
88                return 'GraphName('.$this->graphName->getLabel().') '.$this->statement->toString();
89        }
90               
91        /**
92    * Returns the subject.
93    *
94    * @return Resource
95        * @access       public
96    */
97        function getSubject()
98        {
99                return $this->statement->getSubject(); 
100        }
101               
102        /**
103    * Returns the predicate.
104    *
105    * @return Resource
106        * @access       public
107    */
108        function getPredicate()
109        {
110                return $this->statement->getPredicate();       
111        }
112               
113        /**
114    * Returns the object.
115    *
116    * @return Resource
117        * @access       public
118    */
119        function getObject()
120        {
121                return $this->statement->getObject();   
122        }
123               
124        /**
125    * Returns the statement(subject,predicate,object).
126    *
127    * @return statement
128        * @access       public
129    */
130        function getStatement()
131        {
132                return $this->statement;       
133        }
134               
135        /**
136    * Checks if two quads are equal.
137    *
138    * @param  Quad
139    * @return boolean
140        * @access       public
141    */
142        function equals($quad)
143        {
144                return ($this->graphName->equals($quad->getGraphName()) && $this->statement->equals($quad->getStatement()));   
145        }
146}
147?>
Note: See TracBrowser for help on using the repository browser.