org.ceryle.xnode
Class XNodeCatalog

java.lang.Object
  extended by java.lang.Thread
      extended by org.ceryle.xnode.XNodeCatalog
All Implemented Interfaces:
Runnable

public class XNodeCatalog
extends Thread

Creates a List containing XNodeIDs of all XNodes in the current XNodeStore. Because this List can change rapidly, it also connects a listener to the XNodeStore to attempt to stay up to date (or at least invalidate itself).

The catalog is not expected to be kept current with the XNodeStore following its first access, though perhaps the implementation may change in the future to maintain synchronization.

Version:
$Id$
Author:
Murray Altheim

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
static String CATALOG_COMPLETE
          The ActionEvent command string used to indicate a completed catalog.
static String CATALOG_INCOMPLETE
          The ActionEvent command string used to indicate a incomplete catalog, due to either an error or an XNodeCollection or XNode not being found.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
XNodeCatalog(XNodeStore xnodestore, MessageHandler messagehandler, ActionListener listener)
          Constructor provided with the XNodeStore, a MessageHandler, and an optional ActionListener.
 
Method Summary
 List getCatalog()
          Return the List of the documents in the catalog as XNodeIDs.
 List getNotFound()
          Return the List of the documents in the original index but not found at catalog time.
 boolean hadNotFound()
          Returns true if there were any missing XNodeCollections or XNodes during the catalog process.
 void run()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CATALOG_COMPLETE

public static final String CATALOG_COMPLETE
The ActionEvent command string used to indicate a completed catalog. The value is "complete".

See Also:
Constant Field Values

CATALOG_INCOMPLETE

public static final String CATALOG_INCOMPLETE
The ActionEvent command string used to indicate a incomplete catalog, due to either an error or an XNodeCollection or XNode not being found. The value is "incomplete".

See Also:
Constant Field Values
Constructor Detail

XNodeCatalog

public XNodeCatalog(XNodeStore xnodestore,
                    MessageHandler messagehandler,
                    ActionListener listener)
Constructor provided with the XNodeStore, a MessageHandler, and an optional ActionListener. If an ActionListener is provided, it will receive an ActionEvent upon completion whose command indicates the status of the finished catalog CATALOG_COMPLETE or CATALOG_INCOMPLETE.

This will attach an XNodeStoreListener to the XNodeStore upon creation, and remove that listener, not upon completion, but the first time the catalog List is accessed.

Parameters:
xnodestore - the XNodeStore to query
messagehandler - the MessageHandler to receive messages and warnings
listener - an optional listener that will receive an ActionEvent upon completion
Method Detail

run

public void run()
Specified by:
run in interface Runnable
Overrides:
run in class Thread

getCatalog

public List getCatalog()
Return the List of the documents in the catalog as XNodeIDs.

If this method is called prior to completion of the catalog it returns null. Note that upon completion this method never returns null, so this is a safe indication of completion (if not using the ActionListener).

The first time this method is called following the completion of the catalog it will remove the XNodeStore listener.

Returns:
the List of XNodeIDs in the XNodeStore (an empty list rather than null).

getNotFound

public List getNotFound()
Return the List of the documents in the original index but not found at catalog time. This should generally be an empty List but if the XNodeStore is changing while the catalog is being built there may be some that are not available or deleted. Since this can't contain collections (XNodeIDs only refer to XNodes) there is still the possibility of missing any XNodes in a missing XNodeCollection. To be sure check the status via hadNotFound().


hadNotFound

public boolean hadNotFound()
Returns true if there were any missing XNodeCollections or XNodes during the catalog process. This is also set true if there were any errors in retrieval.



The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.