org.weborganic.flint.index
Class IndexParser

java.lang.Object
  extended by org.weborganic.flint.index.IndexParser

public final class IndexParser
extends Object

This handler makes a Lucene 2 Document out of a properly formatted XML document.

The XML document must validate the Lucene Index Document DTD.

For example:

<document>
   <field name="modified" store="yes" index="yes" parse-date-as="MMM dd, yy" resolution="day">Jan 12, 02</field>
   <field name="path"     store="yes" index="no" >C:\documents\00023.xml</field>
   <field name="webpath"  store="yes" index="no" >/documents/doc-23.xml</field>
   <field name="text" store="compress" index="tokenised" >
     Truly to speak, and with no addition,
     We go to gain a little patch of ground
     That hath in it no profit but the name.
     To pay five ducats, five, I would not farm it;
     Nor will it yield to Norway or the Pole
     A ranker rate, should it be sold in fee.
   </field>
 </document>
 

See Also:
Index Documents 1.0 Schema, Index Documents 2.0 Schema

Method Summary
 List<Document> process(File f)
          Returns a list of Lucene documents to be indexed from the XML file given.
 List<Document> process(InputSource source)
          Make a collection Lucene documents to be indexed from the XML file given.
static Field.Index toFieldIndex(String index)
          Returns the Lucene2 Field Index from the attribute value.
static Field.Store toFieldStore(String store)
          Returns the Lucene2 Field Store from the attribute value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toFieldStore

public static Field.Store toFieldStore(String store)
Returns the Lucene2 Field Store from the attribute value.

Parameters:
store - The store flag as a string.
Returns:
The corresponding Lucene2 constant.

toFieldIndex

public static Field.Index toFieldIndex(String index)
Returns the Lucene2 Field Index from the attribute value.

Parameters:
index - The index flag as a string.
Returns:
The corresponding Lucene2 constant.

process

public List<Document> process(InputSource source)
                       throws IndexException
Make a collection Lucene documents to be indexed from the XML file given.

The XML file must conform to the DTD defined in this class.

Ensure that the reader uses the correct encoding.

Parameters:
source - The source to read.
Returns:
A collection of Lucene documents made from the file.
Throws:
IndexException - Should an error occur while parsing the file.

process

public List<Document> process(File f)
                       throws IndexException
Returns a list of Lucene documents to be indexed from the XML file given.

The XML file must conform to the DTD defined in this class.

Parameters:
f - the file to be read
Returns:
A collection of Lucene documents made from the file.
Throws:
IndexException - Should an error occur while parsing the file.
See Also:
#make(java.io.Reader)