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