[TASK] Merge submodule version into core
[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 textfile 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 * Constructs this Comparison instance
92 *
93 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface $operand1
94 * @param integer $operator one of \TYPO3\CMS\Extbase\Persistence\QueryInterface.OPERATOR_*
95 * @param mixed $operand2
96 */
97 public function __construct(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface $operand1, $operator, $operand2) {
98 $this->operand1 = $operand1;
99 $this->operator = $operator;
100 $this->operand2 = $operand2;
101 }
102
103 /**
104 * Gets the first operand.
105 *
106 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface the operand; non-null
107 */
108 public function getOperand1() {
109 return $this->operand1;
110 }
111
112 /**
113 * Gets the operator.
114 *
115 * @return string one of \TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelConstantsInterface.JCR_OPERATOR_*
116 */
117 public function getOperator() {
118 return $this->operator;
119 }
120
121 /**
122 * Gets the second operand.
123 *
124 * @return mixed the operand; non-null
125 */
126 public function getOperand2() {
127 return $this->operand2;
128 }
129 }
130
131 ?>