public interface ISearch
disjunction == true. See also the Filter class.
Sort class.
resultMode. See also the Field
class.COUNT, COUNT DISTINCT, SUM, AVG, MAX, MIN. Note that fields with
column operators can not be mixed with fields that do not use column
operators.distinct to true in order to filter out
duplicate results.maxResults. (This can also be thought of as results per page.)
The first result can be specified using either firstResult or
page.
ISearch is intended to be an immutable interface and only
provides getters for each of the properties. The IMutableSearch
interface extends ISearch by adding setters for all the
properties.Filter,
Field,
Sort,
IMutableSearch| Modifier and Type | Field and Description |
|---|---|
static int |
RESULT_ARRAY
Value for result mode.
|
static int |
RESULT_AUTO
Value for result mode.
|
static int |
RESULT_LIST
Value for result mode.
|
static int |
RESULT_MAP
Value for result mode.
|
static int |
RESULT_SINGLE
Value for result mode.
|
| Modifier and Type | Method and Description |
|---|---|
List<String> |
getFetches() |
List<Field> |
getFields() |
List<Filter> |
getFilters() |
int |
getFirstResult()
Zero based index of first result record to return.
|
int |
getMaxResults()
The maximum number of records to return.
|
int |
getPage()
Zero based index of the page of records to return.
|
int |
getResultMode()
Result mode tells the search what form to use for the results.
|
Class<?> |
getSearchClass() |
List<Sort> |
getSorts() |
boolean |
isDisjunction() |
boolean |
isDistinct() |
static final int RESULT_AUTO
RESULT_AUTO the result mode is automatically determined
according to the following rules:
RESULT_MAP.
RESULT_SINGLE.
RESULT_ARRAY.
getResultMode(),
Constant Field Valuesstatic final int RESULT_ARRAY
RESULT_ARRAY returns each result as
an Object array (Object[]) with the entries corresponding to
the fields added to the search. Here's an example:
Search s = new Search(Person.class);
s.setResultMode(Search.RESULT_ARRAY);
s.addField("firstName");
s.addField("lastName");
for (Object[] array : dao.search(s)) {
System.out.println(array[0] + " " + array[1]);
}
getResultMode(),
Constant Field Valuesstatic final int RESULT_LIST
RESULT_LIST returns each result as a
list of Objects (List<Object> ). Here's an example:
Search s = new Search(Person.class);
s.setResultMode(Search.RESULT_LIST);
s.addField("firstName");
s.addField("lastName");
for (List<Object> list : dao.search(s)) {
System.out.println(list.get(0) + " " + list.get(1));
}
getResultMode(),
Constant Field Valuesstatic final int RESULT_MAP
RESULT_MAP returns each row as a map
with properties' names or keys for keys to the corresponding values.
Here's an example:
Search s = new Search(Person.class);
s.setResultMode(Search.RESULT_MAP;
s.addField("firstName");
s.addField("lastName", "ln");
for (Map<String, Object> map : dao.search(s)) {
System.out.println(map.get("firstName") + " " + map.get("ln"));
}
getResultMode(),
Constant Field Valuesstatic final int RESULT_SINGLE
RESULT_SINGLE - Exactly one field or
no fields must be specified to use this result mode. The result list
contains just the value of that property for each element. Here's an
example:
Search s = new Search(Person.class);
s.setResultMode(Search.RESULT_SINGLE);
s.addField("firstName");
for (Object name : dao.search(s)) {
System.out.println(name);
}
getResultMode(),
Constant Field Valuesint getFirstResult()
<= 0 for unspecified value.
int getMaxResults()
page.
<= 0 for unspecified value.
int getPage()
maxResults. If both page and
maxResults are specified (i.e. > 0), the first result
returned is calculated by page * maxResults.
firstResult has precedence over page. So if
firstResult is specified (i.e. > 0), page is
ignored.
<= 0 for unspecified value.
Class<?> getSearchClass()
boolean isDisjunction()
boolean isDistinct()
int getResultMode()
RESULT_AUTO, RESULT_ARRAY,
RESULT_LIST
, RESULT_MAP and RESULT_SINGLE
.RESULT_AUTO,
RESULT_ARRAY,
RESULT_LIST,
RESULT_MAP,
RESULT_SINGLECopyright © 2008-2013. All Rights Reserved.