source: trunk/gsdl3/src/packages/mg/java/org/greenstone/mg/MGPassesWrapper.java@ 7452

Last change on this file since 7452 was 7452, checked in by kjdon, 20 years ago

tidied up the setting filename and basepath path stuff

  • Property svn:keywords set to Author Date Id Revision
File size: 2.5 KB
Line 
1/*
2 * MGPassesWrapper.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_passes in C
23 *
24 * the native side implemented in MGPassesWrapperImpl.c
25 */
26
27public class MGPassesWrapper
28{
29 static {
30 System.loadLibrary("mgpassjni");
31 initIDs();
32 }
33
34 private final char END_OF_DOCUMENT = (char) 2;
35
36 public MGPassesWrapper() {
37 initCSide();
38 }
39
40 /** initialises field and method IDs for java side to enable access on C side */
41 private static native void initIDs();
42
43 /** initialises any C side stuff */
44 private native boolean initCSide();
45
46 /** initialise the pass through the documents */
47 public native boolean init();
48
49 /** add a pass declaration */
50 public native void addPass(char pass_type, char pass_num);
51
52 /** set the base path */
53 public native void setBasePath(String basepath);
54 /** set the file name */
55 public native void setFileName(String filename);
56
57 public native void setStemOptions(String stemmer_type, int stem_method);
58
59 public native void setInvfLevel(char level);
60
61
62 /** process a Greenstone document, which may consist of many MG documents (seeparated by ^B */
63 public boolean processDocument(String docs_text) {
64 String [] docs = docs_text.split(String.valueOf(END_OF_DOCUMENT));
65 System.err.println("num docs split into "+docs.length);
66 for (int i=0; i<docs.length; i++) {
67 try {
68 processMGDocument(docs[i].getBytes("UTF-8"));
69 } catch (Exception e) {
70 e.printStackTrace();
71 }
72 }
73 return true;
74 }
75 /** process a MG document */
76 public native boolean processMGDocument(byte[] text);
77
78 /** finalise the pass through the documents */
79 public native boolean finish();
80}
Note: See TracBrowser for help on using the repository browser.