Renamed Registry -> GenericRegistry to make it clear that this registry does
[core.git] / framework / main / interfaces / criteria / class_Criteria.php
1 <?php
2 // Own namespace
3 namespace Org\Mxchange\CoreFramework\Criteria;
4
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
7
8 /**
9  * An interface for criterias
10  *
11  * @author              Roland Haeder <webmaster@shipsimu.org>
12  * @version             0.0.0
13  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
14  * @license             GNU GPL 3.0 or any newer version
15  * @link                http://www.shipsimu.org
16  *
17  * This program is free software: you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation, either version 3 of the License, or
20  * (at your option) any later version.
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program. If not, see <http://www.gnu.org/licenses/>.
29  */
30 interface Criteria extends FrameworkInterface {
31         /**
32          * Setter for wrapper class name
33          *
34          * @param       $wrapperConfigEntry             Configuration entry which hold the wrapper class' name
35          * @return      void
36          */
37         function setWrapperConfigEntry ($wrapperConfigEntry);
38
39         /**
40          * Getter for wrapper class name
41          *
42          * @return      $wrapperConfigEntry             Configuration entry which hold the wrapper class' name
43          */
44         function getWrapperConfigEntry ();
45
46         /**
47          * Checks whether given key is set
48          *
49          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
50          * @param       $criteriaKey    Criteria key
51          * @return      $isSet                  Whether key is set
52          */
53         function isKeySet ($criteriaType, $criteriaKey);
54
55         /**
56          * Checks whether given key is set for 'choice' type
57          *
58          * @param       $criteriaKey    Criteria key
59          * @return      $isSet                  Whether key is set
60          */
61         function isChoiceKeySet ($criteriaKey);
62
63         /**
64          * Checks whether given key is set for 'exclude' type
65          *
66          * @param       $criteriaKey    Criteria key
67          * @return      $isSet                  Whether key is set
68          */
69         function isExcludeKeySet ($criteriaKey);
70
71         /**
72          * Getter for criteria array
73          *
74          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
75          * @return      $criteria
76          */
77         function getCriteriaArray ($criteriaType = 'default');
78
79         /**
80          * Getter for criteria array 'choice' type
81          *
82          * @return      $criteria
83          */
84         function getCriteriaChoiceArray ();
85
86         /**
87          * Getter for criteria array 'exclude' type
88          *
89          * @return      $criteria
90          */
91         function getCriteriaExcludeArray ();
92
93         /**
94          * Unsets a criteria key from all criteria types
95          *
96          * @param       $criteriaKey    Criteria key to unset
97          * @return      void
98          */
99         function unsetCriteria ($criteriaKey);
100
101         /**
102          * Add criteria, this method converts dashes to underscores because dashes
103          * are not valid for criteria keys.
104          *
105          * @param       $criteriaKey    Criteria key
106          * @param       $criteriaValue  Criteria value
107          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
108          * @return      void
109          */
110         function addCriteria ($criteriaKey, $criteriaValue, $criteriaType = 'default');
111
112         /**
113          * Sets criteria, this method converts dashes to underscores because dashes
114          * are not valid for criteria keys.
115          *
116          * @param       $criteriaKey    Criteria key
117          * @param       $criteriaValue  Criteria value
118          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
119          * @return      void
120          */
121         function setCriteria ($criteriaKey, $criteriaValue, $criteriaType = 'default');
122
123         /**
124          * Add "choice" criteria, this method converts dashes to underscores because
125          * dashes are not valid for criteria keys.
126          *
127          * @param       $criteriaKey    Criteria key
128          * @param       $criteriaValue  Criteria value
129          * @return      void
130          */
131         function addChoiceCriteria ($criteriaKey, $criteriaValue);
132
133         /**
134          * Add "exclude" criteria, this method converts dashes to underscores because
135          * dashes are not valid for criteria keys.
136          *
137          * @param       $criteriaKey    Criteria key
138          * @param       $criteriaValue  Criteria value
139          * @return      void
140          */
141         function addExcludeCriteria ($criteriaKey, $criteriaValue);
142
143         /**
144          * Add configured criteria
145          *
146          * @param       $criteriaKey    Criteria key
147          * @param       $configEntry    Configuration entry
148          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
149          * @return      void
150          */
151         function addConfiguredCriteria ($criteriaKey, $configEntry, $criteriaType = 'default');
152
153         /**
154          * Get criteria element or false if not found
155          *
156          * @param       $criteriaKey    The requested criteria key
157          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
158          * @return      $value                  Whether the value of the critera or false
159          */
160         function getCriteriaElemnent ($criteriaKey, $criteriaType = 'default');
161
162         /**
163          * Get criteria element or false if not found for 'choice' type
164          *
165          * @param       $criteriaKey    The requested criteria key
166          * @return      $value                  Whether the value of the critera or false
167          */
168         function getCriteriaChoiceElemnent ($criteriaKey);
169
170         /**
171          * Get criteria element or false if not found for 'exclude' type
172          *
173          * @param       $criteriaKey    The requested criteria key
174          * @return      $value                  Whether the value of the critera or false
175          */
176         function getCriteriaExcludeElemnent ($criteriaKey);
177
178         /**
179          * Checks whether given array entry matches
180          *
181          * @param       $entryArray             Array with the entries to find
182          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
183          * @return      $matches                Whether the entry matches or not
184          */
185         function ifEntryMatches (array $entryArray, $criteriaType = 'default');
186
187         /**
188          * Checks whether given array 'choice' entry matches
189          *
190          * @param       $entryArray             Array with the entries to find
191          * @return      $matches                Whether the entry matches or not
192          */
193         function ifChoiceMatches (array $entryArray);
194
195         /**
196          * Checks whether given array 'exclude' entry matches
197          *
198          * @param       $entryArray             Array with the entries to find
199          * @return      $matches                Whether the entry matches or not
200          */
201         function ifExcludeMatches (array $entryArray);
202
203         /**
204          * "Getter" for a cache key
205          *
206          * @param       $onlyKeys       Only use these keys for a cache key
207          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
208          * @return      $cacheKey       The key suitable for the cache system
209          */
210         function getCacheKey ($onlyKeys = array(), $criteriaType = 'default');
211
212         /**
213          * "Getter" for a cache key ('choice' type)
214          *
215          * @param       $onlyKeys       Only use these keys for a cache key
216          * @return      $cacheKey       The key suitable for the cache system
217          */
218         function getCacheKeyChoice ($onlyKeys = array());
219
220         /**
221          * "Getter" for a cache key ('exclude' type)
222          *
223          * @param       $onlyKeys       Only use these keys for a cache key
224          * @return      $cacheKey       The key suitable for the cache system
225          */
226         function getCacheKeyExclude ($onlyKeys = array());
227
228         /**
229          * Count the criteria, e.g. useful to find out if a database query has no
230          * limitation (search criteria).
231          *
232          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
233          * @return      $count  Count of all criteria entries
234          */
235         function count ($criteriaType = 'default');
236
237         /**
238          * Count 'choice' criteria, e.g. useful to find out if a database query
239          * has no limitation (search criteria).
240          *
241          * @return      $count  Count of all criteria entries
242          */
243         function countChoice ();
244
245         /**
246          * Count 'exclude' criteria, e.g. useful to find out if a database query
247          * has no limitation (search criteria).
248          *
249          * @return      $count  Count of all criteria entries
250          */
251         function countExclude ();
252
253 }