source: trunk/mgpp/java/org/greenstone/mgpp/MGPPWrapper.java@ 10072

Last change on this file since 10072 was 4214, checked in by kjdon, 21 years ago

fixed up some left over stuff from changing the mgpp basepath stuff (to make it work on windows)

  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1
2package org.greenstone.mgpp;
3
4import java.util.Vector;
5
6/** java wrapper class for access to mgpp in C++
7 *
8 * the native side implemented in MGPPWrapperImpl.cpp
9 * uses MGPPQueryResult to hold the result of a query. the
10 * result of a getDocument is a String
11 * uses the jni
12 *
13 *@see MGPPQueryResult
14 */
15public class MGPPWrapper {
16
17 /** the query result
18 * will be filled in by runQuery
19 */
20 protected MGPPQueryResult mgpp_query_result_=null;
21 /** pointer to c++ MGPPWrapperData class - cached indexData and queryInfo
22 */
23 protected long mgpp_data_ptr_=0;
24
25 static {
26 System.loadLibrary("mgppjni");
27 initIDs();
28 }
29
30 public MGPPWrapper() {
31 mgpp_query_result_ = new MGPPQueryResult();
32 initCppSide();
33 }
34
35 /** initialises field and method IDs for java side to enable access on
36 C++ side */
37 private static native void initIDs();
38
39 /** initialises the mgpp_data_ptr_ */
40 private native boolean initCppSide();
41
42 /** returns a document: number docnum at level level
43 * text_path path should provide
44 * the absolute location of the mgpp text files eg ..../index/text/demo
45 * returns the doc in utf-8
46 */
47 public native String getDocument(String text_path,
48 String level,
49 long docnum );
50
51 /** the public method - converts between utf-8 and unicode
52 */
53 // public String getDocument(String text_path,
54 // String level,
55 // long docnum ) {
56
57 //String utf8_doc = getUtF8Document(base_dir, text_path, level, docnum);
58
59 /** load up the data structure for index
60 * - maintains state between requests as can be slow
61 * index_path should provide
62 * the absolute location of the mgpp index files eg ..../index/tt/demo
63 */
64 public native boolean loadIndexData(String index_path);
65 /** unloads the data */
66 public native boolean unloadIndexData();
67
68 // query param methods
69
70 /** if on=true, sets default stemming on - its off by default*/
71 public native void setStem(boolean on);
72 /** if on=true, sets default casefolding on - its off by default */
73 public native void setCase(boolean on);
74 /** default is 50 */
75 public native void setMaxDocs(int num);
76 /** if on=true, sorts by rank, otherwise returns in build order -
77 default is on */
78 public native void setSortByRank(boolean on);
79 /** if on=true, a query returns term freq info - default is on */
80 public native void setReturnTerms(boolean on);
81 /** sets the granularity of the query - default 'Document' */
82 public native void setQueryLevel(String level);
83 /** sets the granularity of the result - default 'Document' */
84 public native void setReturnLevel(String level);
85 /** sets the default boolean operator - AND(=1)/OR(=0) */
86 public native void setMatchMode(int mode);
87
88 /** returns a string with all the current query param settings */
89 public native String getQueryParams();
90
91 /** actually carry out the query. Use the set methods to set any query
92 params
93 * writes the result to query_result
94 */
95 public native void runQuery(String query_string);
96
97 /** get the result out of the wrapper */
98 public MGPPQueryResult getQueryResult() {
99 return mgpp_query_result_;
100 }
101
102}
Note: See TracBrowser for help on using the repository browser.