com.timeindexing.index
Class TimeIndexFactory

java.lang.Object
  extended by com.timeindexing.index.TimeIndexFactory
All Implemented Interfaces:
IndexAccessEventListener, IndexAddEventListener, IndexEventGenerator, IndexPrimaryEventListener, java.util.EventListener

public class TimeIndexFactory
extends java.lang.Object
implements IndexPrimaryEventListener, IndexAddEventListener, IndexAccessEventListener, IndexEventGenerator

This is the TimeIndexFactory which returns different implementations of a TimeIndex, depending on the arguments to create() or retrieve().

The factory listens to events from Indexes, and will pass them on to any of its listeners.


Constructor Summary
TimeIndexFactory()
          Create a TimeIndexFactory.
 
Method Summary
 void addAccessEventListener(IndexAccessEventListener l)
          Add a IndexAccessEventListener.
 void addAddEventListener(IndexAddEventListener l)
          Add a IndexAddEventListener.
 void addPrimaryEventListener(IndexPrimaryEventListener l)
          Add a IndexPrimaryEventListener.
 IndexView append(java.io.File indexFile)
          Append to an index.
 IndexView append(java.util.Map indexMap)
          Append to an index.
 IndexView append(java.util.Properties indexProperties)
          Append to an index.
 IndexView append(java.net.URI uri)
          Append to an index.
 boolean close(Index index)
          Close an index
 void closed(IndexPrimaryEvent ipe)
          A notification that an Index has been closed.
 void committed(IndexPrimaryEvent ipe)
          A notification that an Index has been committed.
 IndexView create(IndexType kind, java.io.File indexFile)
          Create a new Time Index object given an IndexType.
 IndexView create(IndexType kind, java.util.Map indexMap)
          Create a new Time Index object given an IndexType.
 IndexView create(IndexType kind, java.util.Properties indexProperties)
          Create a new Time Index object given an IndexType.
 IndexView create(IndexType kind, java.net.URI uri)
          Create a new Time Index object given an IndexType.
 void created(IndexPrimaryEvent ipe)
          A notification that an Index has been created.
 IndexEventMulticaster eventMulticaster()
          Get the event listener.
 IndexView find(ID indexID)
          Try and find an Index, given its ID.
 void itemAccessed(IndexAccessEvent iae)
          A notification that an IndexItem has been accessed in an Index.
 void itemAdded(IndexAddEvent iae)
          A notification that an IndexItem has been added to an Index.
 IndexView open(java.io.File indexFile)
          Retrieve a TimeIndex object by file name.
 IndexView open(java.util.Map indexMap)
          Retrieve a TimeIndex object by file name.
 IndexView open(java.util.Properties indexProperties)
          Retrieve a TimeIndex object by file name.
 IndexView open(java.net.URI indexURI)
          Retrieve a TimeIndex object by URI.
 void opened(IndexPrimaryEvent ipe)
          A notification that an Index has been opened.
 void removeAccessEventListener(IndexAccessEventListener l)
          Remove a IndexAccessEventListener.
 void removeAddEventListener(IndexAddEventListener l)
          Remove a IndexAddEventListener.
 void removePrimaryEventListener(IndexPrimaryEventListener l)
          Remove a IndexPrimaryEventListener.
 IndexView save(Index index, IndexType kind, java.util.Map indexMap)
          Create a new Index object from an existing Index object.
 IndexView save(Index index, IndexType kind, java.util.Properties indexProperties)
          Create a new Index object from an existing Index object.
 void viewAdded(IndexPrimaryEvent ipe)
          A notification that a view has been added to an Index.
 void viewRemoved(IndexPrimaryEvent ipe)
          A notification that a view has been removed to an Index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeIndexFactory

public TimeIndexFactory()
Create a TimeIndexFactory.

Method Detail

create

public IndexView create(IndexType kind,
                        java.io.File indexFile)
                 throws TimeIndexFactoryException,
                        IndexSpecificationException,
                        IndexCreateException
Create a new Time Index object given an IndexType. If the index already exists then an IndexView onto that index will be returned.

Parameters:
kind - One of IndexType.INLINE, IndexType.EXTERNAL, IndexType.SHADOW, IndexType.INCORE.
indexFile - the file spec of the index
Throws:
TimeIndexFactoryException
IndexSpecificationException
IndexCreateException

create

public IndexView create(IndexType kind,
                        java.net.URI uri)
                 throws TimeIndexFactoryException,
                        IndexSpecificationException,
                        IndexCreateException
