edu.wpi.cs.DSRG.xmldb.storeDTD
Class StoreDTD

java.lang.Object
  |
  +--edu.wpi.cs.DSRG.xmldb.storeDTD.StoreDTD

public class StoreDTD
extends java.lang.Object

StoreDTD.java provides the capability to store one or more DTDs (one at a time). The DTD information will be stored into the three MTables and three Views with be created for each DTD called: N_DTDM_Item, N_DTDM_Nesting, N_DTDM_Attribute.

Since:
1/18/2000

Field Summary
(package private)  JDBCClient client_connection
           
(package private)  int curr_DTD_ID
           
(package private)  int fillDTDMNestingItem_level
           
(package private) static int LOGID
           
(package private)  UniqueID unique_id
           
 
Constructor Summary
StoreDTD(JDBCClient client, UniqueID generator)
          This constructor is used when a JDBCClient connectin has already been established.
StoreDTD(java.lang.String DB_URI, java.lang.String username, java.lang.String password, UniqueID generator)
          This constructor is used when the user needs to specify a connection to a database using the JDBCClient class.
 
Method Summary
protected  void createDTDViews(int DTD_ID)
          The method createDTDViews() will create a DTD view for each DTD MTables (DTDM) that pertain only to entries from that dtd.
(package private)  void createGroup(Group a_group)
          The method createGroup() creates an item in the ALL_DTDS_DTDM_Table to represent the current group.
 void dropViews(java.lang.String XML_URI)
          The method dropViews() will drop all the views for the DTD that the XML document is compliant to.
(package private)  void fillDTDMAttributeTable(DTDWrapper wrapper)
          The method fillDTDMAtrributeTable() fills the ALL_DTDS_DTDM_Attribute table.
(package private)  void fillDTDMItemTable(DTDWrapper wrapper)
          The method fillDTDMItemTable() fills the relational tables for this current DTD.
private  void fillDTDMNestingItem(Item parent, int element_id)
          The method fillDTDMNestingItem() is used to recursively store all the references defined inside an item (group, elementTypeDeclaration).
(package private)  void fillDTDMNestingTable(DTDWrapper wrapper)
          The method fillDTDMNestingTable() fills the ALL_DTDS_DTDM_Nesting table.
(package private)  int getIDbyName(java.lang.String name)
          The method getIDbyName()gets the ID of a Item stored in ALL_DTDS_DTDM_Item table by its Name and the current DTD ID.
private  void initializeDTDMNestingTable(DTDWrapper wrapper)
           
 void store(java.lang.String XML_URI)
          The method store() will store a DTD into a database.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

LOGID

static final int LOGID

client_connection

JDBCClient client_connection

unique_id

UniqueID unique_id

curr_DTD_ID

int curr_DTD_ID

fillDTDMNestingItem_level

int fillDTDMNestingItem_level
Constructor Detail

StoreDTD

public StoreDTD(JDBCClient client,
                UniqueID generator)
This constructor is used when a JDBCClient connectin has already been established. A UniqueID object must also be passed in in order to guarantee unique ids in the database entries.
Parameters:
client - JDBCClient connection passed in that connects to a source database
generator - UniqueID generator passed in for keeping generating unique ids in the database

StoreDTD

public StoreDTD(java.lang.String DB_URI,
                java.lang.String username,
                java.lang.String password,
                UniqueID generator)
This constructor is used when the user needs to specify a connection to a database using the JDBCClient class. A UniqueID object must also be passed in in order to guarantee unique ids in the database entries.
Parameters:
DB_URI - String The URI of the database.
username - String The username of the database account
password - String The password of the database account
generator - UniqueID generator passed in for keeping generating unique ids in the database
Method Detail

createDTDViews

protected void createDTDViews(int DTD_ID)
The method createDTDViews() will create a DTD view for each DTD MTables (DTDM) that pertain only to entries from that dtd.
Parameters:
DTD_ID - int internal id for the current dtd

createGroup

void createGroup(Group a_group)
The method createGroup() creates an item in the ALL_DTDS_DTDM_Table to represent the current group.
Parameters:
a_group - Group current group

dropViews

public void dropViews(java.lang.String XML_URI)
               throws java.lang.Exception
The method dropViews() will drop all the views for the DTD that the XML document is compliant to.
Parameters:
XML_URI - String URI for XML document

fillDTDMAttributeTable

void fillDTDMAttributeTable(DTDWrapper wrapper)
The method fillDTDMAtrributeTable() fills the ALL_DTDS_DTDM_Attribute table. It requires query the ID from the ALL_DTDS_DTDM_Item table, and then put the attributes in the ALL_DTDS_DTDM_Attribute table.
Parameters:
wrapper - DTDWrapper currently wrapped dtd

fillDTDMItemTable

void fillDTDMItemTable(DTDWrapper wrapper)
The method fillDTDMItemTable() fills the relational tables for this current DTD. It will go through each ElementTypeDeclaration in the DTD, then insert the tuples into the ALL_DTDS_DTDM_Item table.
Parameters:
wrapper - DTDWrapper currently wrapped dtd

fillDTDMNestingItem

private void fillDTDMNestingItem(Item parent,
                                 int element_id)
The method fillDTDMNestingItem() is used to recursively store all the references defined inside an item (group, elementTypeDeclaration). Please notice, the top level group that has no indicator will not be considered as a group. It will fill up the nesting item by using the parent as default, when the element_id is -1 means, I have no ID for it, it will use the id of the parent in the ALL_DTDS_DTDM_Item table to fill the nesting table. In order to handle the case that some "group" is not a "meaningful" group I have to specify an element_id for it, instead of the id of that "group". So, in that case, the element_id will not be -1, and all the children of the "parent" will be linked to the "element_id".
Parameters:
parent - Item parent item
element_id - int element's id

fillDTDMNestingTable

void fillDTDMNestingTable(DTDWrapper wrapper)
The method fillDTDMNestingTable() fills the ALL_DTDS_DTDM_Nesting table. It will query the ID from the ALL_DTDS_DTDM_Item, and also create GROUP if encountered in storing the references. Please notice, if the element type declaration is ELEMENT.MIX, then it will have one nesting relationship to the PCDATA element. Also, if the element type is "ANY", we need to make all the nesting relationship to all the available elements too.
Parameters:
wrapper - DTDWrapper currently wrapped dtd

getIDbyName

int getIDbyName(java.lang.String name)
The method getIDbyName()gets the ID of a Item stored in ALL_DTDS_DTDM_Item table by its Name and the current DTD ID.
Parameters:
name - String item name

initializeDTDMNestingTable

private void initializeDTDMNestingTable(DTDWrapper wrapper)

store

public void store(java.lang.String XML_URI)
           throws java.lang.Exception
The method store() will store a DTD into a database. This will incrementally increase the content of the ALL_DTDS_DTDM. So, the ALL_DTDS_DTDM tables could store multiple DTDs.
Parameters:
XML_URI - String The URI of XML that reference to that DTD.