1 | <?php
|
---|
2 | // ---------------------------------------------
|
---|
3 | // Class: QueryTriple
|
---|
4 | // ---------------------------------------------
|
---|
5 | require_once RDFAPI_INCLUDE_DIR . 'sparql/SparqlVariable.php';
|
---|
6 |
|
---|
7 | /**
|
---|
8 | * Represents a query triple with subject, predicate and object.
|
---|
9 | *
|
---|
10 | * @author Tobias Gauss <tobias.gauss@web.de>
|
---|
11 | * @version $Id$
|
---|
12 | * @license http://www.gnu.org/licenses/lgpl.html LGPL
|
---|
13 | *
|
---|
14 | * @package sparql
|
---|
15 | */
|
---|
16 | class QueryTriple extends Object
|
---|
17 | {
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * The QueryTriples Subject.
|
---|
21 | * Can be a BlankNode or Resource, string in
|
---|
22 | * case of a variable
|
---|
23 | * @var Node/string
|
---|
24 | */
|
---|
25 | protected $subject;
|
---|
26 |
|
---|
27 | /**
|
---|
28 | * The QueryTriples Predicate.
|
---|
29 | * Normally only a Resource, string in
|
---|
30 | * case of a variable
|
---|
31 | * @var Node/string
|
---|
32 | */
|
---|
33 | protected $predicate;
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * The QueryTriples Object.
|
---|
37 | * Can be BlankNode, Resource or Literal, string in
|
---|
38 | * case of a variable
|
---|
39 | * @var Node/string
|
---|
40 | */
|
---|
41 | protected $object;
|
---|
42 |
|
---|
43 |
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * Constructor
|
---|
47 | *
|
---|
48 | * @param Node $sub Subject
|
---|
49 | * @param Node $pred Predicate
|
---|
50 | * @param Node $ob Object
|
---|
51 | */
|
---|
52 | public function QueryTriple($sub,$pred,$ob)
|
---|
53 | {
|
---|
54 | $this->subject = $sub;
|
---|
55 | $this->predicate = $pred;
|
---|
56 | $this->object = $ob;
|
---|
57 | }
|
---|
58 |
|
---|
59 | /**
|
---|
60 | * Returns the Triples Subject.
|
---|
61 | *
|
---|
62 | * @return Node
|
---|
63 | */
|
---|
64 | public function getSubject()
|
---|
65 | {
|
---|
66 | return $this->subject;
|
---|
67 | }
|
---|
68 |
|
---|
69 | /**
|
---|
70 | * Returns the Triples Predicate.
|
---|
71 | *
|
---|
72 | * @return Node
|
---|
73 | */
|
---|
74 | public function getPredicate()
|
---|
75 | {
|
---|
76 | return $this->predicate;
|
---|
77 | }
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * Returns the Triples Object.
|
---|
81 | *
|
---|
82 | * @return Node
|
---|
83 | */
|
---|
84 | public function getObject()
|
---|
85 | {
|
---|
86 | return $this->object;
|
---|
87 | }
|
---|
88 |
|
---|
89 |
|
---|
90 |
|
---|
91 | /**
|
---|
92 | * Returns an array of all variables in this triple.
|
---|
93 | *
|
---|
94 | * @return array Array of variable names
|
---|
95 | */
|
---|
96 | public function getVariables()
|
---|
97 | {
|
---|
98 | $arVars = array();
|
---|
99 |
|
---|
100 | foreach (array('subject', 'predicate', 'object') as $strVar) {
|
---|
101 | if (SparqlVariable::isVariable($this->$strVar)) {
|
---|
102 | $arVars[] = $this->$strVar;
|
---|
103 | }
|
---|
104 | }
|
---|
105 |
|
---|
106 | return $arVars;
|
---|
107 | }//public function getVariables()
|
---|
108 |
|
---|
109 |
|
---|
110 |
|
---|
111 | public function __clone()
|
---|
112 | {
|
---|
113 | foreach (array('subject', 'predicate', 'object') as $strVar) {
|
---|
114 | if (is_object($this->$strVar)) {
|
---|
115 | $this->$strVar = clone $this->$strVar;
|
---|
116 | }
|
---|
117 | }
|
---|
118 | }//public function __clone()
|
---|
119 |
|
---|
120 | }//class QueryTriple extends Object
|
---|
121 |
|
---|
122 | // end class: QueryTriple.php
|
---|
123 | ?> |
---|