Changeset 2107


Ignore:
Timestamp:
2001-03-03T09:22:55+13:00 (23 years ago)
Author:
bas6
Message:

add comments to NzdlQuery

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/java-client/org/nzdl/gsdl/service/NzdlQuery.java

    r2098 r2107  
    1 
     1/*
     2 *    NzdlQuery.java
     3 *    Copyright (C) 2001 New Zealand Digital Library Project
     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 */
     19
     20//the package we're in
    221package org.nzdl.gsdl.service;
    322
    423import java.util.*;
    5 
    624import org.nzdl.gsdl.util.NzdlConstants;
    725
     26/**
     27 * NzdlQuery is an object that holds the options for a query and is
     28 * easily configured by the user.
     29 *
     30 * @author Stuart Yeates  ([email protected])
     31 * @author Aziz Mahoui    ([email protected])
     32 * @author Gordon Paynter ([email protected])
     33 * @version $Revision$
     34 */
     35
    836public class NzdlQuery extends java.lang.Object {
    937
    10   /** */
     38
    1139  private Map m_Options = null;
    1240
    13   /** */
    14 
     41  /**     
     42   * Creates an instance of NzdlQuery with an empty query string.
     43   *  Default values are: maxDocs 200, startResults= 1, endResults= 10,
     44   *  queryType= "ranked", caseFolding= true, stemming= false, queryTerm= "".
     45   */
    1546  public NzdlQuery() {
    1647    m_Options = new HashMap();
     
    2455  }
    2556
     57  /**
     58   * Creates an instance of NzdlQuery with a value for query string. Has the
     59   * same default values as NzdlQuery(), with the exception of term which is
     60   * loaded into the query string field.
     61   * @param term the query string
     62   */
    2663  public NzdlQuery( String _term ) {
    2764    m_Options = new HashMap();
     
    3572  }
    3673
    37   /** */
    38 
     74  /**
     75   * Sets the expression to be queried. Note: this can also be done using the
     76   * constructor.
     77   * @param term the query expression string
     78   */
    3979  public void setQueryTerm(String _term) {
    4080    m_Options.put("Term", _term);
    4181  }
    4282
     83  /**
     84  * Sets the query type as either "ranked" or "boolean". "ranked"
     85  * orders results by suitability. "boolean" allows use of operators such as
     86  * !, &, |. Default is "ranked"
     87  * @param type "ranked" or "boolean"
     88  */
    4389  public void setQueryType(String _type) {
    4490    m_Options.put("QueryType", _type);
    4591  }
    4692
     93  /**
     94  * Sets query to ignore case. Default is true.
     95  * @param case if false then sets query to be case sensitive. If true
     96  * then sets query to be case insenstive.
     97  */
    4798  public void setCaseFolding(String _case) {
    4899    m_Options.put("CaseFold", _case);
    49100  }
    50101
     102  /**
     103  * Sets query to ignore word endings. Default is false.
     104  * @param stem if true, sets query to strip endings such as "...ing",
     105  * "...ed". If false, sets query to only match whole words.
     106  */
    51107  public void setStemming(String _stem) {
    52108    m_Options.put("Stem", _stem);
    53109  }
    54110
     111  /**
     112  * Sets the maximum number of documents that can be found by a query.
     113  * Default is 200.
     114  * @param max The maximum permitted number of documents to be found
     115  * by the query
     116  */
     117  public void setMaxDocs(int _max) {
     118    m_Options.put("Maxdocs", new Integer(_max));
     119  }
     120
     121  /**
     122  * Sets the start number of the result set. The result set is a subset
     123  * of the maximum number of documents that will be found by the query.
     124  * Default is 1.
     125  * @param start the number of the first document, relative to the found
     126  * documents
     127  */
    55128  public void setStartResults(int _start) {
    56129    m_Options.put("StartResults", new Integer(_start));
    57130  }
    58131
     132  /**
     133  * Sets the end number of the result set. The result set is a subset of the
     134  * maximum number documents that could be found by that query.
     135  * Default is 10.
     136  * @param end the number of the last document relative to the found
     137  * documents
     138  */
    59139  public void setEndResults(int _end) {
    60140    m_Options.put("EndResults", new Integer(_end));
    61141  }
    62142
    63   public void setMaxDocs(int _max) {
    64     m_Options.put("Maxdocs", new Integer(_max));
    65   }
    66 
    67   /** */
    68 
     143  /**
     144  * Returns whether query is "ranked" or "boolean". "ranked" orders results by
     145  * suitability. "boolean" allows use of operators such as !, &, |. Default is
     146  * "ranked"
     147  * @return Either "ranked" or "boolean"
     148  */
    69149  public String getQueryType() {
    70150    return (String)m_Options.get("QueryType");
    71151  }
    72152
     153  /**
     154  * Returns the query string expression.
     155  * @return the query string
     156  */
    73157  public String getQueryTerm() {
    74158    return (String)m_Options.get("Term");
    75159  }
    76160
     161  /**
     162  * Returns "true" if query is case insenstive. Default is "true"
     163  * @return "true" if query is case insenstive, "false" if the query is case
     164  * senstive.
     165  */
    77166  public String getCaseFolding() {
    78167    return (String)m_Options.get("CaseFold");
    79168  }
    80169
     170  /**
     171  * Returns "true" if query ignores word endings. Default is "false".
     172  * @return "true" if query strips endings such as "...ing" or "...ed" , false
     173  * if query only matches whole words.
     174  */
    81175  public String getStemming() {
    82176    return (String)m_Options.get("Stem");
    83177  }
    84178
     179    /**
     180   * Returns the current setting for the maximum number of documents that
     181   * may be found by a query. Default is 200.
     182   * @return The maximum number of documents to be found
     183   */
     184  public int getMaxDocs() {
     185    return ((Integer) m_Options.get("Maxdocs")).intValue();
     186  }
     187
     188  /**
     189  * Returns the start number of the result set. The result set is a subset of
     190  * the maximum number of documents that could be found by the query.
     191  * Default is 1.
     192  * @return The number of the first document relative to the documents that
     193  * were found to match the query
     194  */
    85195  public int getStartResults() {
    86196    return ((Integer) m_Options.get("StartResults")).intValue();
    87197  }
    88198
     199  /**
     200  * Returns the end number of the result set. The result set is a subset of
     201  * the maximum number documents that could be found by the query.
     202  * Default is 10.
     203  * @return The number of the last document relative to the documents that
     204  * were found to match the query.
     205  */
    89206  public int getEndResults() {
    90207    return ((Integer) m_Options.get("EndResults")).intValue();
    91208  }
    92209
    93   public int getMaxDocs() {
    94     return ((Integer) m_Options.get("Maxdocs")).intValue();
    95   }
    96 
    97   /** */
    98 
     210  /**
     211  * Returns the set of query terms.
     212  * @return This set: "EndResults", "QueryType", "Term", "MaxDocs",
     213  * "StartResults", "Stem", "CaseFold"
     214  */
    99215  public Set queryKeySet() {
    100216    return m_Options.keySet();
    101217  }
    102218
     219  /**
     220  * Returns a collection of the current query values.
     221  * @return For a default query this collection: 10, "ranked", "", 200, 1
     222  * , false, true
     223  */
    103224  public Collection queryValues() {
    104225    return m_Options.values();
     
    106227
    107228}
     229
Note: See TracChangeset for help on using the changeset viewer.