3 * An interface for criterias
5 * @author Roland Haeder <webmaster@shipsimu.org>
7 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2013 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 * Add "choice" criteria, this method converts dashes to underscores because
108 * dashes are not valid for criteria keys.
110 * @param $criteriaKey Criteria key
111 * @param $criteriaValue Criteria value
114 function addChoiceCriteria ($criteriaKey, $criteriaValue);
117 * Add "exclude" criteria, this method converts dashes to underscores because
118 * dashes are not valid for criteria keys.
120 * @param $criteriaKey Criteria key
121 * @param $criteriaValue Criteria value
124 function addExcludeCriteria ($criteriaKey, $criteriaValue);
127 * Add configured criteria
129 * @param $criteriaKey Criteria key
130 * @param $configEntry Configuration entry
131 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
134 function addConfiguredCriteria ($criteriaKey, $configEntry, $criteriaType = 'default');
137 * Get criteria element or FALSE if not found
139 * @param $criteriaKey The requested criteria key
140 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
141 * @return $value Whether the value of the critera or FALSE
143 function getCriteriaElemnent ($criteriaKey, $criteriaType = 'default');
146 * Get criteria element or FALSE if not found for 'choice' type
148 * @param $criteriaKey The requested criteria key
149 * @return $value Whether the value of the critera or FALSE
151 function getCriteriaChoiceElemnent ($criteriaKey);
154 * Get criteria element or FALSE if not found for 'exclude' type
156 * @param $criteriaKey The requested criteria key
157 * @return $value Whether the value of the critera or FALSE
159 function getCriteriaExcludeElemnent ($criteriaKey);
162 * Checks whether given array entry matches
164 * @param $entryArray Array with the entries to find
165 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
166 * @return $matches Whether the entry matches or not
168 function ifEntryMatches (array $entryArray, $criteriaType = 'default');
171 * Checks whether given array 'choice' entry matches
173 * @param $entryArray Array with the entries to find
174 * @return $matches Whether the entry matches or not
176 function ifChoiceMatches (array $entryArray);
179 * Checks whether given array 'exclude' entry matches
181 * @param $entryArray Array with the entries to find
182 * @return $matches Whether the entry matches or not
184 function ifExcludeMatches (array $entryArray);
187 * "Getter" for a cache key
189 * @param $onlyKeys Only use these keys for a cache key
190 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
191 * @return $cacheKey The key suitable for the cache system
193 function getCacheKey ($onlyKeys = array(), $criteriaType = 'default');
196 * "Getter" for a cache key ('choice' type)
198 * @param $onlyKeys Only use these keys for a cache key
199 * @return $cacheKey The key suitable for the cache system
201 function getCacheKeyChoice ($onlyKeys = array());
204 * "Getter" for a cache key ('exclude' type)
206 * @param $onlyKeys Only use these keys for a cache key
207 * @return $cacheKey The key suitable for the cache system
209 function getCacheKeyExclude ($onlyKeys = array());
212 * Count the criteria, e.g. useful to find out if a database query has no
213 * limitation (search criteria).
215 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
216 * @return $count Count of all criteria entries
218 function count ($criteriaType = 'default');
221 * Count 'choice' criteria, e.g. useful to find out if a database query
222 * has no limitation (search criteria).
224 * @return $count Count of all criteria entries
226 function countChoice ();
229 * Count 'exclude' criteria, e.g. useful to find out if a database query
230 * has no limitation (search criteria).
232 * @return $count Count of all criteria entries
234 function countExclude ();