Create a new Time Index object given an IndexType. If the index already exists then an IndexView onto that index will be returned.

Parameters:
kind - One of IndexType.INLINE, IndexType.EXTERNAL, IndexType.SHADOW, IndexType.INCORE.
uri - the uri spec of the index
Throws:
TimeIndexFactoryException
IndexSpecificationException
IndexCreateException

create

public IndexView create(IndexType kind,
                        java.util.Map indexMap)
                 throws TimeIndexFactoryException,
                        IndexSpecificationException,
                        IndexCreateException
Create a new Time Index object given an IndexType. If the index already exists then an IndexView onto that index will be returned.

Parameters:
kind - One of IndexType.INLINE, IndexType.EXTERNAL, IndexType.SHADOW, IndexType.INCORE.
indexMap - map of the index needed at creat time, such as its name.
Throws:
TimeIndexFactoryException
IndexSpecificationException
IndexCreateException

create

public IndexView create(IndexType kind,
                        java.util.Properties indexProperties)
                 throws TimeIndexFactoryException,
                        IndexSpecificationException,
                        IndexCreateException
Create a new Time Index object given an IndexType. If the index already exists then an IndexView onto that index will be returned.

Parameters:
kind - One of IndexType.INLINE, IndexType.EXTERNAL, IndexType.SHADOW, IndexType.INCORE.
indexProperties - properties of the index needed at creat time, such as its name.
Throws:
TimeIndexFactoryException
IndexSpecificationException
IndexCreateException

open

public IndexView open(java.io.File indexFile)
               throws TimeIndexFactoryException,
                      IndexSpecificationException,
                      IndexOpenException
Retrieve a TimeIndex object by file name. e.g. TimeIndexFactory.open(new File(someDirectory, fileName))

Parameters:
indexFile - the file of the index
Throws:
TimeIndexFactoryException
IndexSpecificationException
IndexOpenException

open

public IndexView open(java.net.URI indexURI)
               throws TimeIndexFactoryException,
                      IndexSpecificationException,
                      IndexOpenException
Retrieve a TimeIndex object by URI. e.g. TimeIndexFactory.open(new URI("index", "", "/path/to/index", null));

Parameters:
indexURI - the URI of the index
Throws:
TimeIndexFactoryException
IndexSpecificationException
IndexOpenException

open

public IndexView open(java.util.Map indexMap)
               throws TimeIndexFactoryException,
                      IndexSpecificationException,
                      IndexOpenException
Retrieve a TimeIndex object by file name. e.g. TimeIndexFactory.open(properties)

Parameters:
indexMap - the filename of the index
Returns:
null if the index can't be opened
Throws:
TimeIndexFactoryException
IndexSpecificationException
IndexOpenException

open

public IndexView open(java.util.Properties indexProperties)
               throws TimeIndexFactoryException,
                      IndexSpecificationException,
                      IndexOpenException
Retrieve a TimeIndex object by file name. e.g. TimeIndexFactory.open(properties)

Parameters:
indexProperties - the filename of the index
Returns:
null if the index can't be opened
Throws:
TimeIndexFactoryException
IndexSpecificationException
IndexOpenException

save

public IndexView save(Index index,
                      IndexType kind,
                      java.util.Map indexMap)
               throws TimeIndexFactoryException,
                      IndexSpecificationException,
                      IndexCreateException,
                      TimeIndexException
Create a new Index object from an existing Index object. The type of the new Index is based on a constant, as defined in TimeType.

Parameters:
index - the original index to convert
kind - One of IndexType.INLINE, IndexType.EXTERNAL, IndexType.INCORE.
indexMap - property map of the index needed at create time, such as its name.
Throws:
TimeIndexFactoryException
IndexSpecificationException
IndexCreateException
TimeIndexException

save

public IndexView save(Index index,
                      IndexType kind,
                      java.util.Properties indexProperties)
               throws TimeIndexFactoryException,
                      IndexSpecificationException,
                      IndexCreateException,
                      TimeIndexException
Create a new Index object from an existing Index object. The type of the new Index is based on a constant, as defined in TimeType.

Parameters:
index - the original index to convert
kind - One of IndexType.INLINE, IndexType.EXTERNAL, IndexType.INCORE.
indexProperties - properties of the index needed at creat time, such as its name.
Throws:
TimeIndexFactoryException
IndexSpecificationException
IndexCreateException
TimeIndexException

