org.activemath.omdocjdom.lucene
Class LuceneUtilities

java.lang.Object
  extended by org.activemath.omdocjdom.lucene.LuceneUtilities

public class LuceneUtilities
extends Object

This is utitlity class of Lucence base MBase implementation.

Version:

Field Summary
static HashSet INDEXER_ITEMS
           
static HashSet NONVISIBLEITEMS
           
static HashSet OJITEMS
           
 
Constructor Summary
LuceneUtilities()
           
 
Method Summary
static Iterator computeMetadataAttributes(OJElement metadataElt)
          Goes through the metadata and returns any element-name followed by ":" and a sole attribute of any child provided it is not relation and it is not in the OJConstants.DC_NAMESPACE.
static void copyFile(File from, File to)
          Copies a file from one location to another.
static void createBackUp(String location)
          This method creates a back up of existing database.
static boolean deletePath(String path)
           
 org.jdom.Element dublicateElementWithoutDependency(org.jdom.Element source)
           
static int getLuceneBuild(File file)
          this method get build number of lucene database.
static OJElement getorMakeMetadataExtradata(OJElement source)
          This method extracts extra data from the source element.
static String getXMLText(org.jdom.Element elt)
          This method build indent xml text from the given Element object
static String getXMLText(org.jdom.Element elt, boolean withRoot)
           
protected static HashSet initIndexerItems()
           
protected static HashSet initNonVisibleItems()
           
protected static HashSet initOJItems()
           
static boolean isIndexerItem(String name)
          This method tells whether the indexer will create the index of this item or not.
static boolean isLuceneMBaseItem(String name)
           
static boolean isNonVisibleItem(String name)
           
static void main(String[] args)
           
static void makeSureTheresAnIndexAt(File dir)
          Tries to read the index and create it if necessary.
static boolean recoverDB(String location)
          If the database is crashed during the previous update then this procedure will try to recover the database.
static int setLuceneBuild(File file)
          this method increment the build number in lucene
static List split(String source, String del)
          A utility method to return the extradata child of the item and create it, if it is missing.
static Reader wrapReader(Reader origin, String start, String end)
           
static void writeDocument(org.jdom.Document doc, File file)
          This method build indent xml text from the given org.jdom.Document object then write it in the file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INDEXER_ITEMS

public static final HashSet INDEXER_ITEMS

OJITEMS

public static final HashSet OJITEMS

NONVISIBLEITEMS

public static final HashSet NONVISIBLEITEMS
Constructor Detail

LuceneUtilities

public LuceneUtilities()
Method Detail

getXMLText

public static String getXMLText(org.jdom.Element elt)
This method build indent xml text from the given Element object

Parameters:
elt - Source element
Returns:
xml text String.

getXMLText

public static String getXMLText(org.jdom.Element elt,
                                boolean withRoot)

makeSureTheresAnIndexAt

public static void makeSureTheresAnIndexAt(File dir)
                                    throws IOException
Tries to read the index and create it if necessary. May lock if another lock is on the index.

Parameters:
dir - directory where the index is to be
Throws:
IOException - if low-level write errors occur
IllegalStateException - is something else happens.

writeDocument

public static void writeDocument(org.jdom.Document doc,
                                 File file)
                          throws IOException
This method build indent xml text from the given org.jdom.Document object then write it in the file

Parameters:
doc - Document Source document
Throws:
IOException

initIndexerItems

protected static HashSet initIndexerItems()

initOJItems

protected static HashSet initOJItems()

isLuceneMBaseItem

public static boolean isLuceneMBaseItem(String name)

initNonVisibleItems

protected static HashSet initNonVisibleItems()

isNonVisibleItem

public static boolean isNonVisibleItem(String name)

isIndexerItem

public static boolean isIndexerItem(String name)
This method tells whether the indexer will create the index of this item or not.

Parameters:
name - the item name.
Returns:
true if indexer will create the index of this item otherwise false

split

public static List split(String source,
                         String del)
A utility method to return the extradata child of the item and create it, if it is missing.


dublicateElementWithoutDependency

public final org.jdom.Element dublicateElementWithoutDependency(org.jdom.Element source)

getorMakeMetadataExtradata

public static OJElement getorMakeMetadataExtradata(OJElement source)
This method extracts extra data from the source element. If the extradata does not exsist then it creates and return it.

Parameters:
source - an OJElement value. Source element.
Returns:
an OJElement value. It contains the extradata for the source element.

recoverDB

public static boolean recoverDB(String location)
                         throws IOException
If the database is crashed during the previous update then this procedure will try to recover the database.

Throws:
IOException

createBackUp

public static void createBackUp(String location)
                         throws IOException
This method creates a back up of existing database. If the database is crashed during updation then is backup will be used to recover the database.

Throws:
IOException

setLuceneBuild

public static int setLuceneBuild(File file)
                          throws IOException
this method increment the build number in lucene

Parameters:
file -
Returns:
The new build number
Throws:
IOException

getLuceneBuild

public static int getLuceneBuild(File file)
                          throws IOException
this method get build number of lucene database.

Parameters:
file -
Returns:
returns the build-number
Throws:
IOException

copyFile

public static void copyFile(File from,
                            File to)
                     throws IOException
Copies a file from one location to another. Uses buffered streams.

Parameters:
from - source file
to - destination file
Throws:
IOException
See Also:
JPIOPerformance

deletePath

public static boolean deletePath(String path)

computeMetadataAttributes

public static Iterator computeMetadataAttributes(OJElement metadataElt)
Goes through the metadata and returns any element-name followed by ":" and a sole attribute of any child provided it is not
relation
and it is not in the OJConstants.DC_NAMESPACE.


wrapReader

public static Reader wrapReader(Reader origin,
                                String start,
                                String end)

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception