source: indexers/trunk/mg/java/org/greenstone/mg/MGRetrieveWrapper.java@ 14423

Last change on this file since 14423 was 14423, checked in by xiao, 17 years ago

wrapper classes split from MGWrapper

File size: 3.8 KB
Line 
1/*
2 * MGRetrieveWrapper.java
3 * Copyright (C) 2002 New Zealand Digital Library, http://www.nzdl.org
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19package org.greenstone.mg;
20
21
22/** java wrapper class for access to mg in C
23 *
24 * the native side implemented in MGWrapperImpl.c
25 * uses MGQueryResult to hold the result of a query.
26 * the result of a getDocument is a String
27 * uses the jni
28 *
29 *@see MGQueryResult
30 */
31public class MGRetrieveWrapper {
32 /** the query result, filled in by runQuery */
33// protected MGQueryResult mg_query_result_ = null;
34
35 /** pointer to c MGWrapperData class - cached indexData and queryInfo */
36 protected long mg_data_ptr_ = 0;
37
38 static {
39 System.loadLibrary ("mgretrievejni");
40 initIDs ();
41 }
42
43 public MGRetrieveWrapper () { System.out.println("in MGRetrieveWrapper.java");
44// mg_query_result_ = new MGQueryResult ();
45 initCSide ();
46 }
47
48 /** initialises field and method IDs for java side to enable access on C side */
49 private static native void initIDs ();
50
51 /** initialises the mg_data_ptr_ */
52 private native boolean initCSide ();
53
54 /** unloads the data */
55 public native boolean unloadIndexData ();
56
57 /** sets the index to search - default is 'dtx' */
58 public native void setIndex (String index);
59
60 /** returns a document: number docnum at level level
61 * the base_dir and text_path paths should join together to provide
62 * the absolute location of the mg text files eg ..../index/text/demo
63 * returns the doc in utf-8
64 */
65 public native String getDocument (String base_dir, String text_dir, long docnum);
66
67
68// the following is for search service // query param methods
69//
70// /** if on=true, sets default casefolding on - it's off by default */
71// public native void setCase (boolean on);
72// /** if on=true, sets default stemming on - it's off by default */
73// public native void setStem (boolean on);
74// /** default is 50 */
75// public native void setMaxDocs (int num);
76// /** if on=true, a query returns term freq info - default is on */
77// public native void setReturnTerms (boolean on);
78// /** sets the default boolean operator - AND(=1)/OR(=0) */
79// public native void setMatchMode (int mode);
80//
81// /** returns a string with all the current query param settings */
82// public native String getQueryParams ();
83//
84// /** sets maxnumeric */
85// public native void setMaxNumeric (int maxnumeric);
86//
87// /** actually carry out the query.
88// * Use the set methods to set query results.
89// * Writes the result to query_result.
90// * - maintains state between requests as can be slow
91// * base_dir and index_path should join together to provide
92// * the absolute location of the mg index files eg ..../index/dtx/demo
93// * base_dir must end with a file separator (OS dependant)
94// */
95// public native void runQuery (String base_dir, String text_dir, String query_string);
96//
97//
98// /** get the result out of the wrapper */
99// public MGQueryResult getQueryResult () {
100// return mg_query_result_;
101// }
102}
Note: See TracBrowser for help on using the repository browser.