org.activemath.omdocjdom.mbase
Class Heuristics

java.lang.Object
  extended by org.activemath.omdocjdom.mbase.Heuristics

public class Heuristics
extends Object

An extensiion of OJElement to contain the heuristics to resolve references.

Version:

Constructor Summary
Heuristics()
           
 
Method Summary
static void fillUpTableFromDocument(ElementFromIDTable table, OJDocument doc)
          Walks through the given document and finds all the nodes that have an attribute id and insert their entry into the table.
static ID resolveID(String idString, ElementFromIDTable table, MBaseErrorReporter errorReporter, OJElement referringElement)
          This method and resolveRef(org.activemath.omdocjdom.PointerElement, org.activemath.omdocjdom.mbase.ElementFromIDTable, org.activemath.omdocjdom.mbase.MBaseErrorReporter) contain all the heuristic needed for the current adaptation and this should disappear as soon as possible.
static ID resolveRef(PointerElement refElt, ElementFromIDTable table, MBaseErrorReporter errorReporter)
          This method and resolveID(java.lang.String, org.activemath.omdocjdom.mbase.ElementFromIDTable, org.activemath.omdocjdom.mbase.MBaseErrorReporter, org.activemath.omdocjdom.OJElement) contain all the heuristic needed for the current adaptation and this should disappear as soon as possible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Heuristics

public Heuristics()
Method Detail

resolveRef

public static ID resolveRef(PointerElement refElt,
                            ElementFromIDTable table,
                            MBaseErrorReporter errorReporter)
                     throws NoSuchIDException
This method and resolveID(java.lang.String, org.activemath.omdocjdom.mbase.ElementFromIDTable, org.activemath.omdocjdom.mbase.MBaseErrorReporter, org.activemath.omdocjdom.OJElement) contain all the heuristic needed for the current adaptation and this should disappear as soon as possible. It might even serve only as a transition.

It tries to find, in the table, in the following order, the referenced element:

  1. If the ref element contains a name (and possibly a theory or cd) attribute, then those are used with the same collection as here and without checking (these are all defined in the OMdoc DTD)
  2. Then the xref attribute is used, and is solved calling resolveID(java.lang.String, org.activemath.omdocjdom.mbase.ElementFromIDTable, org.activemath.omdocjdom.mbase.MBaseErrorReporter, org.activemath.omdocjdom.OJElement)
This makes it also work to resolve OMS elements.

Parameters:
refElement - The reference element supposed to be a child of this one
table - The table to check that referred elements exist
errorReporter - Use to report errors and (optionally) to raise exceptions
Throws:
NoSuchIDException

resolveID

public static ID resolveID(String idString,
                           ElementFromIDTable table,
                           MBaseErrorReporter errorReporter,
                           OJElement referringElement)
                    throws NoSuchIDException
This method and resolveRef(org.activemath.omdocjdom.PointerElement, org.activemath.omdocjdom.mbase.ElementFromIDTable, org.activemath.omdocjdom.mbase.MBaseErrorReporter) contain all the heuristic needed for the current adaptation and this should disappear as soon as possible. It might even serve only as a transition. It tries to find, in the table, in the following order, the referenced eleemnt:
  1. First it is checked weather a "/" is contained in the id, in which case it is interpreted using ID.makeRelativeID(org.activemath.omdocjdom.ID, java.lang.String)
  2. the id can be an MID, this is returned so if such an entry is found in the table.
  3. If the xref value is not a reachable mid, then the value is considered as either a name within the given theory or a name without theory (in which case it should be "/theName").

Throws:
NoSuchIDException

fillUpTableFromDocument

public static void fillUpTableFromDocument(ElementFromIDTable table,
                                           OJDocument doc)
Walks through the given document and finds all the nodes that have an attribute id and insert their entry into the table.

This method also contains a bit of heuristic as it inserts in the table for each element with id not only the full-fledged id, it also inserts a theory-less ID with value the value of the mid= attribute, if any, and another theory-less id with the value of the id. It would be urgent to fix this.