KickJava   Java API By Example, From Geeks To Geeks.

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


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.index.Term ;
9 import org.apache.lucene.search.* ;
10 /**
11  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
12  * @since Sep 12, 2004
13  * @version $Id: KeywordFieldSearchInput.java,v 1.1 2004/09/17 23:38:59 tuan08 Exp $
14  */

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