All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class org.xmlmiddleware.xmldbms.maps.utils.MapInverter

java.lang.Object
   |
   +----org.xmlmiddleware.xmldbms.maps.utils.MapInverter

public class MapInverter
extends Object
Invert the database-centric or XML-centric map objects in an XMLDBMSMap.

An XMLDBMSMap is the root of a graph of map objects. ClassMap, PropertyMap, InlineClassMap, and RelatedClassMap objects form an XML-centric view of the map. That is, they map XML elements, attributes, and PCDATA to database structures. ClassTableMap, PropertyTableMap, ColumnMap, ElementInsertionList, ElementInsertionMap, and RelatedClassTableMap objects form a database-centric view of the map. That is, they map tables and columns to XML structures.

MapInverter provides two methods. createXMLView() takes the XML-centric objects and creates database-centric objects. createDatabaseView() takes the database-centric objects and creates XML-centric objects. Note that neither method modifies the objects it inverts.

The primary users of MapInverter are map factories, which usually create one view and use the MapInverter to create the other view. For example, MapFactory_MapDocument and MapFactory_DTD create XML-centric objects, then use MapInverter to create the database-centric objects. MapFactory_Database creates database-centric objects, then uses MapInverter to create the XML-centric objects.

The correspondence between the XML-centric and database-centric objects is as follows. ClassMap corresponds to ClassTableMap. PropertyMap corresponds to ColumnMap and PropertyTableMap. InlineClassMap corresponds to ElementInsertionList and ElementInsertionMap. And RelatedClassMap corresponds to RelatedClassTableMap.

Version:
2.0
Author:
Ronald Bourret, 2001

Constructor Index

 o MapInverter()
Construct a new MapInverter.

Method Index

 o createDatabaseView(XMLDBMSMap)
Create the database-centric view.
 o createXMLView(XMLDBMSMap)
Create the XML-centric view.

Constructors

 o MapInverter
 public MapInverter()
Construct a new MapInverter.

Methods

 o createDatabaseView
 public void createDatabaseView(XMLDBMSMap map) throws XMLMiddlewareException
Create the database-centric view.

Warning: This method deletes any existing objects that form part of the database-centric view of the map.

Warning: If one ClassMap uses another ClassMap, this information is partially lost in the inversion process. The reason for this is that there is no place to store this information in a ClassTableMap. For example, suppose element types Book and Essay both use the ClassMap for element type Writing, which is mapped to the Writings table. A ClassTableMap can only be mapped to a single element type, so it is mapped to Writing, not Book or Essay.

Fortunately, this is not as bad as it sounds. If an element type that uses the ClassMap for another element type is mapped as a related class, then the usage information is retained. The reason for this is that the RelatedClassMap is inverted to a RelatedClassTableMap and the RelatedClassTableMap can store the name of the mapped element type.

Thus, the only real drawback at a mapping level is that used ClassMaps can't be round-tripped. That is, calling createDatabaseView() and then calling createXMLView() results in the loss of these ClassMaps. Fortunately, there seems to be no reason to round-trip such maps.

(At a data level, this means that root elements that use the ClassMaps of other elements can't be reconstructed -- the element type of the used ClassMap is reconstructed instead -- but that child elements that use the ClassMaps of other element types can be reconstructed.)

Throws: XMLMiddlewareException
Thrown if an error occurs creating the database-centric objects. This indicates a programming error, as it means the XML-centric objects are invalid.
 o createXMLView
 public void createXMLView(XMLDBMSMap map) throws XMLMiddlewareException
Create the XML-centric view.

Warning: This method deletes any existing objects that form part of the XML-centric view of the map.

Throws: XMLMiddlewareException
Thrown if an error occurs creating the XML-centric objects. This indicates a programming error, as it means the database-centric objects are invalid.

All Packages  Class Hierarchy  This Package  Previous  Next  Index