3 * An interface for criterias
5 * @author Roland Haeder <webmaster@shipsimu.org>
7 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
8 * @license GNU GPL 3.0 or any newer version
9 * @link http://www.shipsimu.org
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.
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.
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/>.
24 interface Criteria extends FrameworkInterface {
26 * Setter for wrapper class name
28 * @param $wrapperConfigEntry Configuration entry which hold the wrapper class' name
31 function setWrapperConfigEntry ($wrapperConfigEntry);
34 * Getter for wrapper class name
36 * @return $wrapperConfigEntry Configuration entry which hold the wrapper class' name
38 function getWrapperConfigEntry ();
41 * Checks whether given key is set
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
47 function isKeySet ($criteriaType, $criteriaKey);
50 * Checks whether given key is set for 'choice' type
52 * @param $criteriaKey Criteria key
53 * @return $isSet Whether key is set
55 function isChoiceKeySet ($criteriaKey);
58 * Checks whether given key is set for 'exclude' type
60 * @param $criteriaKey Criteria key
61 * @return $isSet Whether key is set
63 function isExcludeKeySet ($criteriaKey);
66 * Getter for criteria array
68 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
71 function getCriteriaArray ($criteriaType = 'default');
74 * Getter for criteria array 'choice' type
78 function getCriteriaChoiceArray ();
81 * Getter for criteria array 'exclude' type
85 function getCriteriaExcludeArray ();
88 * Unsets a criteria key from all criteria types
90 * @param $criteriaKey Criteria key to unset
93 function unsetCriteria ($criteriaKey);
96 * Add criteria, this method converts dashes to underscores because dashes
97 * are not valid for criteria keys.
99 * @param $criteriaKey Criteria key
100 * @param $criteriaValue Criteria value
101 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
104 function addCriteria ($criteriaKey, $criteriaValue, $criteriaType = 'default');
107 * Sets criteria, this method converts dashes to underscores because dashes
108 * are not valid for criteria keys.
110 * @param $criteriaKey Criteria key
111 * @param $criteriaValue Criteria value
112 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
115 function setCriteria ($criteriaKey, $criteriaValue, $criteriaType = 'default');
118 * Add "choice" criteria, this method converts dashes to underscores because
119 * dashes are not valid for criteria keys.
121 * @param $criteriaKey Criteria key
122 * @param $criteriaValue Criteria value
125 function addChoiceCriteria ($criteriaKey, $criteriaValue);
128 * Add "exclude" criteria, this method converts dashes to underscores because
129 * dashes are not valid for criteria keys.
131 * @param $criteriaKey Criteria key
132 * @param $criteriaValue Criteria value
135 function addExcludeCriteria ($criteriaKey, $criteriaValue);
138 * Add configured criteria
140 * @param $criteriaKey Criteria key
141 * @param $configEntry Configuration entry
142 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
145 function addConfiguredCriteria ($criteriaKey, $configEntry, $criteriaType = 'default');
148 * Get criteria element or FALSE if not found
150 * @param $criteriaKey The requested criteria key
151 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
152 * @return $value Whether the value of the critera or FALSE
154 function getCriteriaElemnent ($criteriaKey, $criteriaType = 'default');
157 * Get criteria element or FALSE if not found for 'choice' type
159 * @param $criteriaKey The requested criteria key
160 * @return $value Whether the value of the critera or FALSE
162 function getCriteriaChoiceElemnent ($criteriaKey);
165 * Get criteria element or FALSE if not found for 'exclude' type
167 * @param $criteriaKey The requested criteria key
168 * @return $value Whether the value of the critera or FALSE
170 function getCriteriaExcludeElemnent ($criteriaKey);
173 * Checks whether given array entry matches
175 * @param $entryArray Array with the entries to find
176 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
177 * @return $matches Whether the entry matches or not
179 function ifEntryMatches (array $entryArray, $criteriaType = 'default');
182 * Checks whether given array 'choice' entry matches
184 * @param $entryArray Array with the entries to find
185 * @return $matches Whether the entry matches or not
187 function ifChoiceMatches (array $entryArray);
190 * Checks whether given array 'exclude' entry matches
192 * @param $entryArray Array with the entries to find
193 * @return $matches Whether the entry matches or not
195 function ifExcludeMatches (array $entryArray);
198 * "Getter" for a cache key
200 * @param $onlyKeys Only use these keys for a cache key
201 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
202 * @return $cacheKey The key suitable for the cache system
204 function getCacheKey ($onlyKeys = array(), $criteriaType = 'default');
207 * "Getter" for a cache key ('choice' type)
209 * @param $onlyKeys Only use these keys for a cache key
210 * @return $cacheKey The key suitable for the cache system
212 function getCacheKeyChoice ($onlyKeys = array());
215 * "Getter" for a cache key ('exclude' type)
217 * @param $onlyKeys Only use these keys for a cache key
218 * @return $cacheKey The key suitable for the cache system
220 function getCacheKeyExclude ($onlyKeys = array());
223 * Count the criteria, e.g. useful to find out if a database query has no
224 * limitation (search criteria).
226 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
227 * @return $count Count of all criteria entries
229 function count ($criteriaType = 'default');
232 * Count 'choice' criteria, e.g. useful to find out if a database query
233 * has no limitation (search criteria).
235 * @return $count Count of all criteria entries
237 function countChoice ();
240 * Count 'exclude' criteria, e.g. useful to find out if a database query
241 * has no limitation (search criteria).
243 * @return $count Count of all criteria entries
245 function countExclude ();