org.webdocwf.util.xml
Class XmlWriter

java.lang.Object
  extended by org.webdocwf.util.xml.XmlWriter

public class XmlWriter
extends java.lang.Object

Load existing XML file , creating DOM from file or creating new DOM.Class has methods for insert,update,delete data from XML file and save new DOM in XML file.

Author:
Zoran Milakovic

Field Summary
static SearchElement searchDocumentStatic
          Document made from XML file, and in which will be made changes.Document will be saved in XML file.
 
Constructor Summary
XmlWriter(java.lang.String fileName, boolean isAutoCommit)
          Constructor used when autoCommit is set to false or true.
 
Method Summary
static void commit(java.lang.String fileName)
          Method is used for saving DOM in xml file from connection object,when XmlConnection.commit() method is called.
protected  void createDatabase()
          Method is called when create new database file.
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)
          Delete row(s) from XML file.
protected  void dropTable(java.lang.String tableName)
          Delete table 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)
          Insert row in XML file.
protected  void saveDOM()
          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)
          Update row in in XML file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

searchDocumentStatic

public static SearchElement searchDocumentStatic
Document made from XML file, and in which will be made changes.Document will be saved in XML file.

Constructor Detail

XmlWriter

public XmlWriter(java.lang.String fileName,
                 boolean isAutoCommit)
          throws java.sql.SQLException
Constructor used when autoCommit is set to false or true.

Parameters:
fileName - name of xml file.
isAutoCommit - define is mod auto commit or not.
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 already 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
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
Delete table 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
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
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

createDatabase

protected void createDatabase()
                       throws java.sql.SQLException
Method is called when create new database file.

Throws:
java.sql.SQLException

saveDOM

protected void saveDOM()
                throws java.sql.SQLException
Save DOM as XML file.

Throws:
java.sql.SQLException

commit

public static void commit(java.lang.String fileName)
                   throws java.sql.SQLException
Method is used for saving DOM in xml file from connection object,when XmlConnection.commit() method is called.

Parameters:
fileName - full path of xml file.
Throws:
java.sql.SQLException


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