OSDN Git Service

5265b1dfe6b3724058fa78a98f8120d316ee2a4b
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / filters / EnSearch.java
1 /*\r
2  * This file is part of NeverNote \r
3  * Copyright 2009 Randy Baumgarte\r
4  * \r
5  * This file may be licensed under the terms of of the\r
6  * GNU General Public License Version 2 (the ``GPL'').\r
7  *\r
8  * Software distributed under the License is distributed\r
9  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either\r
10  * express or implied. See the GPL for the specific language\r
11  * governing rights and limitations.\r
12  *\r
13  * You should have received a copy of the GPL along with this\r
14  * program. If not, go to http://www.gnu.org/licenses/gpl.html\r
15  * or write to the Free Software Foundation, Inc.,\r
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
17  *\r
18 */\r
19 \r
20 \r
21 package cx.fbn.nevernote.filters;\r
22 \r
23 import java.util.ArrayList;\r
24 import java.util.List;\r
25 \r
26 import com.evernote.edam.type.Note;\r
27 import com.evernote.edam.type.Tag;\r
28 \r
29 import cx.fbn.nevernote.Global;\r
30 import cx.fbn.nevernote.sql.requests.EnSearchRequest;\r
31 \r
32 public class EnSearch {\r
33         \r
34 \r
35         private List<Note>                      matches;\r
36         public List<String>                     hilightWords;\r
37         int id;\r
38         \r
39         public EnSearch(int i, String s, List<Tag> t, int len, int weight) {\r
40                 id = i;\r
41                 if (s == null) \r
42                         return;\r
43                 if (s.trim().equals(""))\r
44                         return;\r
45                 \r
46                 matches = null;\r
47                 EnSearchRequest request = new EnSearchRequest();\r
48                 request.requestor_id = id;\r
49 //              request.type = DeletedItemRequest.Get_All;\r
50                 request.string1 = s;\r
51                 if (t!=null) {\r
52                         request.tags = new ArrayList<Tag>();\r
53                         for (int k=0; k<t.size(); k++) {\r
54                                 request.tags.add(t.get(k).deepCopy());\r
55                         }\r
56                 }\r
57                 request.int1 = len;\r
58                 request.int2 = weight;\r
59                 Global.dbRunner.addWork(request);\r
60                 Global.dbClientWait(id);\r
61                 EnSearchRequest req = Global.dbRunner.enSearchResponse.get(id);\r
62                 hilightWords = req.responseStrings;\r
63                 matches = req.responseNotes;\r
64         }\r
65                 \r
66         public List<Note> matchWords() {\r
67                 return matches;\r
68         }\r
69         \r
70 \r
71 \r
72         \r
73 }\r