KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > indexing > SingleFieldSearchInput


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.services.indexing;
6
7 import org.apache.lucene.analysis.Analyzer;
8 import org.apache.lucene.queryParser.QueryParser;
9 import org.apache.lucene.search.Query;
10 /**
11  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
12  * @since Sep 12, 2004
13  * @version $Id: SingleFieldSearchInput.java,v 1.2 2004/10/14 23:27:57 tuan08 Exp $
14  */

15 public class SingleFieldSearchInput implements SearchInput {
16   
17   private String JavaDoc field_ ;
18   private String JavaDoc term_ ;
19   private boolean required_ = true ;
20   
21   public SingleFieldSearchInput(String JavaDoc field) {
22     field_ = field ;
23   }
24   
25   public SingleFieldSearchInput(String JavaDoc field, String JavaDoc term) {
26     field_ = field ;
27     term_ = term ;
28   }
29   
30   public boolean isRequired() { return required_ ; }
31   public void setRequired(boolean b) { required_ = b ; }
32   
33   public String JavaDoc getField() { return field_ ; }
34   
35   public boolean hasTerm() {
36     return term_ != null && term_.length() > 0;
37   }
38   
39   public String JavaDoc getTerm() { return term_ ; }
40   public void setTerm(String JavaDoc term) { term_ = term ; }
41   
42   public Query getQuery(Analyzer analyzer) throws Exception JavaDoc {
43     return QueryParser.parse(term_ , field_, analyzer) ;
44   }
45 }
Popular Tags