80b5be04f9baa934f6d2de9aeb7ffd68c3fab473
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / Generic / Qom / Comparison.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Persistence\Generic\Qom;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2010-2013 Extbase Team (http://forge.typo3.org/projects/typo3v4-mvc)
8 * Extbase is a backport of TYPO3 Flow. All credits go to the TYPO3 Flow team.
9 * All rights reserved
10 *
11 * This script is part of the TYPO3 project. The TYPO3 project is
12 * free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
19 * A copy is found in the text file GPL.txt and important notices to the license
20 * from the author is found in LICENSE.txt distributed with these scripts.
21 *
22 *
23 * This script is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * This copyright notice MUST APPEAR in all copies of the script!
29 ***************************************************************/
30 /**
31 * Filters node-tuples based on the outcome of a binary operation.
32 *
33 * For any comparison, operand2 always evaluates to a scalar value. In contrast,
34 * operand1 may evaluate to an array of values (for example, the value of a multi-valued
35 * property), in which case the comparison is separately performed for each element
36 * of the array, and the Comparison constraint is satisfied as a whole if the
37 * comparison against any element of the array is satisfied.
38 *
39 * If operand1 and operand2 evaluate to values of different property types, the
40 * value of operand2 is converted to the property type of the value of operand1.
41 * If the type conversion fails, the query is invalid.
42 *
43 * If operator is not supported for the property type of operand1, the query is invalid.
44 *
45 * If operand1 evaluates to null (for example, if the operand evaluates the value
46 * of a property which does not exist), the constraint is not satisfied.
47 *
48 * The JCR_OPERATOR_EQUAL_TO operator is satisfied only if the value of operand1
49 * equals the value of operand2.
50 *
51 * The JCR_OPERATOR_NOT_EQUAL_TO operator is satisfied unless the value of
52 * operand1 equals the value of operand2.
53 *
54 * The JCR_OPERATOR_LESSS_THAN operator is satisfied only if the value of
55 * operand1 is ordered before the value of operand2.
56 *
57 * The JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO operator is satisfied unless the value
58 * of operand1 is ordered after the value of operand2.
59 *
60 * The JCR_OPERATOR_GREATER_THAN operator is satisfied only if the value of
61 * operand1 is ordered after the value of operand2.
62 *
63 * The JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO operator is satisfied unless the
64 * value of operand1 is ordered before the value of operand2.
65 *
66 * The JCR_OPERATOR_LIKE operator is satisfied only if the value of operand1
67 * matches the pattern specified by the value of operand2, where in the pattern:
68 * the character "%" matches zero or more characters, and
69 * the character "_" (underscore) matches exactly one character, and
70 * the string "\x" matches the character "x", and
71 * all other characters match themselves.
72 */
73 class Comparison implements \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface {
74
75 /**
76 * @var \TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface
77 */
78 protected $operand1;
79
80 /**
81 * @var integer
82 */
83 protected $operator;
84
85 /**
86 * @var mixed
87 */
88 protected $operand2;
89
90 /*
91 * @var string
92 */
93 protected $parameterIdentifier;
94
95 /**
96 * Constructs this Comparison instance
97 *
98 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface $operand1
99 * @param integer $operator one of \TYPO3\CMS\Extbase\Persistence\QueryInterface.OPERATOR_*
100 * @param mixed $operand2
101 */
102 public function __construct(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface $operand1, $operator, $operand2) {
103 $this->operand1 = $operand1;
104 $this->operator = $operator;
105 $this->operand2 = $operand2;
106 }
107
108 /**
109 * Gets the first operand.
110 *
111 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface the operand; non-null
112 */
113 public function getOperand1() {
114 return $this->operand1;
115 }
116
117 /**
118 * Gets the operator.
119 *
120 * @return string one of \TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelConstantsInterface.JCR_OPERATOR_*
121 */
122 public function getOperator() {
123 return $this->operator;
124 }
125
126 /**
127 * Gets the second operand.
128 *
129 * @return mixed the operand; non-null
130 */
131 public function getOperand2() {
132 return $this->operand2;
133 }
134
135 /**
136 * @param string $parameterIdentifier
137 * @return void
138 */
139 public function setParameterIdentifier($parameterIdentifier) {
140 $this->parameterIdentifier = $parameterIdentifier;
141 }
142
143 /**
144 * @return string
145 */
146 public function getParameterIdentifier() {
147 return $this->parameterIdentifier;
148 }
149 }