append

public IndexView append(java.io.File indexFile)
                 throws TimeIndexFactoryException,
                        IndexSpecificationException,
                        IndexOpenException
Append to an index. e.g. TimeIndexFactory.append(new File(someDirectory, fileName))

Parameters:
indexFile - the file of the index
Throws:
TimeIndexFactoryException
IndexSpecificationException
IndexOpenException

append

public IndexView append(java.net.URI uri)
                 throws TimeIndexFactoryException,
                        IndexSpecificationException,
                        IndexOpenException
Append to an index. e.g. TimeIndexFactory.append(new File(someDirectory, fileName))

Parameters:
uri - the URI of the index
Throws:
TimeIndexFactoryException
IndexSpecificationException
IndexOpenException

append

public IndexView append(java.util.Map indexMap)
                 throws TimeIndexFactoryException,
                        IndexSpecificationException,
                        IndexOpenException
Append to an index. e.g. TimeIndexFactory.append(map)

Parameters:
indexMap - a Map spec of the index
Throws:
TimeIndexFactoryException
IndexSpecificationException
IndexOpenException

append

public IndexView append(java.util.Properties indexProperties)
                 throws TimeIndexFactoryException,
                        IndexSpecificationException,
                        IndexOpenException
Append to an index. e.g. TimeIndexFactory.appemd(properties)

Parameters:
indexProperties - a Properties spec of the index
Throws:
TimeIndexFactoryException
IndexSpecificationException
IndexOpenException

find

public IndexView find(ID indexID)
Try and find an Index, given its ID.


close

public boolean close(Index index)
              throws IndexCommitException,
                     IndexCloseException
Close an index

Returns:
whether the index was really closed. It might still be held open by another TimeIndex.
Throws:
IndexCommitException
IndexCloseException

eventMulticaster

public IndexEventMulticaster eventMulticaster()
Get the event listener.


addPrimaryEventListener

public void addPrimaryEventListener(IndexPrimaryEventListener l)
Add a IndexPrimaryEventListener.

Specified by:
addPrimaryEventListener in interface IndexEventGenerator

removePrimaryEventListener

public void removePrimaryEventListener(IndexPrimaryEventListener l)
Remove a IndexPrimaryEventListener.

Specified by:
removePrimaryEventListener in interface IndexEventGenerator

addAddEventListener

public void addAddEventListener(IndexAddEventListener l)
Add a IndexAddEventListener.

Specified by:
addAddEventListener in interface IndexEventGenerator

removeAddEventListener

public void removeAddEventListener(IndexAddEventListener l)
Remove a IndexAddEventListener.

Specified by:
removeAddEventListener in interface IndexEventGenerator

addAccessEventListener

public void addAccessEventListener(IndexAccessEventListener l)
Add a IndexAccessEventListener.

Specified by:
addAccessEventListener in interface IndexEventGenerator

removeAccessEventListener

public void removeAccessEventListener(IndexAccessEventListener l)
Remove a IndexAccessEventListener.

Specified by:
removeAccessEventListener in interface IndexEventGenerator

created

public void created(IndexPrimaryEvent ipe)
A notification that an Index has been created.

Specified by:
created in interface IndexPrimaryEventListener

opened

public void opened(IndexPrimaryEvent ipe)
A notification that an Index has been opened.

Specified by:
opened in interface IndexPrimaryEventListener

closed

public void closed(IndexPrimaryEvent ipe)
A notification that an Index has been closed.

Specified by:
closed in interface IndexPrimaryEventListener

committed

public void committed(IndexPrimaryEvent ipe)
A notification that an Index has been committed.

Specified by:
committed in interface IndexPrimaryEventListener

viewAdded

public void viewAdded(IndexPrimaryEvent ipe)
A notification that a view has been added to an Index.

Specified by:
viewAdded in interface IndexPrimaryEventListener

viewRemoved

public void viewRemoved(IndexPrimaryEvent ipe)
A notification that a view has been removed to an Index.

Specified by:
viewRemoved in interface IndexPrimaryEventListener

itemAdded

public void itemAdded(IndexAddEvent iae)
A notification that an IndexItem has been added to an Index.

Specified by:
itemAdded in interface IndexAddEventListener

itemAccessed

public void itemAccessed(IndexAccessEvent iae)
A notification that an IndexItem has been accessed in an Index.

Specified by:
itemAccessed in interface IndexAccessEventListener


Timeindexing 2008