edu.wpi.cs.DSRG.xmldb.exportDTD
Class ExportDTD

java.lang.Object
  |
  +--edu.wpi.cs.DSRG.xmldb.exportDTD.ExportDTD

public class ExportDTD
extends java.lang.Object

ExportDTD.java generates a DTD document from three relational tables named ALL_DTDS_DTDM_Item, ALL_DTDS_DTDM_Nesting, and ALL_DTDS_DTDM_Attribute. The output is a file named .DTD in the current dir.

Since:
1/18/2000

Field Summary
(package private)  JDBCClient client_connection
           
(package private)  java.lang.String currentDTD
           
(package private)  java.lang.String currentDTDURI
           
(package private)  java.lang.String DTDM_Attribute
           
(package private)  java.lang.String DTDM_item
           
(package private)  java.lang.String DTDM_Nesting
           
(package private)  boolean isFirst
           
(package private)  java.io.BufferedWriter out
           
(package private)  java.sql.ResultSet rs
           
 
Constructor Summary
ExportDTD(JDBCClient client)
          This constructor is used when a JDBCClient connection has already been established.
ExportDTD(java.lang.String DB_URI, java.lang.String username, java.lang.String password)
          This constructor is used when you need to create a new JDBCClient object to establishes the connection with the database server.
 
Method Summary
 void chooseDTD()
          The method chooseDTD() sets the currentDTD name from the DTD URI.
protected  void closeOut()
          The method closeOut() closes the instance variable 'out' of type BufferedWriter.
 void create(java.lang.String uri)
          The method create() iterates through the ALL_DTDS_DTDM_Item relational table and dispatches appropriate item type handler and attribute handler if necessary for the item type.
protected  void createOut()
          The method createOut() creates the BufferedWriter and set the instance variable 'out' to be the new BufferedWriter.
protected  void handleATTLIST(java.lang.String id)
          The method handleATTLIST iterates through the DTDM_Attribute relational table for the given Item 'id' and writes the list of attribute for the given Item
protected  void handleELEMENT_ANY()
          The method handleELEMENT_ANY() writes the constant string 'ANY'.
protected  void handleELEMENT_ELEMENT(java.lang.String id)
          The method handleELEMENT_ELEMENT() iterates through the ALL_DTDS_DTDM_Nesting relational table and writes the element name if it is a simple type, otherwise calls itself to handle the complex child.
protected  void handleELEMENT_EMPTY()
          The method handleELEMENT_EMPTY() writes the constant string 'EMPTY'.
protected  void handleELEMENT_MIXED(java.lang.String id)
          The method handleELEMENT_MIXED iterates through the ALL_DTDS_DTDM_Nesting relational table and writes the element name of each simple item type.
protected  void handleELEMENT_PCDATA()
          The method handleELEMENT_PCDATA writes the constant string '(#PCDATA)'.
protected  java.lang.String Indicator(java.lang.String s1, java.lang.String s2)
          The method Indicator() returns the appropriate constant string depending on the fields: ratio and optional of the appropriate ALL_DTDS_DTDM_Nesting tuple
 void listDTDs()
          The method listDTDs() returns the list of DTDs stored
protected  void writeFile(java.lang.String s)
          The method writeFile just writes a string to the file.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

client_connection

JDBCClient client_connection

out

java.io.BufferedWriter out

rs

java.sql.ResultSet rs

isFirst

boolean isFirst

currentDTDURI

java.lang.String currentDTDURI

currentDTD

java.lang.String currentDTD

DTDM_item

java.lang.String DTDM_item

DTDM_Attribute

java.lang.String DTDM_Attribute

DTDM_Nesting

java.lang.String DTDM_Nesting
Constructor Detail

ExportDTD

public ExportDTD(JDBCClient client)
This constructor is used when a JDBCClient connection has already been established.
Parameters:
client - JDBCClient connection to database

ExportDTD

public ExportDTD(java.lang.String DB_URI,
                 java.lang.String username,
                 java.lang.String password)
This constructor is used when you need to create a new JDBCClient object to establishes the connection with the database server.
Parameters:
DB_URI - String location of the server
username - String username to the server
password - String password for the user name
Method Detail

closeOut

protected void closeOut()
The method closeOut() closes the instance variable 'out' of type BufferedWriter.

chooseDTD

public void chooseDTD()
The method chooseDTD() sets the currentDTD name from the DTD URI.

create

public void create(java.lang.String uri)
The method create() iterates through the ALL_DTDS_DTDM_Item relational table and dispatches appropriate item type handler and attribute handler if necessary for the item type. It ultimately recreates the DTD requested by the URI
Parameters:
uri - String DTD requested for recreate

createOut

protected void createOut()
The method createOut() creates the BufferedWriter and set the instance variable 'out' to be the new BufferedWriter.

handleATTLIST

protected void handleATTLIST(java.lang.String id)
The method handleATTLIST iterates through the DTDM_Attribute relational table for the given Item 'id' and writes the list of attribute for the given Item
Parameters:
id - String the id of the currrent defining element

handleELEMENT_ANY

protected void handleELEMENT_ANY()
The method handleELEMENT_ANY() writes the constant string 'ANY'.

handleELEMENT_ELEMENT

protected void handleELEMENT_ELEMENT(java.lang.String id)
The method handleELEMENT_ELEMENT() iterates through the ALL_DTDS_DTDM_Nesting relational table and writes the element name if it is a simple type, otherwise calls itself to handle the complex child.
Parameters:
id - String the id of the currrent defining element

handleELEMENT_EMPTY

protected void handleELEMENT_EMPTY()
The method handleELEMENT_EMPTY() writes the constant string 'EMPTY'.

handleELEMENT_MIXED

protected void handleELEMENT_MIXED(java.lang.String id)
The method handleELEMENT_MIXED iterates through the ALL_DTDS_DTDM_Nesting relational table and writes the element name of each simple item type.
Parameters:
id - String the id of the current defining element

handleELEMENT_PCDATA

protected void handleELEMENT_PCDATA()
The method handleELEMENT_PCDATA writes the constant string '(#PCDATA)'.

Indicator

protected java.lang.String Indicator(java.lang.String s1,
                                     java.lang.String s2)
The method Indicator() returns the appropriate constant string depending on the fields: ratio and optional of the appropriate ALL_DTDS_DTDM_Nesting tuple
Parameters:
s1 - multiple
s2 - optional
Returns:
return a constant string

listDTDs

public void listDTDs()
The method listDTDs() returns the list of DTDs stored

writeFile

protected void writeFile(java.lang.String s)
The method writeFile just writes a string to the file.
Parameters:
s - String the string that will be written to the out file