fr.gouv.culture.sdx.search.lucene.query
Class SearchLocations

java.lang.Object
  extended by fr.gouv.culture.sdx.utils.AbstractSdxObject
      extended by fr.gouv.culture.sdx.search.lucene.query.SearchLocations
All Implemented Interfaces:
SearchLocations, Describable, Encodable, Identifiable, Localizable, SdxObject, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.service.Serviceable, org.apache.excalibur.xml.sax.XMLizable

public class SearchLocations
extends AbstractSdxObject
implements SearchLocations

A list of LuceneIndex where searches can be made.


Nested Class Summary
 
Nested classes/interfaces inherited from interface fr.gouv.culture.sdx.utils.SdxObject
SdxObject.ConfigurationNode
 
Field Summary
 
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.SearchLocations
CLASS_NAME_SUFFIX
 
Fields inherited from interface fr.gouv.culture.sdx.utils.Encodable
DEFAULT_ENCODING
 
Constructor Summary
SearchLocations()
          Builds an empty search location.
 
Method Summary
 org.apache.lucene.index.IndexReader _getReader()
          Deprecated.  
 org.apache.lucene.index.IndexReader _getReader(int idx)
          Deprecated. Returns an index reader at the specified index.
 org.apache.lucene.search.Searcher _getSearcher()
          Returns a searcher for these locations.
 org.apache.lucene.search.Searcher _getSearcher(int idx)
          Returns an searcher for the specified index.
 void addDocumentBase(DocumentBase db)
          Add a documentBase to the search location It mean it add all documentBase indexes
 void addIndex(Index index)
          Deprecated. Adds an index to locations.
 boolean contains(DocumentBase db)
           
 boolean contains(Index index)
           
protected  java.lang.String getClassNameSuffix()
          Sub classes should element this method to return their class name suffix for SAX output
 Field getDefaultField()
          Returns the default field for the first search location (first index).
 java.util.Vector getDocumentBases()
          Returns the document bases sets up in the SearchLocations
 java.util.HashSet getDocumentBasesNames()
          Returns the documents bases names sets up in the SearchLocations
 Field getField(java.lang.String name)
          Returns a field given a name.
 int getFieldType(java.lang.String name)
          Returns the type of a field given its name.
 DocumentBase getFirstDocumentBase()
          Returns the first document bases sets up in the SearchLocations.
 java.util.Locale getLocale(java.lang.String name)
          Returns the locale for a field given its name.
 QueryParser getQueryParser()
           
 org.apache.lucene.index.IndexReader getReader()
           
 org.apache.lucene.index.IndexReader getReader(int idb)
          Returns an index reader at the specified documentBase.
 org.apache.lucene.search.Searcher getSearcher()
          Returns a searcher for these locations.
 org.apache.lucene.search.Searcher getSearcher(int idb)
          Returns an searcher for the specified documentBase.
 java.lang.String getTypeName(java.lang.String name)
          Returns the typeName of a field given its name.
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
 void setQueryParser(QueryParser qParser)
           
 void setUp(DocumentBase db)
          Builds a search location with a single documentbase.
 void setUp(Index index)
          Deprecated. Builds a search location with a single index.
 int size()
          Returns the number of document bases in this search location.
 void toSAX(org.xml.sax.ContentHandler hdl)
           
 
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
 

Constructor Detail

SearchLocations

public SearchLocations()
Builds an empty search location. Use enableLoggin and addIndex() afterwards to add at least one index.

See Also:
AbstractSdxObject.enableLogging(org.apache.avalon.framework.logger.Logger), addIndex(fr.gouv.culture.sdx.search.lucene.query.Index)
Method Detail

setUp

public void setUp(Index index)
Deprecated. Builds a search location with a single index.

Parameters:
index - The Lucene index to use.

setUp

public void setUp(DocumentBase db)
Builds a search location with a single documentbase.

Parameters:
db - The documentBase to use.

addIndex

public void addIndex(Index index)
Deprecated. Adds an index to locations.

Parameters:
index - The index to add.

addDocumentBase

public void addDocumentBase(DocumentBase db)
Add a documentBase to the search location It mean it add all documentBase indexes


getDefaultField

public Field getDefaultField()
                      throws SDXException
Returns the default field for the first search location (first index).

Throws:
SDXException

getFirstDocumentBase

public DocumentBase getFirstDocumentBase()
Returns the first document bases sets up in the SearchLocations.

Returns:
DocumentBase The first document base or the only document base. May be null if the SearchLocations does not contain any document base.

getField

public Field getField(java.lang.String name)
               throws SDXException
Returns a field given a name. Will return the first field having this name, null if none found.

Parameters:
name - The name of the field for which the Field is desired.
Returns:
Throws:
SDXException

getFieldType

public int getFieldType(java.lang.String name)
                 throws SDXException
Returns the type of a field given its name. The first field with this name will be returned.

Parameters:
name - The field name.
Throws:
SDXException

getTypeName

public java.lang.String getTypeName(java.lang.String name)
                             throws SDXException
Returns the typeName of a field given its name. The first field with this name will be returned.

Parameters:
name - The field name.
Throws:
SDXException

getDocumentBases

public java.util.Vector getDocumentBases()
Returns the document bases sets up in the SearchLocations

Returns:
Vector The document bases

getDocumentBasesNames

public java.util.HashSet getDocumentBasesNames()
Returns the documents bases names sets up in the SearchLocations

Returns:
HashSet The documents bases names

size

public int size()
Returns the number of document bases in this search location.


contains

public boolean contains(DocumentBase db)

contains

public boolean contains(Index index)

getLocale

public java.util.Locale getLocale(java.lang.String name)
                           throws SDXException
Returns the locale for a field given its name. The first field found with this name will be used.

Parameters:
name - The name of the field for which the Locale is desired.
Throws:
SDXException

_getReader

public org.apache.lucene.index.IndexReader _getReader(int idx)
                                               throws SDXException
Deprecated. Returns an index reader at the specified index.

Parameters:
idx - The documentBase of the desired reader.
Throws:
SDXException

_getReader

public org.apache.lucene.index.IndexReader _getReader()
                                               throws SDXException
Deprecated. 

Throws:
SDXException

getReader

public org.apache.lucene.index.IndexReader getReader(int idb)
                                              throws SDXException
Returns an index reader at the specified documentBase.

Parameters:
idb - The documentBase of the desired reader.
Throws:
SDXException

getReader

public org.apache.lucene.index.IndexReader getReader()
                                              throws SDXException
Throws:
SDXException

_getSearcher

public org.apache.lucene.search.Searcher _getSearcher(int idx)
                                               throws SDXException
Returns an searcher for the specified index.

Parameters:
idx - The index of the desired searcher.
Throws:
SDXException

_getSearcher

public org.apache.lucene.search.Searcher _getSearcher()
                                               throws SDXException
Returns a searcher for these locations.

Throws:
SDXException

getSearcher

public org.apache.lucene.search.Searcher getSearcher(int idb)
                                              throws SDXException
Returns an searcher for the specified documentBase.

Parameters:
idb - The documentBase of the desired searcher.
Throws:
SDXException

getSearcher

public org.apache.lucene.search.Searcher getSearcher()
                                              throws SDXException
Returns a searcher for these locations.

Throws:
SDXException

getQueryParser

public QueryParser getQueryParser()

setQueryParser

public void setQueryParser(QueryParser qParser)

toSAX

public void toSAX(org.xml.sax.ContentHandler hdl)
           throws org.xml.sax.SAXException
Specified by:
toSAX in interface org.apache.excalibur.xml.sax.XMLizable
Overrides:
toSAX in class AbstractSdxObject
Throws:
org.xml.sax.SAXException

getClassNameSuffix

protected java.lang.String getClassNameSuffix()
Description copied from class: AbstractSdxObject
Sub classes should element this method to return their class name suffix for SAX output

Specified by:
getClassNameSuffix in class AbstractSdxObject

initToSax

protected boolean initToSax()
Description copied from class: AbstractSdxObject
Init the LinkedHashMap _xmlizable_objects with the objects in order to describ them in XML

Specified by:
initToSax in class AbstractSdxObject

initVolatileObjectsToSax

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

Specified by:
initVolatileObjectsToSax in class AbstractSdxObject


Copyright © 2000-2010 Ministere de la culture et de la communication / AJLSM. All Rights Reserved.