Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.greenstone.mg
Class MGWrapper  view MGWrapper download MGWrapper.java

java.lang.Object
  extended byorg.greenstone.mg.MGWrapper

public class MGWrapper
extends java.lang.Object

java wrapper class for access to mg in C the native side implemented in MGWrapperImpl.c uses MGQueryResult to hold the result of a query. the result of a getDocument is a String uses the jni


Field Summary
protected  long mg_data_ptr_
          pointer to c MGWrapperData class - cached indexData and queryInfo
protected  MGQueryResult mg_query_result_
          the query result, filled in by runQuery
 
Constructor Summary
MGWrapper()
           
 
Method Summary
 java.lang.String getDocument(java.lang.String base_dir, java.lang.String text_dir, long docnum)
          returns a document: number docnum at level level the base_dir and text_path paths should join together to provide the absolute location of the mg text files eg ..../index/text/demo returns the doc in utf-8
 java.lang.String getQueryParams()
          returns a string with all the current query param settings
 MGQueryResult getQueryResult()
          get the result out of the wrapper
private  boolean initCSide()
          initialises the mg_data_ptr_
private static void initIDs()
          initialises field and method IDs for java side to enable access on C side
 void runQuery(java.lang.String base_dir, java.lang.String text_dir, java.lang.String query_string)
          actually carry out the query.
 void setCase(boolean on)
          if on=true, sets default casefolding on - it's off by default
 void setIndex(java.lang.String index)
          sets the index to search - default is 'dtx'
 void setMatchMode(int mode)
          sets the default boolean operator - AND(=1)/OR(=0)
 void setMaxDocs(int num)
          default is 50
 void setReturnTerms(boolean on)
          if on=true, a query returns term freq info - default is on
 void setSortByRank(boolean on)
          if on=true, sorts by rank, otherwise returns in build order - default is on
 void setStem(boolean on)
          if on=true, sets default stemming on - it's off by default
 boolean unloadIndexData()
          unloads the data
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mg_query_result_

protected MGQueryResult mg_query_result_
the query result, filled in by runQuery


mg_data_ptr_

protected long mg_data_ptr_
pointer to c MGWrapperData class - cached indexData and queryInfo

Constructor Detail

MGWrapper

public MGWrapper()
Method Detail

initIDs

private static void initIDs()
initialises field and method IDs for java side to enable access on C side


initCSide

private boolean initCSide()
initialises the mg_data_ptr_


getDocument

public java.lang.String getDocument(java.lang.String base_dir,
                                    java.lang.String text_dir,
                                    long docnum)
returns a document: number docnum at level level the base_dir and text_path paths should join together to provide the absolute location of the mg text files eg ..../index/text/demo returns the doc in utf-8


unloadIndexData

public boolean unloadIndexData()
unloads the data


setCase

public void setCase(boolean on)
if on=true, sets default casefolding on - it's off by default


setStem

public void setStem(boolean on)
if on=true, sets default stemming on - it's off by default


setMaxDocs

public void setMaxDocs(int num)
default is 50


setSortByRank

public void setSortByRank(boolean on)
if on=true, sorts by rank, otherwise returns in build order - default is on


setReturnTerms

public void setReturnTerms(boolean on)
if on=true, a query returns term freq info - default is on


setIndex

public void setIndex(java.lang.String index)
sets the index to search - default is 'dtx'


setMatchMode

public void setMatchMode(int mode)
sets the default boolean operator - AND(=1)/OR(=0)


getQueryParams

public java.lang.String getQueryParams()
returns a string with all the current query param settings


runQuery

public void runQuery(java.lang.String base_dir,
                     java.lang.String text_dir,
                     java.lang.String query_string)
actually carry out the query. Use the set methods to set query results. Writes the result to query_result. - maintains state between requests as can be slow base_dir and index_path should join together to provide the absolute location of the mg index files eg ..../index/dtx/demo base_dir must end with a file separator (OS dependant)


getQueryResult

public MGQueryResult getQueryResult()
get the result out of the wrapper