1
|
// $Id$
|
2
|
/**
|
3
|
|
4
|
* Copyright (C) 2009 EDIT
|
5
|
* European Distributed Institute of Taxonomy
|
6
|
* http://www.e-taxonomy.eu
|
7
|
*
|
8
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
9
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
10
|
*/
|
11
|
package eu.etaxonomy.cdm.persistence.query;
|
12
|
|
13
|
/**
|
14
|
*
|
15
|
*
|
16
|
* @author a.babadshanjan
|
17
|
* @created 03.03.2009
|
18
|
* @version 1.0
|
19
|
*/
|
20
|
public enum MatchMode {
|
21
|
EXACT("="),
|
22
|
LIKE("LIKE"),
|
23
|
BEGINNING("LIKE"),
|
24
|
ANYWHERE("LIKE"),
|
25
|
END("LIKE");
|
26
|
|
27
|
private String matchOperator;
|
28
|
|
29
|
MatchMode(String matchOperator){
|
30
|
this.matchOperator = matchOperator;
|
31
|
}
|
32
|
|
33
|
public String queryStringFrom(String queryString){
|
34
|
if(queryString == null){
|
35
|
return "";
|
36
|
}
|
37
|
queryString = queryString.replace('*', '%');
|
38
|
switch(this){
|
39
|
case BEGINNING:
|
40
|
return queryString + "%";
|
41
|
case ANYWHERE:
|
42
|
return "%" + queryString + "%";
|
43
|
case END:
|
44
|
return queryString + "%";
|
45
|
default:
|
46
|
return queryString;
|
47
|
}
|
48
|
}
|
49
|
|
50
|
public String getMatchOperator(){
|
51
|
return matchOperator;
|
52
|
}
|
53
|
}
|