2 * This file is part of NeverNote
\r
3 * Copyright 2009 Randy Baumgarte
\r
5 * This file may be licensed under the terms of of the
\r
6 * GNU General Public License Version 2 (the ``GPL'').
\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
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
21 package cx.fbn.nevernote.sql;
\r
23 import cx.fbn.nevernote.Global;
\r
24 import cx.fbn.nevernote.sql.requests.WordRequest;
\r
27 public class WordsTable {
\r
28 private final int id;
\r
31 public WordsTable(int i) {
\r
35 public void createTable() {
\r
36 WordRequest request = new WordRequest();
\r
37 request.requestor_id = id;
\r
38 request.type = WordRequest.Create_Table;
\r
39 Global.dbRunner.addWork(request);
\r
42 public void dropTable() {
\r
43 WordRequest request = new WordRequest();
\r
44 request.requestor_id = id;
\r
45 request.type = WordRequest.Drop_Table;
\r
46 Global.dbRunner.addWork(request);
\r
48 // Count unindexed notes
\r
49 public int getWordCount() {
\r
50 WordRequest request = new WordRequest();
\r
51 request.requestor_id = id;
\r
52 request.type = WordRequest.Get_Word_Count;
\r
53 Global.dbRunner.addWork(request);
\r
54 Global.dbClientWait(id);
\r
55 WordRequest req = Global.dbRunner.wordResponse.get(id).copy();
\r
56 return req.responseInt;
\r
59 // Clear out the word index table
\r
60 public void clearWordIndex() {
\r
61 WordRequest request = new WordRequest();
\r
62 request.requestor_id = id;
\r
63 request.type = WordRequest.Clear_Word_Index;
\r
64 Global.dbRunner.addWork(request);
\r
67 //********************************************************************************
\r
68 //********************************************************************************
\r
69 //* Support adding & deleting index words
\r
70 //********************************************************************************
\r
71 //********************************************************************************
\r
72 public void expungeFromWordIndex(String guid, String type) {
\r
73 WordRequest request = new WordRequest();
\r
74 request.requestor_id = id;
\r
75 request.type = WordRequest.Expunge_From_Word_Index;
\r
76 request.string1 = guid;
\r
77 request.string2 = type;
\r
78 Global.dbRunner.addWork(request);
\r
81 public synchronized void addWordToNoteIndex(String guid, String word, String type, Integer weight) {
\r
82 WordRequest request = new WordRequest();
\r
83 request.requestor_id = id;
\r
84 request.type = WordRequest.Add_Word_To_Note_Index;
\r
85 request.string1 = guid;
\r
86 request.string2 = word;
\r
87 request.string3 = type;
\r
88 request.int1 = weight;
\r
89 Global.dbRunner.addWork(request);
\r
90 Global.dbClientWait(id);
\r