922de3f7b83c5a3f3442b249f4e80bf0f62dad0e
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / ValueInterface.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
6 * All rights reserved
7 *
8 * This class is a backport of the corresponding class of FLOW3.
9 * All credits go to the v5 team.
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 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27
28 /**
29 * A generic holder for the value of a property. A Value object can be used
30 * without knowing the actual property type (STRING, DOUBLE, BINARY etc.).
31 *
32 * Any implementation of this interface must adhere to the following behavior:
33 *
34 * Two Value instances, v1 and v2, are considered equal if and only if:
35 * * v1.getType() == v2.getType(), and,
36 * * v1.getString().equals(v2.getString())
37 *
38 * Actually comparing two Value instances by converting them to string form may not
39 * be practical in some cases (for example, if the values are very large binaries).
40 * Consequently, the above is intended as a normative definition of Value equality
41 * but not as a procedural test of equality. It is assumed that implementations
42 * will have efficient means of determining equality that conform with the above
43 * definition. An implementation is only required to support equality comparisons on
44 * Value instances that were acquired from the same Session and whose contents have
45 * not been read. The equality comparison must not change the state of the Value
46 * instances even though the getString() method in the above definition implies a
47 * state change.
48 *
49 * The deprecated getStream() method and it's related exceptions and rules have been
50 * omitted in this PHP port of the API.
51 *
52 * @package Extbase
53 * @subpackage Persistence
54 * @version $Id$
55 */
56 interface Tx_Extbase_Persistence_ValueInterface {
57
58 /**
59 * Returns a string representation of this value.
60 *
61 * @return string A string representation of the value of this property.
62 * @throws Tx_Extbase_Persistence_Exception_ValueFormatException if conversion to a String is not possible.
63 * @throws Tx_Extbase_Persistence_Exception_RepositoryException if another error occurs.
64 */
65 public function getString();
66
67 /**
68 * Returns a Binary representation of this value. The Binary object in turn provides
69 * methods to access the binary data itself. Uses the standard conversion to binary
70 * (see JCR specification).
71 *
72 * @return \F3\PHPCR\BinaryInterface A Binary representation of this value.
73 * @throws Tx_Extbase_Persistence_Exception_RepositoryException if another error occurs.
74 */
75 public function getBinary();
76
77 /**
78 * Returns a long representation of this value.
79 *
80 * @return string A long representation of the value of this property.
81 * @throws Tx_Extbase_Persistence_Exception_ValueFormatException if conversion to a long is not possible.
82 * @throws Tx_Extbase_Persistence_Exception_RepositoryException if another error occurs.
83 */
84 public function getLong();
85
86 /**
87 * Returns a BigDecimal representation of this value.
88 *
89 * @return string A double representation of the value of this property.
90 * @throws Tx_Extbase_Persistence_Exception_ValueFormatException if conversion is not possible.
91 * @throws Tx_Extbase_Persistence_Exception_RepositoryException if another error occurs.
92 */
93 public function getDecimal();
94
95 /**
96 * Returns a double representation of this value.
97 *
98 * @return string A double representation of the value of this property.
99 * @throws Tx_Extbase_Persistence_Exception_ValueFormatException if conversion to a double is not possible.
100 * @throws Tx_Extbase_Persistence_Exception_RepositoryException if another error occurs.
101 */
102 public function getDouble();
103
104 /**
105 * Returns a \DateTime representation of this value.
106 *
107 * The object returned is a copy of the stored value, so changes to it are
108 * not reflected in internal storage.
109 *
110 * @return \DateTime A \DateTime representation of the value of this property.
111 * @throws Tx_Extbase_Persistence_Exception_ValueFormatException if conversion to a \DateTime is not possible.
112 * @throws Tx_Extbase_Persistence_Exception_RepositoryException if another error occurs.
113 */
114 public function getDate();
115
116 /**
117 * Returns a boolean representation of this value.
118 *
119 * @return string A boolean representation of the value of this property.
120 * @throws Tx_Extbase_Persistence_Exception_ValueFormatException if conversion to a boolean is not possible.
121 * @throws Tx_Extbase_Persistence_Exception_RepositoryException if another error occurs.
122 */
123 public function getBoolean();
124
125 /**
126 * Returns the type of this Value. One of:
127 * * PropertyType.STRING
128 * * PropertyType.DATE
129 * * PropertyType.BINARY
130 * * PropertyType.DOUBLE
131 * * PropertyType.LONG
132 * * PropertyType.BOOLEAN
133 * * PropertyType.NAME
134 * * PropertyType.PATH
135 * * PropertyType.REFERENCE
136 * * PropertyType.WEAKREFERENCE
137 * * PropertyType.URI
138 *
139 * The type returned is that which was set at property creation.
140 * @return integer The type of the value
141 */
142 public function getType();
143 }
144
145 ?>