|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfr.gouv.culture.sdx.utils.SdxObjectImpl
fr.gouv.culture.sdx.search.lucene.query.AbstractQuery
Abstract class for basic SDX query functionalities.
To implement a new SDX query type, it is better to extend this class which takes care of:
use the toSAX method for info; this method will deliver the best information after the prepare() method has been called
enableLogging(org.apache.avalon.framework.logger.Logger)
,
setUp(fr.gouv.culture.sdx.search.lucene.query.SearchLocations, org.apache.lucene.search.Query)
,
prepare()
,
execute()
,
toSAX(org.xml.sax.ContentHandler)
Field Summary | |
protected int |
baseOperator
The operator linking this query to the base query. |
protected Query |
baseQuery
The internal Lucene query for the base query. |
protected Results |
baseResults
Results of a base query. |
protected AbstractFilter |
filter
The filter for this query. |
protected org.apache.lucene.search.Query |
luceneQuery
The internal Lucene query for this query. |
protected java.lang.String |
queryText
The requested Text, especially for simple or field queries |
protected SearchLocations |
searchLocations
A Lucene index to search. |
protected SortSpecification |
sortSpecification
The sort specification for this query. |
Fields inherited from class fr.gouv.culture.sdx.utils.SdxObjectImpl |
encoding, logger |
Fields inherited from interface fr.gouv.culture.sdx.search.lucene.query.Query |
defaultOperator, OPERATOR_AND, OPERATOR_NOT, OPERATOR_OR, SEARCH_ENGINE |
Constructor Summary | |
AbstractQuery()
|
Method Summary | |
protected org.xml.sax.helpers.AttributesImpl |
addAttributesLucene(org.xml.sax.helpers.AttributesImpl atts)
Factorization of *Query.toSax() components |
protected org.xml.sax.helpers.AttributesImpl |
addAttributesText(org.xml.sax.helpers.AttributesImpl atts)
Factorization of *Query.toSax() components |
void |
addBaseQuery(Query query,
int operator)
Adds a base query to the current query |
void |
addBaseQuery(Results results,
int operator)
Adds a base query for this query. |
void |
addFilter(AbstractFilter filter)
Adds a filter for this query. |
void |
addSortSpecification(SortSpecification ss)
Adds a sort specification for this query. |
void |
enableLogging(org.apache.avalon.framework.logger.Logger logger)
Sets the logger. |
Results |
execute()
Executes the query and return results. |
org.apache.lucene.search.Query |
getLuceneQuery()
Returns the internal Lucene query for this query. |
static int |
getOperator(java.lang.String str)
Returns a query operator from a given string representation. |
SearchLocations |
getSearchLocations()
|
AbstractFilter |
prepare()
Prepares a query before execution. |
void |
setLuceneQuery(org.apache.lucene.search.Query lquery)
|
protected void |
setSearchLocations(SearchLocations sLocs)
Sets the SearchLocations object |
void |
setUp()
Does nothing here, please see subclasses |
void |
setUp(SearchLocations sLocs,
org.apache.lucene.search.Query lquery)
|
abstract void |
toSAX(org.xml.sax.ContentHandler hdl)
Formats a query in XML. |
Methods inherited from class fr.gouv.culture.sdx.utils.SdxObjectImpl |
getChildLogger, setEncoding |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface fr.gouv.culture.sdx.utils.SdxObject |
setEncoding |
Field Detail |
protected org.apache.lucene.search.Query luceneQuery
protected java.lang.String queryText
protected SearchLocations searchLocations
protected Results baseResults
protected Query baseQuery
protected int baseOperator
protected SortSpecification sortSpecification
protected AbstractFilter filter
Constructor Detail |
public AbstractQuery()
Method Detail |
public void setUp(SearchLocations sLocs, org.apache.lucene.search.Query lquery) throws SDXException
setUp
in interface Query
SDXException
public void setLuceneQuery(org.apache.lucene.search.Query lquery)
setLuceneQuery
in interface Query
public org.apache.lucene.search.Query getLuceneQuery()
getLuceneQuery
in interface Query
public Results execute() throws SDXException
execute
in interface Query
SDXException
public static int getOperator(java.lang.String str)
The values accepted are :
and
; et
for the logical AND operatoror
; ou
for the logical OR operatornot
; sauf
for the logical NOT operator
str
- The string representation of the operator.
public void addBaseQuery(Results results, int operator)
A base query is another query, given by its search results, that will be combined with the current query with a logical operator (AND, OR or NOT).
Using the AND operator is equivalent to "searching within results". Using the OR operator lets one extend a query. Using the NOT operator lets one eclude some previous results.
addBaseQuery
in interface Query
results
- Results from the base query.operator
- The operator to use.public void addBaseQuery(Query query, int operator)
Query
addBaseQuery
in interface Query
query
- The query objectoperator
- The operator linking the query with the base querypublic void addSortSpecification(SortSpecification ss)
addSortSpecification
in interface Query
ss
- The sort specification.public void addFilter(AbstractFilter filter)
addFilter
in interface Query
filter
- The filter to add.public AbstractFilter prepare()
Queries needing a specifc action can override this method that only returns the current filter.
prepare
in interface Query
public void enableLogging(org.apache.avalon.framework.logger.Logger logger)
enableLogging
in interface org.apache.avalon.framework.logger.LogEnabled
enableLogging
in class SdxObjectImpl
logger
- The logger.protected org.xml.sax.helpers.AttributesImpl addAttributesLucene(org.xml.sax.helpers.AttributesImpl atts) throws org.xml.sax.SAXException, org.apache.cocoon.ProcessingException
atts
- current atts to had attributes
org.xml.sax.SAXException
org.apache.cocoon.ProcessingException
protected org.xml.sax.helpers.AttributesImpl addAttributesText(org.xml.sax.helpers.AttributesImpl atts) throws org.xml.sax.SAXException, org.apache.cocoon.ProcessingException
atts
- current atts to had attributes
org.xml.sax.SAXException
org.apache.cocoon.ProcessingException
public abstract void toSAX(org.xml.sax.ContentHandler hdl) throws org.xml.sax.SAXException, org.apache.cocoon.ProcessingException
toSAX
in interface Query
hdl
- A content handler to receive XML data.
org.xml.sax.SAXException
org.apache.cocoon.ProcessingException
protected void setSearchLocations(SearchLocations sLocs) throws SDXException
sLocs
- The SearchLocations object
SDXException
public void setUp()
public SearchLocations getSearchLocations()
getSearchLocations
in interface Query
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |