org.webdocwf.util.xml
Class XmlWriter

java.lang.Object
  |
  +--org.webdocwf.util.xml.XmlWriter

public class XmlWriter
extends java.lang.Object

Load existing XML file , creating DOM from file or creating new DOM.Methods will change DOM and save new DOM in XML file.

Version:
1.0
Author:
Zoran Milakovic

Constructor Summary
XmlWriter(java.lang.String fileName)
          Constructor will build Document from the specified file if file exist, or will create new Document if file not exist.
 
Method Summary
protected  void createTable(java.lang.String sqlStatement, java.lang.String tableName)
          Adds sql statement CREATE TABLE in XML file.
protected  void delete(java.lang.String tableName, java.lang.String[] whereColumnNames, java.lang.String[] whereColumnValues)
          Method will delete row(s) from XML file.
protected  void dropTable(java.lang.String tableName)
          Method will delete row(s) from XML file.
 java.util.ArrayList getTableProperties(java.lang.String tableName)
          Gets table properties in form ArrayList.
protected  void insert(java.lang.String tableName, java.lang.String[] columnNames, java.lang.String[] columnValues)
          Method will insert row in XML file.
protected  void saveDOM(org.w3c.dom.Node document)
          Save DOM as XML file.
protected  void update(java.lang.String tableName, java.lang.String[] columnNames, java.lang.String[] columnValues, java.lang.String[] whereColumnNames, java.lang.String[] whereColumnValues)
          Method will update row in in XML file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlWriter

public XmlWriter(java.lang.String fileName)
          throws java.sql.SQLException
Constructor will build Document from the specified file if file exist, or will create new Document if file not exist.

Parameters:
fileName - full pathname of the XML file
Throws:
java.sql.SQLException
Method Detail

createTable

protected void createTable(java.lang.String sqlStatement,
                           java.lang.String tableName)
                    throws java.sql.SQLException
Adds sql statement CREATE TABLE in XML file. Method will throw SQLException with appropriate message if table allready exist

Parameters:
sqlStatement - CREATE TABLE statement which will be add into XML file
tableName - name of table which will be created
Throws:
java.sql.SQLException

delete

protected void delete(java.lang.String tableName,
                      java.lang.String[] whereColumnNames,
                      java.lang.String[] whereColumnValues)
               throws java.sql.SQLException
Method will delete row(s) from XML file.

Parameters:
tableName - name of table from which will be deleted rows.
whereColumnNames - names of columns in WHERE clause.
whereColumnValues - values of columns in WHERE clause.
Throws:
java.sql.SQLException

dropTable

protected void dropTable(java.lang.String tableName)
                  throws java.sql.SQLException
Method will delete row(s) from XML file.

Parameters:
tableName - name of table which will be deleted.
Throws:
java.sql.SQLException

insert

protected void insert(java.lang.String tableName,
                      java.lang.String[] columnNames,
                      java.lang.String[] columnValues)
               throws java.sql.SQLException
Method will insert row in XML file.

Parameters:
tableName - name of table in which will be added rows.
columnNames - names of columns in which will be added data.
columnValues - value which will be insert into table.
Throws:
java.sql.SQLException

update

protected void update(java.lang.String tableName,
                      java.lang.String[] columnNames,
                      java.lang.String[] columnValues,
                      java.lang.String[] whereColumnNames,
                      java.lang.String[] whereColumnValues)
               throws java.sql.SQLException
Method will update row in in XML file.

Parameters:
tableName - name of table which will be updatad.
columnNames - names of columns in which will be added data.
columnValues - value which will be insert into table.
whereColumnNames - names of columns in WHERE clause.
whereColumnValues - values of columns in WHERE clause.
Throws:
java.sql.SQLException

getTableProperties

public java.util.ArrayList getTableProperties(java.lang.String tableName)
                                       throws java.sql.SQLException
Gets table properties in form ArrayList. ArrayList[0] is string array with ALL column names in table. ArrayList[1] is string array with colmn names which are PRIMARYKEYs. ArrayList[2] is string array with colmn names which can not be NULL. If table has no CREATE TABLE statement , ArrayList[1] will have value "NO CREATE TABLE"

Parameters:
tableName - name of table.
Returns:
list of table properties.
Throws:
java.sql.SQLException

saveDOM

protected void saveDOM(org.w3c.dom.Node document)
                throws java.sql.SQLException
Save DOM as XML file.

Parameters:
document - DOM which will be saved in XML file.
Throws:
java.sql.SQLException


Copyright © 2002-2003 Together - the Workgroup. All Rights Reserved.