org.activemath.omdocjdom.mbase
Class MBaseBuilder

java.lang.Object
  extended by org.activemath.omdocjdom.mbase.MBaseBuilder
All Implemented Interfaces:
Serializable

public class MBaseBuilder
extends Object
implements Serializable

This class is responsible for building the JDOM documents (more precisely the OJDocument with elements of class MBaseItem) and to build the table of id and the dependencies information.

This is then used to create the OmdocJdomMBase. One such element is need for each new instances of OmdocJdomMBase.

Invocation of this class can be done through two ways: either through a command-line invocation (this OmdocJdomMBase's main invocation is coming to the one here) or through properties.

Version:
See Also:
Serialized Form

Nested Class Summary
protected  class MBaseBuilder.MBaseFactory
           
 
Field Summary
protected  Exception buildException
           
static int CORRECT_ABSOLUTE
           
static int CORRECT_NONE
           
static int CORRECT_RELATIVE
           
static String CVS_ID
           
 
Constructor Summary
MBaseBuilder(Subconfiguration props)
          Complete constructor from the properties which are properties to override makeDefaultProperties().
 
Method Summary
 OmdocJdomMBase buildMBase()
          Makes the whole construction from a set of files given as String paths.
 void fixRef(OJElement elt, OJElement fromWhere, String attName, ID resolvedID)
          Sets the value of the attribute of name attName to be the URI pointed by resolvedID according to the correction politics as stored in correction variable.
 List getDocuments()
           
 Exception getException()
           
 OmdocJdomMBase getMBase()
          Returns the mbase that has been prepared.
 MBaseRef getSurroundingMBaseRef()
          Gets the surrounding MBaseRef used to check the existence of items outside of the currently loaded MBase.
protected  void initSaxBuilder()
           
static void main(String[] args)
          Main invocation of the MBase.
static void printUsage(OutputStream outStream)
          Prints the usage text.
 void rebuild()
          This method calls all the table and dependency rebuilding mechanisms.
 void reloadOMdocs()
          Reloads the OMDocs stored in the paths variable.
protected  boolean runLastThings()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CVS_ID

public static final String CVS_ID
See Also:
Constant Field Values

CORRECT_RELATIVE

public static final int CORRECT_RELATIVE
See Also:
Constant Field Values

CORRECT_ABSOLUTE

public static final int CORRECT_ABSOLUTE
See Also:
Constant Field Values

CORRECT_NONE

public static final int CORRECT_NONE
See Also:
Constant Field Values

buildException

protected Exception buildException
Constructor Detail

MBaseBuilder

public MBaseBuilder(Subconfiguration props)
             throws Exception
Complete constructor from the properties which are properties to override makeDefaultProperties(). Note that the builder is then only ready to be fed with documents.

Properties that can be set are the following (note that the ActiveMath manager uses the prefix OmdocJdomMbase:

This class uses the MBaseRef service to be used as surrounding MBaseRef allowing the items not in the being loaded database to be checked for their existance in the other database.

Throws:
Exception
Method Detail

main

public static void main(String[] args)
                 throws Exception
Main invocation of the MBase. Reads the parameters and creates a new OmdocJdomMBase with all the documents (loaded from the parameters).

Throws:
Exception

runLastThings

protected boolean runLastThings()

printUsage

public static void printUsage(OutputStream outStream)
Prints the usage text.


reloadOMdocs

public void reloadOMdocs()
                  throws IOException
Reloads the OMDocs stored in the paths variable.

Throws:
IOException

buildMBase

public OmdocJdomMBase buildMBase()
                          throws NoSuchIDException,
                                 IOException
Makes the whole construction from a set of files given as String paths. Not be used in a concurrency setting: the builder is nullified. This method currently eats all exceptions and the MBase returned might as well pretty crooked, please check with the getException();

Throws:
NoSuchIDException
IOException

getMBase

public OmdocJdomMBase getMBase()
Returns the mbase that has been prepared. That is the object to be used to send read queries.


getException

public Exception getException()

getDocuments

public List getDocuments()

initSaxBuilder

protected void initSaxBuilder()

getSurroundingMBaseRef

public MBaseRef getSurroundingMBaseRef()
Gets the surrounding MBaseRef used to check the existence of items outside of the currently loaded MBase.


rebuild

public void rebuild()
             throws NoSuchIDException
This method calls all the table and dependency rebuilding mechanisms. It does not (re-)load the documents and assumes that the dependencies are all removed. It is called once the document collection is completely loaded and after each new load.

Throws:
NoSuchIDException

fixRef

public void fixRef(OJElement elt,
                   OJElement fromWhere,
                   String attName,
                   ID resolvedID)
Sets the value of the attribute of name attName to be the URI pointed by resolvedID according to the correction politics as stored in correction variable. That is to say the attribute value is replaced by the absolute URI if correction is CORRECT_ABSOLUTE, to the shortest URI (as given by ID.expressShortestRef(org.activemath.omdocjdom.OJElement, org.activemath.omdocjdom.OJElement)) if correction is CORRECT_RELATIVE or doesn't do anything if the correction is CORRECT_NONE.

This method does not complain and catches all exceptions... It is expected that a prior resolver has already complained.

Parameters:
elt - The elment to change (or add) the attribute
fromWhere - The element from where the reference is taken (probably same as elt, used to express shortest path in relative IDs)
attName - The name of the attribute to fix
resolvedID - The ID resolved appropriately to all possible rules or heuristics