|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object fr.gouv.culture.sdx.utils.AbstractSdxObject fr.gouv.culture.sdx.search.lucene.query.AbstractQuery
public abstract class 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
prepare()
,
execute()
,
toSAX(org.xml.sax.ContentHandler)
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface fr.gouv.culture.sdx.utils.SdxObject |
---|
SdxObject.ConfigurationNode |
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 CachingRewrittenQueryWrapper |
cachedQuery
The internal Lucene query wrapper for term collection/highlighting |
protected Filter |
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.AbstractSdxObject |
---|
_configuration, _context, _description, _encoding, _id, _locale, _logger, _manager, _xmlizable_objects, _xmlLang, isToSaxInitialized |
Fields inherited from interface fr.gouv.culture.sdx.search.lucene.query.Query |
---|
defaultOperator, LUCENE_BOOLEAN_QUERY_MAX_CLAUSES, OPERATOR_AND, OPERATOR_NOT, OPERATOR_OR, SEARCH_ENGINE |
Fields inherited from interface fr.gouv.culture.sdx.search.Query |
---|
CLASS_NAME_SUFFIX |
Fields inherited from interface fr.gouv.culture.sdx.utils.Encodable |
---|
DEFAULT_ENCODING |
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(Filter filter)
Adds a filter for this query. |
void |
addSortSpecification(SortSpecification ss)
Adds a sort specification for this query. |
Results |
execute()
Executes the query and return results. |
float |
getBoost()
Returns the boost on the query. |
org.apache.lucene.search.Query |
getCachedQuery()
|
protected java.lang.String |
getClassNameSuffix()
Sub classes should element this method to return their class name suffix for SAX output |
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()
|
protected boolean |
initToSax()
Init the LinkedHashMap _xmlizable_objects with the objects in order to describ them in XML |
protected void |
initVolatileObjectsToSax()
Init the LinkedHashMap _xmlizable_volatile_objects with the objects in order to describ them in XML Some objects need to be refresh each time a toSAX is called |
Filter |
prepare()
Prepares a query before execution. |
void |
setBoost(float boost)
Change the boost on the query. |
void |
setBoost(java.lang.String boost)
Change the boost on the query. |
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.AbstractSdxObject |
---|
configure, configureDescription, contextualize, enableLogging, getBaseAttributes, getConfiguration, getContext, getDescription, getEncoding, getId, getLocale, getLog, getServiceManager, getXmlLang, service, setDescription, setEncoding, setId, setLocale, setUpSdxObject, setUpSdxObject, setXmlLang, verifyConfigurationResources |
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 |
---|
getLog |
Methods inherited from interface org.apache.avalon.framework.logger.LogEnabled |
---|
enableLogging |
Methods inherited from interface org.apache.avalon.framework.context.Contextualizable |
---|
contextualize |
Methods inherited from interface org.apache.avalon.framework.service.Serviceable |
---|
service |
Methods inherited from interface org.apache.avalon.framework.configuration.Configurable |
---|
configure |
Methods inherited from interface fr.gouv.culture.sdx.utils.Identifiable |
---|
getId, setId |
Methods inherited from interface fr.gouv.culture.sdx.utils.Describable |
---|
getDescription, setDescription |
Methods inherited from interface fr.gouv.culture.sdx.utils.Encodable |
---|
getEncoding, setEncoding |
Methods inherited from interface fr.gouv.culture.sdx.utils.Localizable |
---|
getLocale, getXmlLang, setLocale, setXmlLang |
Field Detail |
---|
protected SearchLocations searchLocations
protected java.lang.String queryText
protected Results baseResults
protected Query baseQuery
protected int baseOperator
protected SortSpecification sortSpecification
protected Filter filter
protected org.apache.lucene.search.Query luceneQuery
protected CachingRewrittenQueryWrapper cachedQuery
Constructor Detail |
---|
public AbstractQuery()
Method Detail |
---|
public void setUp(SearchLocations sLocs, org.apache.lucene.search.Query lquery) throws SDXException
SDXException
public void setLuceneQuery(org.apache.lucene.search.Query lquery)
public org.apache.lucene.search.Query getLuceneQuery()
public org.apache.lucene.search.Query getCachedQuery()
public Results execute() throws SDXException
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.
results
- Results from the base query.operator
- The operator to use.public void addBaseQuery(Query query, int operator)
Query
query
- The query objectoperator
- The operator linking the query with the base querypublic void addSortSpecification(SortSpecification ss)
ss
- The sort specification.public void addFilter(Filter filter)
filter
- The filter to add.public Filter prepare()
Queries needing a specifc action can override this method that only returns the current filter.
protected org.xml.sax.helpers.AttributesImpl addAttributesLucene(org.xml.sax.helpers.AttributesImpl atts) throws org.xml.sax.SAXException
atts
- current atts to had attributes
org.xml.sax.SAXException
protected org.xml.sax.helpers.AttributesImpl addAttributesText(org.xml.sax.helpers.AttributesImpl atts) throws org.xml.sax.SAXException
atts
- current atts to had attributes
org.xml.sax.SAXException
public abstract void toSAX(org.xml.sax.ContentHandler hdl) throws org.xml.sax.SAXException
toSAX
in interface org.apache.excalibur.xml.sax.XMLizable
toSAX
in class AbstractSdxObject
hdl
- A content handler to receive XML data.
org.xml.sax.SAXException
protected void setSearchLocations(SearchLocations sLocs) throws SDXException
sLocs
- The SearchLocations object
SDXException
public void setUp()
public SearchLocations getSearchLocations()
protected java.lang.String getClassNameSuffix()
AbstractSdxObject
getClassNameSuffix
in class AbstractSdxObject
public float getBoost()
Query
This method returns the boost on the query.
public void setBoost(float boost)
Query
This method changes the boost on the query to make it more significant.
public void setBoost(java.lang.String boost)
Query
This method changes the boost on the query to make it more significant. If the String is not a valid float, no changes occur.
protected boolean initToSax()
AbstractSdxObject
initToSax
in class AbstractSdxObject
protected void initVolatileObjectsToSax()
initVolatileObjectsToSax
in class AbstractSdxObject
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |