Xindice API
version 1.2m1

org.apache.xindice.core.indexer
Class MemValueIndexer

java.lang.Object
  extended byorg.apache.xindice.core.indexer.MemValueIndexer
All Implemented Interfaces:
Configurable, DBObject, Indexer, Named

public class MemValueIndexer
extends Object
implements Indexer

Provides an in-memory implementation of Xindice Indexer based upon the Java TreeSet class. This implementation is not persistent. A MemValueIndexer is useful for indexing of temporary Collections (e.g. those based on MemFiler). It is also useful for temporary indexing of persistent Collections.

Version:
$Revision: 571949 $, $Date: 2007-09-02 06:52:38 -0400 (Sun, 02 Sep 2007) $
Author:
Terry Rosenbaum (terry@amicas.com)

Field Summary
 
Fields inherited from interface org.apache.xindice.core.indexer.Indexer
STYLE_FULLTEXT, STYLE_NODENAME, STYLE_NODEVALUE
 
Constructor Summary
MemValueIndexer()
           
 
Method Summary
 void addDocument(Key key)
           
 boolean close()
          Closes this index.
 boolean create()
          Creates a new MemValueIndexer.
 boolean drop()
          Removes this index from existence.
 boolean exists()
          Indicates whether or not this index exists.
 void flush()
          flush forcefully flushes any unwritten buffers to disk.
 Configuration getConfig()
          getConfig retrieves the configuration information for the Configurable object instance.
 IndexerEventHandler getIndexerEventHandler()
          getIndexerEventHandler returns an instance of IndexerEventHandler that handles Indexer-specific events.
 String getIndexStyle()
          Provides the index style.
 String getName()
          Provides the name of this index.
 IndexPattern[] getPatterns()
          Provides the pattern recognized by this Indexer.
 boolean isOpened()
          Indicates whether or not this indexer is open.
 boolean open()
          Opens the index so it can be used.
 IndexMatch[] queryMatches(IndexQuery theQuery)
          Provides a set of MatchEntry instances that match the specified query.
 void removeDocument(Key key)
           
 void setCollection(Collection theCollection)
          Sets the parent Collection of this indexer.
 void setConfig(Configuration theConfig)
          setConfig sets the configuration information for the Configurable object instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemValueIndexer

public MemValueIndexer()
Method Detail

setCollection

public void setCollection(Collection theCollection)
Sets the parent Collection of this indexer.

Specified by:
setCollection in interface Indexer
Parameters:
theCollection - The owner Collection

getIndexStyle

public String getIndexStyle()
Provides the index style. Different query languages will need to draw from different indexing styles. For example, A query that is written in quilt will require XPath indexing.

Specified by:
getIndexStyle in interface Indexer
Returns:
the index style

addDocument

public void addDocument(Key key)
                 throws DBException
Throws:
DBException

removeDocument

public void removeDocument(Key key)
                    throws DBException
Throws:
DBException

getPatterns

public IndexPattern[] getPatterns()
Provides the pattern recognized by this Indexer. Patterns must be in the form of (elem|*)[@(attr|*)] to tell the IndexManager which element types to send to it, so for example:
    contact@name  Indexes all contacts by name attribute
    memo          Indexes the text of all memo elements
    contact@*     Indexes all contact attributes
    *@name        Indexes the name attribute for all elements
    *             Indexes the text of all elements
    *@*           Indexes all attributes of all elements
 
These patterns are used by the IndexManager when handling SAX events. All events that match the specified pattern will result in an add or remove call to the Indexer.

Specified by:
getPatterns in interface Indexer
Returns:
the pattern used by this index

queryMatches

public IndexMatch[] queryMatches(IndexQuery theQuery)
                          throws DBException
Provides a set of MatchEntry instances that match the specified query. The matches are then used by the QueryEngine in co-sequential processing. If this indexer doesn't support the passed value, it should return 'null'. If no matches are found, it should return an empty set. queryMatches will typically be used in XPath processing.

Specified by:
queryMatches in interface Indexer
Parameters:
theQuery - The IndexQuery to use
Returns:
The resulting matches
Throws:
DBException

flush

public void flush()
           throws DBException
flush forcefully flushes any unwritten buffers to disk.

Specified by:
flush in interface Indexer
Throws:
DBException

getIndexerEventHandler

public IndexerEventHandler getIndexerEventHandler()
Description copied from interface: Indexer
getIndexerEventHandler returns an instance of IndexerEventHandler that handles Indexer-specific events. This method is called once per document, and all events for one document will be processed by the same handler.

Specified by:
getIndexerEventHandler in interface Indexer
Returns:
IndexerEventHandler that will handle document processing
See Also:
IndexerEventHandler

setConfig

public void setConfig(Configuration theConfig)
setConfig sets the configuration information for the Configurable object instance.

Specified by:
setConfig in interface Configurable
Parameters:
theConfig - The configuration Node

getConfig

public Configuration getConfig()
getConfig retrieves the configuration information for the Configurable object instance.

Specified by:
getConfig in interface Configurable
Returns:
The configuration Node

create

public boolean create()
               throws DBException
Creates a new MemValueIndexer.

Specified by:
create in interface DBObject
Returns:
Whether or not the DBObject was created
Throws:
DBException - if operation failed

open

public boolean open()
             throws DBException
Opens the index so it can be used. Since MemValueIndexer uses memory only as a backing store, it must always be created before it can be opened. If a call to open() has not been preceeded by a call to create(), the open() will return false. Also, this object must be configured via setConfig() before it can be opened.

Specified by:
open in interface DBObject
Returns:
true if index was opened successfully, false otherwise
Throws:
DBException - if operation failed

isOpened

public boolean isOpened()
Indicates whether or not this indexer is open.

Specified by:
isOpened in interface DBObject
Returns:
true if open, false otherwise

exists

public boolean exists()
               throws DBException
Indicates whether or not this index exists. Since this is a memory-buffered index, it only exists after having been created.

Specified by:
exists in interface DBObject
Returns:
Whether or not the physical resource exists
Throws:
DBException - if operation failed

drop

public boolean drop()
             throws DBException
Removes this index from existence. The indexes owner(s) is/are responsible for removing any references to the index in its own context.

Specified by:
drop in interface DBObject
Returns:
Whether or not the DBObject was dropped
Throws:
DBException - if operation failed

close

public boolean close()
              throws DBException
Closes this index. Does nothing more than set the state returned to isOpened() to false.

Specified by:
close in interface DBObject
Returns:
Whether or not the index was closed
Throws:
DBException - if operation failed

getName

public String getName()
Provides the name of this index.

Specified by:
getName in interface Named
Returns:
index's name

Xindice API
version 1.2m1

Copyright (c) 1999-2007 The Apache Software Foundation. All Rights Reserved.