org.apache.cocoon.bean.query
Class SimpleLuceneQueryBean

java.lang.Object
  extended by org.apache.cocoon.bean.query.SimpleLuceneQueryBean
All Implemented Interfaces:
Serializable, Cloneable, SimpleLuceneQuery

public class SimpleLuceneQueryBean
extends Object
implements SimpleLuceneQuery, Cloneable, Serializable

The query bean.

This object defines a Bean for searching.
The idea is to abstract the process of searching into a Bean to be manipulated by CForms.
This Bean is designed to be persistable.

Version:
CVS $Id: SimpleLuceneQueryBean.html 1304258 2012-03-23 10:09:27Z ilgrosso $
See Also:
Serialized Form

Field Summary
static Long DEFAULT_PAGE
          The DEFAULT_PAGE of this bean.
static Long DEFAULT_PAGE_SIZE
          The DEFAULT_PAGE_SIZE of this bean.
static String INDEX_FIELD
          The INDEX_FIELD of this bean.
static String SCORE_FIELD
          The SCORE_FIELD of this bean.
 
Fields inherited from interface org.apache.cocoon.bean.query.SimpleLuceneQuery
AND_BOOL, OR_BOOL
 
Constructor Summary
SimpleLuceneQueryBean()
          Default constructor.
SimpleLuceneQueryBean(String type, String bool, String match, String field, String query)
          Utility constructor.
 
Method Summary
 void addCriterion(SimpleLuceneCriterionBean criterion)
          Adds a Criterion the Bean.
 Object clone()
           
 String getBool()
          Gets the Bean's boolean operator.
 List getCriteria()
          Gets the Bean's criteria.
 Date getDate()
          Gets the Bean's inception date.
 Long getId()
          Gets the Bean's ID.
 String getName()
          Gets the Bean's name.
 Long getPage()
          Gets the Bean's page index
 Long getSize()
          Gets the Bean's page size
 Long getTotal()
          Gets the Bean's hit count.
 String getType()
          Gets the Bean's type.
 String getUser()
          Gets the Bean's owner.
 void removeCriterion(SimpleLuceneCriterionBean criterion)
          Removes a Criterion from the Bean.
 List search(LuceneCocoonSearcher searcher)
          Gets the Bean to perform it's query The searcher specifies which LuceneCocoonSearcher to use for this search.
 void setBool(String bool)
          Sets the Bean's boolean operator.
 void setCriteria(List criteria)
          Sets the Bean's criteria.
 void setDate(Date date)
          Sets the Bean's inception date.
 void setId(Long id)
          Sets the Bean's ID.
 void setName(String name)
          Sets the Bean's Name.
 void setPage(Long page)
          Sets the Bean's page index.
 void setSize(Long size)
          Sets the Bean's page size.
 void setTotal(Long total)
          Sets the Bean's hit count.
 void setType(String type)
          Sets the Bean's type.
 void setUser(String user)
          Sets the Bean's owner.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PAGE_SIZE

public static Long DEFAULT_PAGE_SIZE
The DEFAULT_PAGE_SIZE of this bean. ie. 20


DEFAULT_PAGE

public static Long DEFAULT_PAGE
The DEFAULT_PAGE of this bean. ie. 0


SCORE_FIELD

public static String SCORE_FIELD
The SCORE_FIELD of this bean. This is the key of the Lucene Score as output by this Bean in each hit. ie. _lucene-score_


INDEX_FIELD

public static String INDEX_FIELD
The INDEX_FIELD of this bean. This is the key of the hit index as output by this Bean in each hit. ie. _lucene-index_

Constructor Detail

SimpleLuceneQueryBean

public SimpleLuceneQueryBean()
Default constructor.


SimpleLuceneQueryBean

public SimpleLuceneQueryBean(String type,
                             String bool,
                             String match,
                             String field,
                             String query)
Utility constructor.

Parameters:
type - the type of this query
bool - the kind of boolean opperation to apply to each of it's Criteria
match - the kind of match to use for the generated Criterion
field - the field to search for the generated Criterion
query - the terms to search for the generated Criterion
Method Detail

clone

public Object clone()
             throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException

search

public List search(LuceneCocoonSearcher searcher)
            throws IOException,
                   ProcessingException
Gets the Bean to perform it's query

The searcher specifies which LuceneCocoonSearcher to use for this search.
It needs to have been initialised properly before use.
Each Map in the List returned by this method contains:

Specified by:
search in interface SimpleLuceneQuery
Parameters:
searcher - The LuceneCocoonSearcher to use for this search
Returns:
a List of Maps, each representing a Hit.
Throws:
ProcessingException - thrown by the searcher
IOException - thrown when the searcher's directory cannot be found

getId

public Long getId()
Gets the Bean's ID.

Returns:
the Long ID of the Bean.

setId

public void setId(Long id)
Sets the Bean's ID.

Parameters:
id - the Long ID of the Bean.

getName

public String getName()
Gets the Bean's name.

Returns:
the String name of the Bean.

setName

public void setName(String name)
Sets the Bean's Name.

Parameters:
name - the String name of the Bean.

getType

public String getType()
Gets the Bean's type.

Returns:
the String type of the Bean.

setType

public void setType(String type)
Sets the Bean's type.

Parameters:
type - the String type of the Bean.

getBool

public String getBool()
Gets the Bean's boolean operator.

Returns:
the String boolean of the Bean.

setBool

public void setBool(String bool)
Sets the Bean's boolean operator. ie. which kind of boolean operation do you want performed on each Criterion.

Parameters:
bool - the String boolean of the Bean.

getUser

public String getUser()
Gets the Bean's owner.

Returns:
the String owner of the Bean.

setUser

public void setUser(String user)
Sets the Bean's owner.

Parameters:
user - the String owner of the Bean.

getSize

public Long getSize()
Gets the Bean's page size

Returns:
the Long page size of the Bean.

setSize

public void setSize(Long size)
Sets the Bean's page size. ie. how many hits do you want this Bean to show on in page.

Parameters:
size - the Long page size of the Bean.

getPage

public Long getPage()
Gets the Bean's page index

Returns:
the Long page index of the Bean.

setPage

public void setPage(Long page)
Sets the Bean's page index. ie. which page do you want this Bean to show.

Parameters:
page - the Long page index of the Bean.

getTotal

public Long getTotal()
Gets the Bean's hit count.

Returns:
the Long hit count of the Bean.

setTotal

public void setTotal(Long total)
Sets the Bean's hit count.

Parameters:
total - the Long hit count of the Bean.

getDate

public Date getDate()
Gets the Bean's inception date.

Returns:
the Date of the Bean.

setDate

public void setDate(Date date)
Sets the Bean's inception date.

Parameters:
date - the Date inception date of the Bean.

getCriteria

public List getCriteria()
Gets the Bean's criteria.

Returns:
the List of Bean Query criteria.

setCriteria

public void setCriteria(List criteria)
Sets the Bean's criteria.

Parameters:
criteria - the List of Bean Query criteria.

addCriterion

public void addCriterion(SimpleLuceneCriterionBean criterion)
Adds a Criterion the Bean.

Parameters:
criterion - the SimpleLuceneCriterionBean to add to the Bean.

removeCriterion

public void removeCriterion(SimpleLuceneCriterionBean criterion)
Removes a Criterion from the Bean.

Parameters:
criterion - the SimpleLuceneCriterionBean to remove from the Bean.


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.