org.apache.lenya.lucene.index
Class IndexIterator

java.lang.Object
  extended by org.apache.lenya.lucene.index.IndexIterator

public class IndexIterator
extends java.lang.Object


Constructor Summary
IndexIterator(java.lang.String index, java.io.FileFilter filter)
          Creates a new instance of IndexItertor
 
Method Summary
 void addHandler(IndexIteratorHandler handler)
          DOCUMENT ME!
protected  void collectFiles(java.io.File file, java.util.List files)
          Collect files
static java.lang.String createID(java.io.File file, java.io.File dumpDir)
          Create a unique id
static java.lang.String createUID(java.io.File file, java.io.File htdocsDumpDir)
          Append path and date into a string in such a way that lexicographic sorting gives the same results as a walk of the file hierarchy.
protected  org.apache.lucene.index.TermEnum enumerateUIDs(org.apache.lucene.index.IndexReader reader)
          Returns an term enumerator beginning with the first term that represents a UID field.
 java.io.File[] getFiles(java.io.File dumpDirectory)
          Get Files and sorts by alphabet?
protected  java.io.FileFilter getFilter()
           
protected  java.lang.String getIndex()
           
protected  org.apache.lucene.index.IndexReader getReader()
           
protected  void handleFile(java.io.File file)
           
protected  void handleNewDocument(org.apache.lucene.index.Term term, java.io.File file)
           
protected  void handleStaleDocument(org.apache.lucene.index.Term term)
           
protected  void handleUnmodifiedDocument(org.apache.lucene.index.Term term, java.io.File file)
           
protected static boolean hasEqualUID(org.apache.lucene.index.Term term, java.lang.String uid)
          Returns true if the file described by uid has the same UID as the file described by the existing UID term.
protected static boolean isStale(org.apache.lucene.index.Term term, java.lang.String uid)
          Returns true if the file described by uid has a bigger UID than the file described by the existing UID term.
protected static boolean isUIDTerm(org.apache.lucene.index.Term term)
          Returns if the term is not null and decribes a UID field.
 void iterate(java.io.File dumpDirectory)
          Iterate over all files within directory
protected  void iterateFiles(org.apache.lucene.index.TermEnum iterator, java.io.File file, java.io.File dumpDirectory)
           
protected  void traverse(org.apache.lucene.index.TermEnum iterator, java.io.File file, java.io.File dumpDirectory)
          Traverse directory
static java.lang.String uid2url(java.lang.String uid)
          Converts a UID to a URL string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexIterator

public IndexIterator(java.lang.String index,
                     java.io.FileFilter filter)
Creates a new instance of IndexItertor

Method Detail

getIndex

protected java.lang.String getIndex()

getFilter

protected java.io.FileFilter getFilter()
Returns:
FileFilter

addHandler

public void addHandler(IndexIteratorHandler handler)
DOCUMENT ME!

Parameters:
handler - DOCUMENT ME!

handleFile

protected void handleFile(java.io.File file)

handleStaleDocument

protected void handleStaleDocument(org.apache.lucene.index.Term term)

handleUnmodifiedDocument

protected void handleUnmodifiedDocument(org.apache.lucene.index.Term term,
                                        java.io.File file)

handleNewDocument

protected void handleNewDocument(org.apache.lucene.index.Term term,
                                 java.io.File file)

getReader

protected org.apache.lucene.index.IndexReader getReader()

iterate

public void iterate(java.io.File dumpDirectory)
Iterate over all files within directory

Parameters:
dumpDirectory - Directory over which shall be iterated

iterateFiles

protected void iterateFiles(org.apache.lucene.index.TermEnum iterator,
                            java.io.File file,
                            java.io.File dumpDirectory)
                     throws java.io.IOException
Throws:
java.io.IOException

enumerateUIDs

protected org.apache.lucene.index.TermEnum enumerateUIDs(org.apache.lucene.index.IndexReader reader)
Returns an term enumerator beginning with the first term that represents a UID field.


isUIDTerm

protected static boolean isUIDTerm(org.apache.lucene.index.Term term)
Returns if the term is not null and decribes a UID field.


isStale

protected static boolean isStale(org.apache.lucene.index.Term term,
                                 java.lang.String uid)
Returns true if the file described by uid has a bigger UID than the file described by the existing UID term.


hasEqualUID

protected static boolean hasEqualUID(org.apache.lucene.index.Term term,
                                     java.lang.String uid)
Returns true if the file described by uid has the same UID as the file described by the existing UID term.


createID

public static java.lang.String createID(java.io.File file,
                                        java.io.File dumpDir)
Create a unique id

Parameters:
file - file to index
dumpDir - dump directory
Returns:
id

createUID

public static java.lang.String createUID(java.io.File file,
                                         java.io.File htdocsDumpDir)
Append path and date into a string in such a way that lexicographic sorting gives the same results as a walk of the file hierarchy. Thus null () is used both to separate directory components and to separate the path from the date.

Parameters:
file - DOCUMENT ME!
htdocsDumpDir - DOCUMENT ME!
Returns:
DOCUMENT ME!

uid2url

public static java.lang.String uid2url(java.lang.String uid)
Converts a UID to a URL string.


getFiles

public java.io.File[] getFiles(java.io.File dumpDirectory)
Get Files and sorts by alphabet?


collectFiles

protected void collectFiles(java.io.File file,
                            java.util.List files)
Collect files


traverse

protected void traverse(org.apache.lucene.index.TermEnum iterator,
                        java.io.File file,
                        java.io.File dumpDirectory)
                 throws java.io.IOException
Traverse directory

Throws:
java.io.IOException


Copyright © 1999-2005 Apache Software Foundation. All Rights Reserved.