com.xpn.xwiki.plugin.lucene
Class XWikiDocumentQueue

java.lang.Object
  extended by com.xpn.xwiki.plugin.lucene.XWikiDocumentQueue

public class XWikiDocumentQueue
extends java.lang.Object

This class represents a Queue (FirstInFirstOut) for XWikiDocument objects. It is used during indexing of the wiki. The index is updated whenever the processing queue is not empty. This class is threadsafe, as usually several threads add elements and one thread removes them for processing.

Version:
$Id: XWikiDocumentQueue.java 25406 2009-12-02 16:44:37Z tmortagne $

Constructor Summary
XWikiDocumentQueue()
           
 
Method Summary
 void add(IndexData data)
          Adds an item to the queue.
 int getSize()
          Returns the number of elements in the queue.
 boolean isEmpty()
          Check if the queue is empty or not.
 IndexData remove()
          Remove an item from the queue and return it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XWikiDocumentQueue

public XWikiDocumentQueue()
Method Detail

remove

public IndexData remove()
                 throws org.apache.commons.collections.BufferUnderflowException
Remove an item from the queue and return it. Since this is a FIFO, the element returned will be the oldes one in the queue.

Returns:
The oldest element in the queue.
Throws:
org.apache.commons.collections.BufferUnderflowException - If the queue is empty.

add

public void add(IndexData data)
Adds an item to the queue. Since this is a FIFO, it will be removed after all the other items already in the queue have been processed. If the element was already in the queue, it will not be added again (as a duplicate), its position will remain unchanged, but the associated data is updated, so the new version will replace the old unprocessed one.

Parameters:
data - IndexData object to add to the queue.

isEmpty

public boolean isEmpty()
Check if the queue is empty or not.

Returns:
true if the queue is empty, false otherwise.

getSize

public int getSize()
Returns the number of elements in the queue.

Returns:
Number of elements in the queue.


Copyright © 2004-2010 XWiki. All Rights Reserved.