3 * An interface for criterias
5 * @author Roland Haeder <webmaster@ship-simu.org>
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
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 * Getter for criteria array
43 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
46 function getCriteriaArray ($criteriaType = 'default');
49 * Getter for criteria array 'choice' type
53 function getCriteriaChoiceArray ();
56 * Getter for criteria array 'exclude' type
60 function getCriteriaExcludeArray ();
63 * Add criteria, this method converts dashes to underscores because dashes
64 * are not valid for criteria keys.
66 * @param $criteriaKey Criteria key
67 * @param $criteriaValue Criteria value
68 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
71 function addCriteria ($criteriaKey, $criteriaValue, $criteriaType = 'default');
74 * Add "choice" criteria, this method converts dashes to underscores because
75 * dashes are not valid for criteria keys.
77 * @param $criteriaKey Criteria key
78 * @param $criteriaValue Criteria value
81 function addChoiceCriteria ($criteriaKey, $criteriaValue);
84 * Add "exclude" criteria, this method converts dashes to underscores because
85 * dashes are not valid for criteria keys.
87 * @param $criteriaKey Criteria key
88 * @param $criteriaValue Criteria value
91 function addExcludeCriteria ($criteriaKey, $criteriaValue);
94 * Add configured criteria
96 * @param $criteriaKey Criteria key
97 * @param $configEntry Configuration entry
98 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
101 function addConfiguredCriteria ($criteriaKey, $configEntry, $criteriaType = 'default');
104 * Get criteria element or null if not found
106 * @param $criteriaKey The requested criteria key
107 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
108 * @return $value Whether the value of the critera or null
110 function getCriteriaElemnent ($criteriaKey, $criteriaType = 'default');
113 * Checks whether given array entry matches
115 * @param $entryArray Array with the entries to find
116 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
117 * @return $matches Whether the entry matches or not
119 function ifEntryMatches (array $entryArray, $criteriaType = 'default');
122 * Checks whether given array 'choice' entry matches
124 * @param $entryArray Array with the entries to find
125 * @return $matches Whether the entry matches or not
127 function ifChoiceMatches (array $entryArray);
130 * Checks whether given array 'exclude' entry matches
132 * @param $entryArray Array with the entries to find
133 * @return $matches Whether the entry matches or not
135 function ifExcludeMatches (array $entryArray);
138 * "Getter" for a cache key
140 * @param $onlyKeys Only use these keys for a cache key
141 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
142 * @return $cacheKey The key suitable for the cache system
144 function getCacheKey ($onlyKeys = array(), $criteriaType = 'default');
147 * "Getter" for a cache key ('choice' type)
149 * @param $onlyKeys Only use these keys for a cache key
150 * @return $cacheKey The key suitable for the cache system
152 function getCacheKeyChoice ($onlyKeys = array());
155 * "Getter" for a cache key ('exclude' type)
157 * @param $onlyKeys Only use these keys for a cache key
158 * @return $cacheKey The key suitable for the cache system
160 function getCacheKeyExclude ($onlyKeys = array());
163 * "Getter" for a cache key ('choice' type)
165 * @param $onlyKeys Only use these keys for a cache key
166 * @return $cacheKey The key suitable for the cache system
168 function getCacheKeyChoice ($onlyKeys = array());
171 * Count the criteria, e.g. useful to find out if a database query has no
172 * limitation (search criteria).
174 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
175 * @return $count Count of all criteria entries
177 function count ($criteriaType = 'default');
180 * Count 'choice' criteria, e.g. useful to find out if a database query
181 * has no limitation (search criteria).
183 * @return $count Count of all criteria entries
185 function countChoice ();
188 * Count 'exclude' criteria, e.g. useful to find out if a database query
189 * has no limitation (search criteria).
191 * @return $count Count of all criteria entries
193 function countExclude ();